diff --git a/src/main/java/mekanism/client/ClientProxy.java b/src/main/java/mekanism/client/ClientProxy.java index 1c81e1a3f..2df318539 100644 --- a/src/main/java/mekanism/client/ClientProxy.java +++ b/src/main/java/mekanism/client/ClientProxy.java @@ -164,13 +164,14 @@ public class ClientProxy extends CommonProxy { super.loadConfiguration(); - Mekanism.configuration.load(); MekanismClient.enableSounds = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnableSounds", true).getBoolean(true); MekanismClient.fancyUniversalCableRender = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "FancyUniversalCableRender", true).getBoolean(true); MekanismClient.holidays = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "Holidays", true).getBoolean(true); MekanismClient.baseSoundVolume = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "SoundVolume", 1D).getDouble(1D); MekanismClient.machineEffects = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "MachineEffects", true).getBoolean(true); - Mekanism.configuration.save(); + + if(Mekanism.configuration.hasChanged()) + Mekanism.configuration.save(); } @Override diff --git a/src/main/java/mekanism/common/CommonProxy.java b/src/main/java/mekanism/common/CommonProxy.java index 7d03fc7dd..fb254b95d 100644 --- a/src/main/java/mekanism/common/CommonProxy.java +++ b/src/main/java/mekanism/common/CommonProxy.java @@ -182,19 +182,14 @@ public class CommonProxy */ public void loadConfiguration() { - Mekanism.configuration.load(); - Mekanism.osmiumGenerationEnabled = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "OsmiumGenerationEnabled", true).getBoolean(true); Mekanism.copperGenerationEnabled = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "CopperGenerationEnabled", true).getBoolean(true); Mekanism.tinGenerationEnabled = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "TinGenerationEnabled", true).getBoolean(true); - Mekanism.disableBCSteelCrafting = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "DisableBCSteelCrafting", false).getBoolean(false); - Mekanism.disableBCBronzeCrafting = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "DisableBCBronzeCrafting", false).getBoolean(false); Mekanism.updateNotifications = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "UpdateNotifications", true).getBoolean(true); Mekanism.controlCircuitOreDict = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ControlCircuitOreDict", true).getBoolean(true); Mekanism.logPackets = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "LogPackets", false).getBoolean(false); Mekanism.dynamicTankEasterEgg = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "DynamicTankEasterEgg", false).getBoolean(true); Mekanism.voiceServerEnabled = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "VoiceServerEnabled", true).getBoolean(true); - Mekanism.forceBuildcraft = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ForceBuildcraftPower", false).getBoolean(false); Mekanism.cardboardSpawners = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "AllowSpawnerBoxPickup", true).getBoolean(true); Mekanism.obsidianTNTDelay = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ObsidianTNTDelay", 100).getInt(); Mekanism.obsidianTNTBlastRadius = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ObsidianTNTBlastRadius", 12).getInt(); @@ -208,11 +203,11 @@ public class CommonProxy Mekanism.TO_BC = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "MJToJoules", .04D).getDouble(.04D); Mekanism.FROM_H2 = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "HydrogenEnergyDensity", 2000D).getDouble(2000D); Mekanism.ENERGY_PER_REDSTONE = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnergyPerRedstone", 10000D).getDouble(10000D); - Mekanism.VOICE_PORT = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "VoicePort", 36123).getInt(); + Mekanism.VOICE_PORT = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "VoicePort", 36123, null, 1, 65535).getInt(); //If this is less than 1, upgrades make machines worse. If less than 0, I don't even know. - Mekanism.maxUpgradeMultiplier = Math.max(1, Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "UpgradeModifier", 10).getInt()); + Mekanism.maxUpgradeMultiplier = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "UpgradeModifier", 10, null, 1, Integer.MAX_VALUE).getInt(); - String s = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnergyType", "J").getString(); + String s = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnergyType", "J", null, new String[]{"J", "RF", "MJ", "EU"}).getString(); if(s != null) { @@ -266,7 +261,9 @@ public class CommonProxy Mekanism.seismicVibratorUsage = Mekanism.configuration.get("usage", "SeismicVibratorUsage", 50D).getDouble(50D); Mekanism.pressurizedReactionBaseUsage = Mekanism.configuration.get("usage", "PressurizedReactionBaseUsage", 5D).getDouble(5D); Mekanism.fluidicPlenisherUsage = Mekanism.configuration.get("usage", "FluidicPlenisherUsage", 100D).getDouble(100D); - Mekanism.configuration.save(); + + if(Mekanism.configuration.hasChanged()) + Mekanism.configuration.save(); } /** diff --git a/src/main/java/mekanism/common/Mekanism.java b/src/main/java/mekanism/common/Mekanism.java index dd8679c79..2c08dd57a 100644 --- a/src/main/java/mekanism/common/Mekanism.java +++ b/src/main/java/mekanism/common/Mekanism.java @@ -287,14 +287,11 @@ public class Mekanism public static boolean osmiumGenerationEnabled = true; public static boolean copperGenerationEnabled = true; public static boolean tinGenerationEnabled = true; - public static boolean disableBCBronzeCrafting = true; - public static boolean disableBCSteelCrafting = true; public static boolean updateNotifications = true; public static boolean controlCircuitOreDict = true; public static boolean logPackets = false; public static boolean dynamicTankEasterEgg = false; public static boolean voiceServerEnabled = true; - public static boolean forceBuildcraft = false; public static boolean cardboardSpawners = true; public static boolean machineEffects = true; public static int obsidianTNTBlastRadius = 12; @@ -1310,6 +1307,7 @@ public class Mekanism new ThreadGetData(); //Register to receive subscribed events + FMLCommonHandler.instance().bus().register(this); MinecraftForge.EVENT_BUS.register(this); //Set up VoiceServerManager @@ -1454,7 +1452,7 @@ public class Mekanism @SubscribeEvent public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) { - if(event.modID.equals("Mekanism") || event.modID.equals("MekanismGenerators") || event.modID.equals("MekanismTools")) + if(event.modID.equals("Mekanism")) { proxy.loadConfiguration(); proxy.onConfigSync(); diff --git a/src/main/java/mekanism/common/integration/MekanismHooks.java b/src/main/java/mekanism/common/integration/MekanismHooks.java index b96c16e73..cee94e95c 100644 --- a/src/main/java/mekanism/common/integration/MekanismHooks.java +++ b/src/main/java/mekanism/common/integration/MekanismHooks.java @@ -53,7 +53,6 @@ public final class MekanismHooks if(ModAPIManager.INSTANCE.hasAPI("CoFHAPI|energy")) RedstoneFluxLoaded = true; if(Loader.isModLoaded("IC2")) IC2Loaded = true; if(Loader.isModLoaded("Railcraft")) RailcraftLoaded = true; - if(Loader.isModLoaded("BasicComponents")) BasicComponentsLoaded = true; if(Loader.isModLoaded("ThermalExpansion")) TELoaded = true; if(Loader.isModLoaded("ComputerCraft")) CCLoaded = true; @@ -70,23 +69,6 @@ public final class MekanismHooks Mekanism.logger.info("Hooked into IC2 successfully."); } - if(BasicComponentsLoaded) - { - if(Mekanism.disableBCSteelCrafting) - { - MekanismUtils.removeRecipes(getBasicComponentsItem("itemSteelDust")); - MekanismUtils.removeRecipes(getBasicComponentsItem("itemSteelIngot")); - } - - if(Mekanism.disableBCBronzeCrafting) - { - MekanismUtils.removeRecipes(getBasicComponentsItem("itemBronzeDust")); - MekanismUtils.removeRecipes(getBasicComponentsItem("itemBronzeIngot")); - } - - Mekanism.logger.info("Hooked into BasicComponents successfully."); - } - if(BuildCraftPowerLoaded) { Mekanism.logger.info("Hooked into BuildCraft successfully."); @@ -197,28 +179,4 @@ public final class MekanismHooks return null; } } - - public ItemStack getBasicComponentsItem(String name) - { - try { - if(BasicComponents == null) BasicComponents = Class.forName("basiccomponents.common.BasicComponents"); - if(BasicComponents == null) BasicComponents = Class.forName("net.minecraft.src.basiccomponents.common.BasicComponents"); - Object ret = BasicComponents.getField(name).get(null); - - if(ret instanceof Item) - { - return new ItemStack((Item)ret); - } - else if(ret instanceof Block) - { - return new ItemStack((Block)ret); - } - else { - throw new Exception("not instanceof ItemStack"); - } - } catch(Exception e) { - Mekanism.logger.error("Unable to retrieve Basic Components item " + name + "."); - return null; - } - } } diff --git a/src/main/java/mekanism/common/network/PacketConfigSync.java b/src/main/java/mekanism/common/network/PacketConfigSync.java index 1516f93d1..645257fb6 100644 --- a/src/main/java/mekanism/common/network/PacketConfigSync.java +++ b/src/main/java/mekanism/common/network/PacketConfigSync.java @@ -27,14 +27,11 @@ public class PacketConfigSync implements IMessageHandler getConfigElements() { List list = new ArrayList(); - list.add(new DummyCategoryElement("Armor Balance", "mekanism.configgui.ctgy.armor", ArmorEntry.class)); - list.add(new DummyCategoryElement("Tools Balance", "mekanism.configgui.ctgy.tools", ToolsEntry.class)); + list.add(new DummyCategoryElement("General", "mekanism.configgui.ctgy.tools.general", GeneralEntry.class)); + list.add(new DummyCategoryElement("Armor Balance", "mekanism.configgui.ctgy.tools.armor", ArmorEntry.class)); + list.add(new DummyCategoryElement("Tools Balance", "mekanism.configgui.ctgy.tools.tools", ToolsEntry.class)); return list; } + public static class GeneralEntry extends CategoryEntry + { + public GeneralEntry(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement prop) + { + super(owningScreen, owningEntryList, prop); + } + + @Override + protected GuiScreen buildChildScreen() + { + return new GuiConfig(this.owningScreen, + new ConfigElement(Mekanism.configuration.getCategory("tools.general")).getChildElements(), + this.owningScreen.modID, Configuration.CATEGORY_GENERAL, this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart, + this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart, + GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); + } + } + public static class ArmorEntry extends CategoryEntry { public ArmorEntry(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement prop) @@ -44,7 +63,7 @@ public class GuiToolsConfig extends GuiConfig protected GuiScreen buildChildScreen() { return new GuiConfig(this.owningScreen, - new ConfigElement(Mekanism.configuration.getCategory("armor-balance")).getChildElements(), + new ConfigElement(Mekanism.configuration.getCategory("tools.armor-balance")).getChildElements(), this.owningScreen.modID, Configuration.CATEGORY_GENERAL, this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart, this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart, GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); @@ -62,7 +81,7 @@ public class GuiToolsConfig extends GuiConfig protected GuiScreen buildChildScreen() { return new GuiConfig(this.owningScreen, - new ConfigElement(Mekanism.configuration.getCategory("tool-balance")).getChildElements(), + new ConfigElement(Mekanism.configuration.getCategory("tools.tool-balance")).getChildElements(), this.owningScreen.modID, Configuration.CATEGORY_GENERAL, this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart, this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart, GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); diff --git a/src/main/java/mekanism/tools/common/MekanismTools.java b/src/main/java/mekanism/tools/common/MekanismTools.java index 474e91529..06e80815d 100644 --- a/src/main/java/mekanism/tools/common/MekanismTools.java +++ b/src/main/java/mekanism/tools/common/MekanismTools.java @@ -26,11 +26,14 @@ import net.minecraft.item.crafting.CraftingManager; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.event.entity.living.LivingSpawnEvent; +import cpw.mods.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent; +import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.registry.GameRegistry; @Mod(modid = "MekanismTools", name = "MekanismTools", version = "7.0.0", dependencies = "required-after:Mekanism", guiFactory = "mekanism.tools.client.gui.ToolsGuiFactory") @@ -147,7 +150,7 @@ public class MekanismTools implements IModule public static Item SteelBoots; //Tools Configuration - public static double armourSpawnRate; + public static double armorSpawnRate; @EventHandler public void init(FMLInitializationEvent event) @@ -157,7 +160,8 @@ public class MekanismTools implements IModule //Register this class to the event bus for special mob spawning (mobs with Mekanism armor/tools) MinecraftForge.EVENT_BUS.register(this); - + FMLCommonHandler.instance().bus().register(this); + //Load the proxy proxy.loadConfiguration(); @@ -384,161 +388,158 @@ public class MekanismTools implements IModule public void addItems() { - //Declarations - Mekanism.configuration.load(); - //Tools toolOBSIDIAN = EnumHelper.addToolMaterial("OBSIDIAN" - , Mekanism.configuration.get("tool-balance", "obsidian-harvestLevel", 3).getInt() - , Mekanism.configuration.get("tool-balance", "obsidian-maxUses", 2500).getInt() - , (float)Mekanism.configuration.get("tool-balance", "obsidian-efficiency", 20d).getDouble(0) - , Mekanism.configuration.get("tool-balance", "obsidian-damage", 10).getInt() - , Mekanism.configuration.get("tool-balance", "obsidian-enchantability", 100).getInt() + , Mekanism.configuration.get("tools.tool-balance.obsidian.regular", "harvestLevel", 3).getInt() + , Mekanism.configuration.get("tools.tool-balance.obsidian.regular", "maxUses", 2500).getInt() + , (float)Mekanism.configuration.get("tools.tool-balance.obsidian.regular", "efficiency", 20d).getDouble(0) + , Mekanism.configuration.get("tools.tool-balance.obsidian.regular", "damage", 10).getInt() + , Mekanism.configuration.get("tools.tool-balance.obsidian.regular", "enchantability", 100).getInt() ); toolOBSIDIAN2 = EnumHelper.addToolMaterial("OBSIDIAN2" - , Mekanism.configuration.get("tool-balance", "obsidian-paxel-harvestLevel", 3).getInt() - , Mekanism.configuration.get("tool-balance", "obsidian-paxel-maxUses", 3000).getInt() - , (float)Mekanism.configuration.get("tool-balance", "obsidian-paxel-efficiency", 25d).getDouble(0) - , Mekanism.configuration.get("tool-balance", "obsidian-paxel-damage", 10).getInt() - , Mekanism.configuration.get("tool-balance", "obsidian-paxel-enchantability", 100).getInt() + , Mekanism.configuration.get("tools.tool-balance.obsidian.paxel", "harvestLevel", 3).getInt() + , Mekanism.configuration.get("tools.tool-balance.obsidian.paxel", "maxUses", 3000).getInt() + , (float)Mekanism.configuration.get("tools.tool-balance.obsidian.paxel", "efficiency", 25d).getDouble(0) + , Mekanism.configuration.get("tools.tool-balance.obsidian.paxel", "damage", 10).getInt() + , Mekanism.configuration.get("tools.tool-balance.obsidian.paxel", "enchantability", 100).getInt() ); toolLAZULI = EnumHelper.addToolMaterial("LAZULI" - , Mekanism.configuration.get("tool-balance", "lazuli-harvestLevel", 2).getInt() - , Mekanism.configuration.get("tool-balance", "lazuli-maxUses", 200).getInt() - , (float)Mekanism.configuration.get("tool-balance", "lazuli-efficiency", 5d).getDouble(0) - , Mekanism.configuration.get("tool-balance", "lazuli-damage", 2).getInt() - , Mekanism.configuration.get("tool-balance", "lazuli-enchantability", 22).getInt() + , Mekanism.configuration.get("tools.tool-balance.lapis.regular", "harvestLevel", 2).getInt() + , Mekanism.configuration.get("tools.tool-balance.lapis.regular", "maxUses", 200).getInt() + , (float)Mekanism.configuration.get("tools.tool-balance.lapis.regular", "efficiency", 5d).getDouble(0) + , Mekanism.configuration.get("tools.tool-balance.lapis.regular", "damage", 2).getInt() + , Mekanism.configuration.get("tools.tool-balance.lapis.regular", "enchantability", 22).getInt() ); toolLAZULI2 = EnumHelper.addToolMaterial("LAZULI2" - , Mekanism.configuration.get("tool-balance", "lazuli-paxel-harvestLevel", 2).getInt() - , Mekanism.configuration.get("tool-balance", "lazuli-paxel-maxUses", 250).getInt() - , (float)Mekanism.configuration.get("tool-balance", "lazuli-paxel-efficiency", 6d).getDouble(0) - , Mekanism.configuration.get("tool-balance", "lazuli-paxel-damage", 4).getInt() - , Mekanism.configuration.get("tool-balance", "lazuli-paxel-enchantability", 50).getInt() + , Mekanism.configuration.get("tools.tool-balance.lapis.paxel", "harvestLevel", 2).getInt() + , Mekanism.configuration.get("tools.tool-balance.lapis.paxel", "maxUses", 250).getInt() + , (float)Mekanism.configuration.get("tools.tool-balance.lapis.paxel", "efficiency", 6d).getDouble(0) + , Mekanism.configuration.get("tools.tool-balance.lapis.paxel", "damage", 4).getInt() + , Mekanism.configuration.get("tools.tool-balance.lapis.paxel", "enchantability", 50).getInt() ); toolOSMIUM = EnumHelper.addToolMaterial("OSMIUM" - , Mekanism.configuration.get("tool-balance", "osmium-harvestLevel", 2).getInt() - , Mekanism.configuration.get("tool-balance", "osmium-maxUses", 500).getInt() - , (float)Mekanism.configuration.get("tool-balance", "osmium-efficiency", 10d).getDouble(0) - , Mekanism.configuration.get("tool-balance", "osmium-damage", 4).getInt() - , Mekanism.configuration.get("tool-balance", "osmium-enchantability", 30).getInt() + , Mekanism.configuration.get("tools.tool-balance.osmium.regular", "harvestLevel", 2).getInt() + , Mekanism.configuration.get("tools.tool-balance.osmium.regular", "maxUses", 500).getInt() + , (float)Mekanism.configuration.get("tools.tool-balance.osmium.regular", "efficiency", 10d).getDouble(0) + , Mekanism.configuration.get("tools.tool-balance.osmium.regular", "damage", 4).getInt() + , Mekanism.configuration.get("tools.tool-balance.osmium.regular", "enchantability", 30).getInt() ); toolOSMIUM2 = EnumHelper.addToolMaterial("OSMIUM2" - , Mekanism.configuration.get("tool-balance", "osmium-paxel-harvestLevel", 3).getInt() - , Mekanism.configuration.get("tool-balance", "osmium-paxel-maxUses", 700).getInt() - , (float)Mekanism.configuration.get("tool-balance", "osmium-paxel-efficiency", 12d).getDouble(0) - , Mekanism.configuration.get("tool-balance", "osmium-paxel-damage", 5).getInt() - , Mekanism.configuration.get("tool-balance", "osmium-paxel-enchantability", 40).getInt() + , Mekanism.configuration.get("tools.tool-balance.osmium.paxel", "harvestLevel", 3).getInt() + , Mekanism.configuration.get("tools.tool-balance.osmium.paxel", "maxUses", 700).getInt() + , (float)Mekanism.configuration.get("tools.tool-balance.osmium.paxel", "efficiency", 12d).getDouble(0) + , Mekanism.configuration.get("tools.tool-balance.osmium.paxel", "damage", 5).getInt() + , Mekanism.configuration.get("tools.tool-balance.osmium.paxel", "enchantability", 40).getInt() ); toolBRONZE = EnumHelper.addToolMaterial("BRONZE" - , Mekanism.configuration.get("tool-balance", "bronze-harvestLevel", 2).getInt() - , Mekanism.configuration.get("tool-balance", "bronze-maxUses", 800).getInt() - , (float)Mekanism.configuration.get("tool-balance", "bronze-efficiency", 14d).getDouble(0) - , Mekanism.configuration.get("tool-balance", "bronze-damage", 6).getInt() - , Mekanism.configuration.get("tool-balance", "bronze-enchantability", 100).getInt() + , Mekanism.configuration.get("tools.tool-balance.bronze.regular", "harvestLevel", 2).getInt() + , Mekanism.configuration.get("tools.tool-balance.bronze.regular", "maxUses", 800).getInt() + , (float)Mekanism.configuration.get("tools.tool-balance.bronze.regular", "efficiency", 14d).getDouble(0) + , Mekanism.configuration.get("tools.tool-balance.bronze.regular", "damage", 6).getInt() + , Mekanism.configuration.get("tools.tool-balance.bronze.regular", "enchantability", 100).getInt() ); toolBRONZE2 = EnumHelper.addToolMaterial("BRONZE2" - , Mekanism.configuration.get("tool-balance", "bronze-paxel-harvestLevel", 3).getInt() - , Mekanism.configuration.get("tool-balance", "bronze-paxel-maxUses", 1100).getInt() - , (float)Mekanism.configuration.get("tool-balance", "bronze-paxel-efficiency", 16d).getDouble(0) - , Mekanism.configuration.get("tool-balance", "bronze-paxel-damage", 10).getInt() - , Mekanism.configuration.get("tool-balance", "bronze-paxel-enchantability", 100).getInt() + , Mekanism.configuration.get("tools.tool-balance.bronze.paxel", "harvestLevel", 3).getInt() + , Mekanism.configuration.get("tools.tool-balance.bronze.paxel", "maxUses", 1100).getInt() + , (float)Mekanism.configuration.get("tools.tool-balance.bronze.paxel", "efficiency", 16d).getDouble(0) + , Mekanism.configuration.get("tools.tool-balance.bronze.paxel", "damage", 10).getInt() + , Mekanism.configuration.get("tools.tool-balance.bronze.paxel", "enchantability", 100).getInt() ); toolGLOWSTONE = EnumHelper.addToolMaterial("GLOWSTONE" - , Mekanism.configuration.get("tool-balance", "glowstone-harvestLevel", 2).getInt() - , Mekanism.configuration.get("tool-balance", "glowstone-maxUses", 300).getInt() - , (float)Mekanism.configuration.get("tool-balance", "glowstone-efficiency", 14d).getDouble(0) - , Mekanism.configuration.get("tool-balance", "glowstone-damage", 5).getInt() - , Mekanism.configuration.get("tool-balance", "glowstone-enchantability", 80).getInt() + , Mekanism.configuration.get("tools.tool-balance.glowstone.regular", "harvestLevel", 2).getInt() + , Mekanism.configuration.get("tools.tool-balance.glowstone.regular", "maxUses", 300).getInt() + , (float)Mekanism.configuration.get("tools.tool-balance.glowstone.regular", "efficiency", 14d).getDouble(0) + , Mekanism.configuration.get("tools.tool-balance.glowstone.regular", "damage", 5).getInt() + , Mekanism.configuration.get("tools.tool-balance.glowstone.regular", "enchantability", 80).getInt() ); toolGLOWSTONE2 = EnumHelper.addToolMaterial("GLOWSTONE2" - , Mekanism.configuration.get("tool-balance", "glowstone-paxel-harvestLevel", 2).getInt() - , Mekanism.configuration.get("tool-balance", "glowstone-paxel-maxUses", 450).getInt() - , (float)Mekanism.configuration.get("tool-balance", "glowstone-paxel-efficiency", 18d).getDouble(0) - , Mekanism.configuration.get("tool-balance", "glowstone-paxel-damage", 5).getInt() - , Mekanism.configuration.get("tool-balance", "glowstone-paxel-enchantability", 100).getInt() + , Mekanism.configuration.get("tools.tool-balance.glowstone.paxel", "harvestLevel", 2).getInt() + , Mekanism.configuration.get("tools.tool-balance.glowstone.paxel", "maxUses", 450).getInt() + , (float)Mekanism.configuration.get("tools.tool-balance.glowstone.paxel", "efficiency", 18d).getDouble(0) + , Mekanism.configuration.get("tools.tool-balance.glowstone.paxel", "damage", 5).getInt() + , Mekanism.configuration.get("tools.tool-balance.glowstone.paxel", "enchantability", 100).getInt() ); toolSTEEL = EnumHelper.addToolMaterial("STEEL" - , Mekanism.configuration.get("tool-balance", "steel-harvestLevel", 3).getInt() - , Mekanism.configuration.get("tool-balance", "steel-maxUses", 850).getInt() - , (float)Mekanism.configuration.get("tool-balance", "steel-efficiency", 14d).getDouble(0) - , Mekanism.configuration.get("tool-balance", "steel-damage", 4).getInt() - , Mekanism.configuration.get("tool-balance", "steel-enchantability", 100).getInt() + , Mekanism.configuration.get("tools.tool-balance.steel.regular", "harvestLevel", 3).getInt() + , Mekanism.configuration.get("tools.tool-balance.steel.regular", "maxUses", 850).getInt() + , (float)Mekanism.configuration.get("tools.tool-balance.steel.regular", "efficiency", 14d).getDouble(0) + , Mekanism.configuration.get("tools.tool-balance.steel.regular", "damage", 4).getInt() + , Mekanism.configuration.get("tools.tool-balance.steel.regular", "enchantability", 100).getInt() ); toolSTEEL2 = EnumHelper.addToolMaterial("STEEL2" - , Mekanism.configuration.get("tool-balance", "steel-paxel-harvestLevel", 3).getInt() - , Mekanism.configuration.get("tool-balance", "steel-paxel-maxUses", 1250).getInt() - , (float)Mekanism.configuration.get("tool-balance", "steel-paxel-efficiency", 18d).getDouble(0) - , Mekanism.configuration.get("tool-balance", "steel-paxel-damage", 8).getInt() - , Mekanism.configuration.get("tool-balance", "steel-paxel-enchantability", 100).getInt() + , Mekanism.configuration.get("tools.tool-balance.steel.paxel", "harvestLevel", 3).getInt() + , Mekanism.configuration.get("tools.tool-balance.steel.paxel", "maxUses", 1250).getInt() + , (float)Mekanism.configuration.get("tools.tool-balance.steel.paxel", "efficiency", 18d).getDouble(0) + , Mekanism.configuration.get("tools.tool-balance.steel.paxel", "damage", 8).getInt() + , Mekanism.configuration.get("tools.tool-balance.steel.paxel", "enchantability", 100).getInt() ); //Armors armorOBSIDIAN = EnumHelper.addArmorMaterial("OBSIDIAN" - , Mekanism.configuration.get("armor-balance", "obsidian-durability", 50).getInt() + , Mekanism.configuration.get("tools.armor-balance.obsidian", "durability", 50).getInt() , new int[] { - Mekanism.configuration.get("armor-balance", "obsidian-reduction-amount-head", 5).getInt() - , Mekanism.configuration.get("armor-balance", "obsidian-reduction-amount-chest", 12).getInt() - , Mekanism.configuration.get("armor-balance", "obsidian-reduction-amount-legs", 8).getInt() - , Mekanism.configuration.get("armor-balance", "obsidian-reduction-amount-feet", 5).getInt() + Mekanism.configuration.get("tools.armor-balance.obsidian.protection", "head", 5).getInt() + , Mekanism.configuration.get("tools.armor-balance.obsidian.protection", "chest", 12).getInt() + , Mekanism.configuration.get("tools.armor-balance.obsidian.protection", "legs", 8).getInt() + , Mekanism.configuration.get("tools.armor-balance.obsidian.protection", "feet", 5).getInt() } - , Mekanism.configuration.get("armor-balance", "obsidian-enchantability", 50).getInt() + , Mekanism.configuration.get("tools.armor-balance.obsidian", "enchantability", 50).getInt() ); armorLAZULI = EnumHelper.addArmorMaterial("LAZULI" - , Mekanism.configuration.get("armor-balance", "lazuli-durability", 13).getInt() + , Mekanism.configuration.get("tools.armor-balance.lapis", "durability", 13).getInt() , new int[] { - Mekanism.configuration.get("armor-balance", "lazuli-reduction-amount-head", 2).getInt() - , Mekanism.configuration.get("armor-balance", "lazuli-reduction-amount-chest", 5).getInt() - , Mekanism.configuration.get("armor-balance", "lazuli-reduction-amount-legs", 6).getInt() - , Mekanism.configuration.get("armor-balance", "lazuli-reduction-amount-feet", 2).getInt() + Mekanism.configuration.get("tools.armor-balance.lapis.protection", "head", 2).getInt() + , Mekanism.configuration.get("tools.armor-balance.lapis.protection", "chest", 5).getInt() + , Mekanism.configuration.get("tools.armor-balance.lapis.protection", "legs", 6).getInt() + , Mekanism.configuration.get("tools.armor-balance.lapis.protection", "feet", 2).getInt() } - , Mekanism.configuration.get("armor-balance", "lazuli-enchantability", 50).getInt() + , Mekanism.configuration.get("tools.armor-balance.lapis", "enchantability", 50).getInt() ); armorOSMIUM = EnumHelper.addArmorMaterial("OSMIUM" - , Mekanism.configuration.get("armor-balance", "osmium-durability", 30).getInt() + , Mekanism.configuration.get("tools.armor-balance.osmium", "durability", 30).getInt() , new int[] { - Mekanism.configuration.get("armor-balance", "osmium-reduction-amount-head", 3).getInt() - , Mekanism.configuration.get("armor-balance", "osmium-reduction-amount-chest", 5).getInt() - , Mekanism.configuration.get("armor-balance", "osmium-reduction-amount-legs", 6).getInt() - , Mekanism.configuration.get("armor-balance", "osmium-reduction-amount-feet", 3).getInt() + Mekanism.configuration.get("tools.armor-balance.osmium.protection", "head", 3).getInt() + , Mekanism.configuration.get("tools.armor-balance.osmium.protection", "chest", 5).getInt() + , Mekanism.configuration.get("tools.armor-balance.osmium.protection", "legs", 6).getInt() + , Mekanism.configuration.get("tools.armor-balance.osmium.protection", "feet", 3).getInt() } - , Mekanism.configuration.get("armor-balance", "osmium-enchantability", 50).getInt() + , Mekanism.configuration.get("tools.armor-balance.osmium", "enchantability", 50).getInt() ); armorBRONZE = EnumHelper.addArmorMaterial("BRONZE" - , Mekanism.configuration.get("armor-balance", "bronze-durability", 35).getInt() + , Mekanism.configuration.get("tools.armor-balance.bronze", "durability", 35).getInt() , new int[] { - Mekanism.configuration.get("armor-balance", "bronze-reduction-amount-head", 3).getInt() - , Mekanism.configuration.get("armor-balance", "bronze-reduction-amount-chest", 6).getInt() - , Mekanism.configuration.get("armor-balance", "bronze-reduction-amount-legs", 5).getInt() - , Mekanism.configuration.get("armor-balance", "bronze-reduction-amount-feet", 2).getInt() + Mekanism.configuration.get("tools.armor-balance.bronze.protection", "head", 3).getInt() + , Mekanism.configuration.get("tools.armor-balance.bronze.protection", "chest", 6).getInt() + , Mekanism.configuration.get("tools.armor-balance.bronze.protection", "legs", 5).getInt() + , Mekanism.configuration.get("tools.armor-balance.bronze.protection", "feet", 2).getInt() } - , Mekanism.configuration.get("armor-balance", "bronze-enchantability", 50).getInt() + , Mekanism.configuration.get("tools.armor-balance.bronze", "enchantability", 50).getInt() ); armorGLOWSTONE = EnumHelper.addArmorMaterial("GLOWSTONE" - , Mekanism.configuration.get("armor-balance", "glowstone-durability", 18).getInt() + , Mekanism.configuration.get("tools.armor-balance.glowstone", "durability", 18).getInt() , new int[] { - Mekanism.configuration.get("armor-balance", "glowstone-reduction-amount-head", 3).getInt() - , Mekanism.configuration.get("armor-balance", "glowstone-reduction-amount-chest", 7).getInt() - , Mekanism.configuration.get("armor-balance", "glowstone-reduction-amount-legs", 6).getInt() - , Mekanism.configuration.get("armor-balance", "glowstone-reduction-amount-feet", 3).getInt() + Mekanism.configuration.get("tools.armor-balance.glowstone.protection", "head", 3).getInt() + , Mekanism.configuration.get("tools.armor-balance.glowstone.protection", "chest", 7).getInt() + , Mekanism.configuration.get("tools.armor-balance.glowstone.protection", "legs", 6).getInt() + , Mekanism.configuration.get("tools.armor-balance.glowstone.protection", "feet", 3).getInt() } - , Mekanism.configuration.get("armor-balance", "glowstone-enchantability", 50).getInt() + , Mekanism.configuration.get("tools.armor-balance.glowstone", "enchantability", 50).getInt() ); armorSTEEL = EnumHelper.addArmorMaterial("STEEL" - , Mekanism.configuration.get("armor-balance", "steel-durability", 40).getInt() + , Mekanism.configuration.get("tools.armor-balance.steel", "durability", 40).getInt() , new int[] { - Mekanism.configuration.get("armor-balance", "steel-reduction-amount-head", 3).getInt() - , Mekanism.configuration.get("armor-balance", "steel-reduction-amount-chest", 7).getInt() - , Mekanism.configuration.get("armor-balance", "steel-reduction-amount-legs", 6).getInt() - , Mekanism.configuration.get("armor-balance", "steel-reduction-amount-feet", 3).getInt() + Mekanism.configuration.get("tools.armor-balance.steel.protection", "head", 3).getInt() + , Mekanism.configuration.get("tools.armor-balance.steel.protection", "chest", 7).getInt() + , Mekanism.configuration.get("tools.armor-balance.steel.protection", "legs", 6).getInt() + , Mekanism.configuration.get("tools.armor-balance.steel.protection", "feet", 3).getInt() } - , Mekanism.configuration.get("armor-balance", "steel-enchantability", 50).getInt() + , Mekanism.configuration.get("tools.armor-balance.steel", "enchantability", 50).getInt() ); //Bronze @@ -739,13 +740,13 @@ public class MekanismTools implements IModule GameRegistry.registerItem(SteelBoots, "SteelBoots"); } - + @SubscribeEvent public void onLivingSpecialSpawn(LivingSpawnEvent event) { double chance = event.world.rand.nextDouble(); int armorType = event.world.rand.nextInt(4); - if(chance < armourSpawnRate) + if(chance < armorSpawnRate) { if(event.entityLiving instanceof EntityZombie || event.entityLiving instanceof EntitySkeleton) { @@ -814,12 +815,21 @@ public class MekanismTools implements IModule @Override public void writeConfig(ByteBuf dataStream) throws IOException { - dataStream.writeDouble(armourSpawnRate); + dataStream.writeDouble(armorSpawnRate); } @Override public void readConfig(ByteBuf dataStream) throws IOException { - armourSpawnRate = dataStream.readDouble(); + armorSpawnRate = dataStream.readDouble(); + } + + @SubscribeEvent + public void onConfigChanged(OnConfigChangedEvent event) + { + if(event.modID.equals("MekanismTools")) + { + proxy.loadConfiguration(); + } } } diff --git a/src/main/java/mekanism/tools/common/ToolsCommonProxy.java b/src/main/java/mekanism/tools/common/ToolsCommonProxy.java index d0723856e..e9e100e2e 100644 --- a/src/main/java/mekanism/tools/common/ToolsCommonProxy.java +++ b/src/main/java/mekanism/tools/common/ToolsCommonProxy.java @@ -1,7 +1,6 @@ package mekanism.tools.common; import mekanism.common.Mekanism; -import net.minecraftforge.common.config.Configuration; public class ToolsCommonProxy { @@ -10,8 +9,9 @@ public class ToolsCommonProxy */ public void loadConfiguration() { - Mekanism.configuration.load(); - MekanismTools.armourSpawnRate = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "mob-armor-spawn-rate", 0.03).getDouble(0.03); - Mekanism.configuration.save(); + MekanismTools.armorSpawnRate = Mekanism.configuration.get("tools.general", "MobArmorSpawnRate", 0.03, null, 0.00, 1.00).getDouble(0.03); + + if(Mekanism.configuration.hasChanged()) + Mekanism.configuration.save(); } }