mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-20 04:09:45 +00:00
Use a config file instead of a hardcoded list so modpacks can customize it. Defaults to BloodMagic "NEIAlchemyRecipeHandler" for non GTNH usage.
This commit is contained in:
1 parent
8bdcf65250
commit
a88a13e7cf
5 files changed
+44
-8
No files matched your search
@@ -7,6 +7,7 @@ import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.ItemInfo;
|
||||
import cpw.mods.fml.client.CustomModLoadingErrorDisplayException;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
@@ -23,13 +24,25 @@ import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class ClientHandler
|
||||
{
|
||||
private static String[] defaultSerialHandlers = {
|
||||
"WayofTime.alchemicalWizardry.client.nei.NEIAlchemyRecipeHandler"
|
||||
};
|
||||
private static ClientHandler instance;
|
||||
|
||||
private ArrayList<EntityItem> SMPmagneticItems = new ArrayList<>();
|
||||
@@ -114,8 +127,29 @@ public class ClientHandler
|
||||
}
|
||||
|
||||
public static void preInit() {
|
||||
loadSerialHandlers();
|
||||
ItemInfo.preInit();
|
||||
}
|
||||
|
||||
public static void loadSerialHandlers() {
|
||||
File file = NEIClientConfig.serialHandlersFile;
|
||||
if(!file.exists()) {
|
||||
try(FileWriter writer = new FileWriter(file)) {
|
||||
NEIClientConfig.logger.info("Creating default serial handlers list {}", file);
|
||||
Collection<String> toSave = Loader.isModLoaded("dreamcraft") ? Collections.singletonList("") : Arrays.asList(defaultSerialHandlers);
|
||||
IOUtils.writeLines(toSave, "\n", writer);
|
||||
} catch (IOException e) {
|
||||
NEIClientConfig.logger.error("Failed to save default serial handlers list to file {}", file, e);
|
||||
}
|
||||
}
|
||||
try (FileReader reader = new FileReader(file)) {
|
||||
NEIClientConfig.logger.info("Loading serial handlers from file {}", file);
|
||||
NEIClientConfig.serialHandlers = new HashSet<>(IOUtils.readLines(reader));
|
||||
} catch (IOException e) {
|
||||
NEIClientConfig.logger.error("Failed to load serial handlers from file {}", file, e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
instance = new ClientHandler();
|
||||
|
||||
@@ -41,8 +41,7 @@ import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
public class NEIClientConfig
|
||||
{
|
||||
public class NEIClientConfig {
|
||||
private static boolean configLoaded;
|
||||
private static boolean enabledOverride;
|
||||
|
||||
@@ -54,6 +53,11 @@ public class NEIClientConfig
|
||||
public static ConfigSet world;
|
||||
public static final File bookmarkFile = new File(configDir, "bookmarks.ini");
|
||||
public static final File handlerFile = new File(configDir, "handlers.csv");
|
||||
public static final File serialHandlersFile = new File(configDir, "serialhandlers.cfg");
|
||||
|
||||
// Set of handlers that need to be run in serial
|
||||
public static HashSet<String> serialHandlers = new HashSet<>();
|
||||
|
||||
|
||||
public static ItemStack[] creativeInv;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package codechicken.nei.recipe;
|
||||
|
||||
import codechicken.core.TaskProfiler;
|
||||
import codechicken.nei.ItemList;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
@@ -58,7 +59,7 @@ public class GuiCraftingRecipe extends GuiRecipe
|
||||
return;
|
||||
|
||||
final String handlerClassStr = handlerClass.getName();
|
||||
if(Arrays.asList(serialHandlers).contains(handlerClassStr))
|
||||
if(NEIClientConfig.serialHandlers.contains(handlerClassStr))
|
||||
serialCraftingHandlers.add(handler);
|
||||
else
|
||||
craftinghandlers.add(handler);
|
||||
|
||||
@@ -36,10 +36,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class GuiRecipe extends GuiContainer implements IGuiContainerOverlay, IGuiClientSide, IGuiHandleMouseWheel, IContainerTooltipHandler, INEIGuiHandler {
|
||||
// List of handlers that need to be run in serial
|
||||
protected static final String[] serialHandlers = {
|
||||
"WayofTime.alchemicalWizardry.client.nei.NEIAlchemyRecipeHandler"
|
||||
};
|
||||
// Background image calculations
|
||||
private static final int BG_TOP_HEIGHT = 6;
|
||||
private static final int BG_MIDDLE_HEIGHT = 154;
|
||||
|
||||
@@ -2,6 +2,7 @@ package codechicken.nei.recipe;
|
||||
|
||||
import codechicken.core.TaskProfiler;
|
||||
import codechicken.nei.ItemList;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
@@ -58,7 +59,7 @@ public class GuiUsageRecipe extends GuiRecipe
|
||||
return;
|
||||
|
||||
final String handlerClassStr = handlerClass.getName();
|
||||
if(Arrays.asList(serialHandlers).contains(handlerClassStr))
|
||||
if(NEIClientConfig.serialHandlers.contains(handlerClassStr))
|
||||
serialUsageHandlers.add(handler);
|
||||
else
|
||||
usagehandlers.add(handler);
|
||||
|
||||
Reference in new issue
Block a user