diff --git a/src/main/java/techreborn/Core.java b/src/main/java/techreborn/Core.java index e18b88d35..7df066bb1 100644 --- a/src/main/java/techreborn/Core.java +++ b/src/main/java/techreborn/Core.java @@ -28,7 +28,6 @@ import net.minecraft.block.BlockDispenser; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fml.client.event.ConfigChangedEvent; import net.minecraftforge.fml.common.*; import net.minecraftforge.fml.common.event.*; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @@ -49,7 +48,6 @@ import techreborn.client.GuiHandler; import techreborn.command.TechRebornDevCommand; import techreborn.compat.CompatManager; import techreborn.compat.ICompatModule; -import techreborn.config.ConfigTechReborn; import techreborn.dispenser.BehaviorDispenseScrapbox; import techreborn.entities.EntityNukePrimed; import techreborn.events.BlockBreakHandler; @@ -69,7 +67,6 @@ import java.io.File; @Mod(modid = ModInfo.MOD_ID, name = ModInfo.MOD_NAME, version = ModInfo.MOD_VERSION, dependencies = ModInfo.MOD_DEPENDENCIES, guiFactory = ModInfo.GUI_FACTORY_CLASS, acceptedMinecraftVersions = "[1.12]", certificateFingerprint = "8727a3141c8ec7f173b87aa78b9b9807867c4e6b") public class Core { - public static ConfigTechReborn config; @SidedProxy(clientSide = ModInfo.CLIENT_PROXY_CLASS, serverSide = ModInfo.SERVER_PROXY_CLASS) public static CommonProxy proxy; @Mod.Instance @@ -92,10 +89,6 @@ public class Core { MinecraftForge.EVENT_BUS.register(this); configDir = new File(new File(event.getModConfigurationDirectory(), "teamreborn"), "techreborn"); - if (!configDir.exists()) { - configDir.mkdir(); - } - config = ConfigTechReborn.initialize(new File(configDir, "main.cfg")); worldGen = new TechRebornWorldGen(); worldGen.configFile = (new File(configDir, "ores.json")); //Must be done before the item classes are loaded. @@ -200,13 +193,6 @@ public class Core { } } - @SubscribeEvent - public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent cfgChange) { - if (cfgChange.getModID().equals("TechReborn")) { - ConfigTechReborn.Configs(); - } - } - @SubscribeEvent public void LoadPackets(RegisterPacketEvent event) { event.registerPacket(PacketSyncSideConfig.class, Side.SERVER); diff --git a/src/main/java/techreborn/compat/CompatManager.java b/src/main/java/techreborn/compat/CompatManager.java index a09fcfc0e..ff3e83fdc 100644 --- a/src/main/java/techreborn/compat/CompatManager.java +++ b/src/main/java/techreborn/compat/CompatManager.java @@ -34,7 +34,6 @@ import techreborn.compat.ic2.RecipesIC2; import techreborn.compat.theoneprobe.TheOneProbeCompat; import techreborn.compat.tinkers.CompatModuleTinkers; import techreborn.compat.waila.CompatModuleWaila; -import techreborn.config.ConfigTechReborn; import java.util.ArrayList; @@ -64,12 +63,13 @@ public class CompatManager { public void registerCompact(Class moduleClass, boolean config, Object... objs) { boolean shouldLoad = true; - if (config) { - shouldLoad = ConfigTechReborn.config - .get(ConfigTechReborn.CATEGORY_INTEGRATION, "Compat:" + moduleClass.getSimpleName(), true, - "Should the " + moduleClass.getSimpleName() + " be loaded?") - .getBoolean(true); - } + //TODO config +// if (config) { +// shouldLoad = ConfigTechReborn.config +// .get(ConfigTechReborn.CATEGORY_INTEGRATION, "Compat:" + moduleClass.getSimpleName(), true, +// "Should the " + moduleClass.getSimpleName() + " be loaded?") +// .getBoolean(true); +// } for (Object obj : objs) { if (obj instanceof String) { String modid = (String) obj; @@ -95,13 +95,6 @@ public class CompatManager { return; } } - if (config) { - if (ConfigTechReborn.config.hasChanged()) - ConfigTechReborn.config.save(); - if (!shouldLoad) { - return; - } - } try { compatModules.add(moduleClass.newInstance()); } catch (InstantiationException e) { diff --git a/src/main/java/techreborn/config/ConfigTechReborn.java b/src/main/java/techreborn/config/ConfigTechReborn.java index 2d39dc709..975c1337f 100644 --- a/src/main/java/techreborn/config/ConfigTechReborn.java +++ b/src/main/java/techreborn/config/ConfigTechReborn.java @@ -24,151 +24,40 @@ package techreborn.config; -import net.minecraftforge.common.config.Configuration; import reborncore.common.registration.RebornRegistry; import reborncore.common.registration.impl.ConfigRegistry; import techreborn.lib.ModInfo; -import java.io.File; - @RebornRegistry(modID = ModInfo.MOD_ID) public class ConfigTechReborn { - public static String CATEGORY_WORLD = "world"; - public static String CATEGORY_POWER = "power"; - public static String CATEGORY_CRAFTING = "crafting"; - public static String CATEGORY_UU = "uu"; - public static String CATEGORY_EMC = "emc"; - public static String CATEGORY_INTEGRATION = "Integration"; - public static String CATEGORY_FEATURES = "Features"; - @ConfigRegistry(config = "recipes", category = "railcraft", key = "disableRailcraftNugget", comment = "When true TechReborn will remove Railcrafts Iron Nugget to steel nuggert recipe.") public static boolean disableRailcraftSteelNuggetRecipe = false; - // Charge - public static int IronDrillCharge; - public static int DiamondDrillCharge; - public static int AdvancedDrillCharge; - public static int IronChainsawCharge; - public static int DiamondChainsawCharge; - public static int AdvancedChainsawCharge; - public static int SteelJackhammerCharge; - public static int DiamondJackhammerCharge; - public static int AdvancedJackhammerCharge; - public static int LapotronPackCharge; - public static int LithiumBatpackCharge; - public static int LapotronicOrbMaxCharge; - public static int OmniToolCharge; - public static int RockCutterCharge; - public static int CloakingDeviceCharge; - public static int CentrifugeCharge; - public static int ThermalGeneratorCharge; - // Crafting @ConfigRegistry(config = "recipes", category = "ic2", key = "deduplicate", comment = "Changes a lot of reipes and hides blocks to intrgrade TechReborn into IC2") public static boolean REMOVE_DUPLICATES = false; - // Client @ConfigRegistry(config = "client", category = "hud", key = "showChargeHud", comment = "Show the charge hud") public static boolean ShowChargeHud = true; @ConfigRegistry(config = "misc", category = "general", key = "enableGemTools", comment = "Enable Gem armor and tools") public static boolean enableGemArmorAndTools = true; - public static Configuration config; - private static ConfigTechReborn instance = null; + //TODO give an annotation + public static int IronDrillCharge = 10000; + public static int DiamondDrillCharge = 100000; + public static int AdvancedDrillCharge = 1000000; + public static int IronChainsawCharge = 10000; + public static int DiamondChainsawCharge = 10000; + public static int AdvancedChainsawCharge = 1000000; + public static int SteelJackhammerCharge = 1000000; + public static int DiamondJackhammerCharge = 20000; + public static int AdvancedJackhammerCharge = 100000; + public static int LapotronPackCharge = 100000000; + public static int LithiumBatpackCharge = 4000000; + public static int LapotronicOrbMaxCharge = 20000; + public static int OmniToolCharge = 20000; + public static int RockCutterCharge = 10000; + public static int CloakingDeviceCharge = 10000000; + public static int CentrifugeCharge = 1000000; + public static int ThermalGeneratorCharge = 1000000; - private ConfigTechReborn(File configFile) { - config = new Configuration(configFile); - config.load(); - - ConfigTechReborn.Configs(); - - config.save(); - - } - - public static ConfigTechReborn initialize(File configFile) { - - if (instance == null) - instance = new ConfigTechReborn(configFile); - else - throw new IllegalStateException("Cannot initialize TechReborn Config twice"); - - return instance; - } - - public static ConfigTechReborn instance() { - if (instance == null) { - - throw new IllegalStateException("Instance of TechReborn Config requested before initialization"); - } - return instance; - } - - public static void Configs() { - - // Charge - IronDrillCharge = config - .get(CATEGORY_POWER, "IronDrill MaxCharge", 10000, "Set the max charge for the iron drill").getInt(); - - DiamondDrillCharge = config - .get(CATEGORY_POWER, "DiamondDrill MaxCharge", 100000, "Set the max charge for the diamond drill") - .getInt(); - - AdvancedDrillCharge = config - .get(CATEGORY_POWER, "AdvancedDrill MaxCharge", 1000000, "Set the max charge for the advanced drill") - .getInt(); - - IronChainsawCharge = config - .get(CATEGORY_POWER, "IronChainsaw MaxCharge", 10000, "Set the max charge for the iron chainsaw") - .getInt(); - - DiamondChainsawCharge = config - .get(CATEGORY_POWER, "DiamondChainsaw MaxCharge", 100000, "Set the max charge for the diamond chainsaw") - .getInt(); - - AdvancedChainsawCharge = config.get(CATEGORY_POWER, "AdvancedChainsaw MaxCharge", 1000000, - "Set the max charge for the advanced chainsaw").getInt(); - - AdvancedJackhammerCharge = config - .get(CATEGORY_POWER, "AdvancedJackhammer MaxCharge", 100000, "Set the max charge for the advanced jackhammer") - .getInt(); - - SteelJackhammerCharge = config.get(CATEGORY_POWER, "SteelJackhammer MaxCharge", 10000, - "Set the max charge for the steel jackhammer").getInt(); - - DiamondJackhammerCharge = config.get(CATEGORY_POWER, "DiamondJackhammer MaxCharge", 20000, - "Set the max charge for the diamond jackhammer").getInt(); - - LapotronPackCharge = config - .get(CATEGORY_POWER, "LapotronPack MaxCharge", 100000000, "Set the max charge for the LapotronPack") - .getInt(); - - LapotronicOrbMaxCharge = config - .get(CATEGORY_POWER, "LapotronicOrb MaxCharge", 10000000, "Set the max charge for the LapotronicOrb") - .getInt(); - - LithiumBatpackCharge = config - .get(CATEGORY_POWER, "LithiumBatpack MaxCharge", 4000000, "Set the max charge for the LithiumBatpack") - .getInt(); - - OmniToolCharge = config.get(CATEGORY_POWER, "OmniTool MaxCharge", 20000, "Set the max charge for the OmniTool") - .getInt(); - - RockCutterCharge = config - .get(CATEGORY_POWER, "RockCutter MaxCharge", 10000, "Set the max charge for the RockCutter").getInt(); - - CloakingDeviceCharge = config - .get(CATEGORY_POWER, "CloakingDevice MaxCharge", 10000000, "Set the max charge for the CloakingDevice") - .getInt(); - - CentrifugeCharge = config - .get(CATEGORY_POWER, "Centrifuge MaxCharge", 1000000, "Set the max charge for the Centrifuge").getInt(); - - ThermalGeneratorCharge = config.get(CATEGORY_POWER, "ThermalGenerator MaxCharge", 1000000, - "Set the max charge for the ThermalGenerator").getInt(); - - - if (config.hasChanged()) { - config.save(); - } - } } diff --git a/src/main/java/techreborn/config/TechRebornConfigGui.java b/src/main/java/techreborn/config/TechRebornConfigGui.java index ea480fa17..5fedfeb22 100644 --- a/src/main/java/techreborn/config/TechRebornConfigGui.java +++ b/src/main/java/techreborn/config/TechRebornConfigGui.java @@ -25,170 +25,23 @@ package techreborn.config; import net.minecraft.client.gui.GuiScreen; -import net.minecraft.util.text.translation.I18n; -import net.minecraftforge.common.config.ConfigElement; -import net.minecraftforge.common.config.Configuration; -import net.minecraftforge.fml.client.config.DummyConfigElement; import net.minecraftforge.fml.client.config.GuiConfig; -import net.minecraftforge.fml.client.config.GuiConfigEntries; -import net.minecraftforge.fml.client.config.GuiConfigEntries.CategoryEntry; import net.minecraftforge.fml.client.config.IConfigElement; +import techreborn.lib.ModInfo; import java.util.ArrayList; import java.util.List; +//TODO load from config annoations public class TechRebornConfigGui extends GuiConfig { public TechRebornConfigGui(GuiScreen top) { - super(top, getConfigCategories(), "TechReborn", false, false, - GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config.toString())); + super(top, getConfigCategories(), ModInfo.MOD_ID, false, true, + ModInfo.MOD_NAME); } private static List getConfigCategories() { List list = new ArrayList<>(); - list.add( - new DummyConfigElement.DummyCategoryElement(I18n.translateToLocal("config.techreborn.category.general"), - "tr.configgui.category.trGeneral", TRGeneral.class)); - list.add(new DummyConfigElement.DummyCategoryElement(I18n.translateToLocal("config.techreborn.category.world"), - "tr.configgui.category.trWorld", TRWORLD.class)); - list.add(new DummyConfigElement.DummyCategoryElement(I18n.translateToLocal("config.techreborn.category.power"), - "tr.configgui.category.trPower", TRPOWER.class)); - list.add(new DummyConfigElement.DummyCategoryElement( - I18n.translateToLocal("config.techreborn.category.crafting"), "tr.configgui.category.trCrafting", - TRCRAFTING.class)); - list.add(new DummyConfigElement.DummyCategoryElement(I18n.translateToLocal("config.techreborn.category.uu"), - "tr.configgui.category.truu", TRUU.class)); - list.add(new DummyConfigElement.DummyCategoryElement(I18n.translateToLocal("config.techreborn.category.emc"), - "tr.configgui.category.tremc", TREMC.class)); - list.add(new DummyConfigElement.DummyCategoryElement( - I18n.translateToLocal("config.techreborn.category.integration"), "tr.configgui.category.treinter", - TRINT.class)); - return list; } - public static class TRGeneral extends CategoryEntry { - - public TRGeneral(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement configElement) { - super(owningScreen, owningEntryList, configElement); - } - - @Override - protected GuiScreen buildChildScreen() { - return new GuiConfig(this.owningScreen, - (new ConfigElement(ConfigTechReborn.config.getCategory(Configuration.CATEGORY_GENERAL))) - .getChildElements(), - this.owningScreen.modID, Configuration.CATEGORY_GENERAL, - this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart, - this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart, - GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config.toString())); - } - } - - // World - public static class TRWORLD extends CategoryEntry { - public TRWORLD(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement configElement) { - super(owningScreen, owningEntryList, configElement); - } - - @Override - protected GuiScreen buildChildScreen() { - return new GuiConfig(this.owningScreen, - (new ConfigElement(ConfigTechReborn.config.getCategory(ConfigTechReborn.CATEGORY_WORLD))) - .getChildElements(), - this.owningScreen.modID, Configuration.CATEGORY_GENERAL, - this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart, - this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart, - GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config.toString())); - } - } - - // Power - public static class TRPOWER extends CategoryEntry { - public TRPOWER(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement configElement) { - super(owningScreen, owningEntryList, configElement); - } - - @Override - protected GuiScreen buildChildScreen() { - return new GuiConfig(this.owningScreen, - (new ConfigElement(ConfigTechReborn.config.getCategory(ConfigTechReborn.CATEGORY_POWER))) - .getChildElements(), - this.owningScreen.modID, Configuration.CATEGORY_GENERAL, - this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart, - this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart, - GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config.toString())); - } - } - - // Crafting - public static class TRCRAFTING extends CategoryEntry { - public TRCRAFTING(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement configElement) { - super(owningScreen, owningEntryList, configElement); - } - - @Override - protected GuiScreen buildChildScreen() { - return new GuiConfig(this.owningScreen, - (new ConfigElement(ConfigTechReborn.config.getCategory(ConfigTechReborn.CATEGORY_CRAFTING))) - .getChildElements(), - this.owningScreen.modID, Configuration.CATEGORY_GENERAL, - this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart, - this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart, - GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config.toString())); - } - } - - // Crafting - public static class TRUU extends CategoryEntry { - public TRUU(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement configElement) { - super(owningScreen, owningEntryList, configElement); - } - - @Override - protected GuiScreen buildChildScreen() { - return new GuiConfig(this.owningScreen, - (new ConfigElement(ConfigTechReborn.config.getCategory(ConfigTechReborn.CATEGORY_UU))) - .getChildElements(), - this.owningScreen.modID, Configuration.CATEGORY_GENERAL, - this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart, - this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart, - GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config.toString())); - } - } - - // Emc - public static class TREMC extends CategoryEntry { - public TREMC(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement configElement) { - super(owningScreen, owningEntryList, configElement); - } - - @Override - protected GuiScreen buildChildScreen() { - return new GuiConfig(this.owningScreen, - (new ConfigElement(ConfigTechReborn.config.getCategory(ConfigTechReborn.CATEGORY_EMC))) - .getChildElements(), - this.owningScreen.modID, Configuration.CATEGORY_GENERAL, - this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart, - this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart, - GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config.toString())); - } - } - - // Mod Integration - public static class TRINT extends CategoryEntry { - public TRINT(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement configElement) { - super(owningScreen, owningEntryList, configElement); - } - - @Override - protected GuiScreen buildChildScreen() { - return new GuiConfig(this.owningScreen, - (new ConfigElement(ConfigTechReborn.config.getCategory(ConfigTechReborn.CATEGORY_INTEGRATION))) - .getChildElements(), - this.owningScreen.modID, Configuration.CATEGORY_GENERAL, - this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart, - this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart, - GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config.toString())); - } - } }