From 7ecd97ad8fed921be3c31624554a8d45f1ca8b7e Mon Sep 17 00:00:00 2001 From: mDiyo Date: Tue, 1 Jul 2014 23:23:15 -0800 Subject: [PATCH] Update the way modules are loaded --- src/main/java/tconstruct/TConstruct.java | 23 ++++--- .../java/tconstruct/armor/TinkerArmor.java | 5 +- .../tconstruct/mechworks/TinkerMechworks.java | 6 +- .../tconstruct/smeltery/TinkerSmeltery.java | 5 +- .../java/tconstruct/tools/TinkerTools.java | 5 +- .../tconstruct/util/config/PHConstruct.java | 64 +++++++++++++++---- .../java/tconstruct/world/TinkerWorld.java | 5 +- 7 files changed, 77 insertions(+), 36 deletions(-) diff --git a/src/main/java/tconstruct/TConstruct.java b/src/main/java/tconstruct/TConstruct.java index ee9e6eda..320ed1ef 100644 --- a/src/main/java/tconstruct/TConstruct.java +++ b/src/main/java/tconstruct/TConstruct.java @@ -80,7 +80,7 @@ public class TConstruct public static TProxyCommon proxy; /* Loads modules in a way that doesn't clutter the @Mod list */ - private PulseManager pulsar = new PulseManager(modID, "TinkersModules"); //Scheduled to change shortly. + private PulseManager pulsar = new PulseManager(modID); public TConstruct() { @@ -102,13 +102,20 @@ public class TConstruct { PHConstruct.initProps(event.getModConfigurationDirectory()); - pulsar.registerPulse(new TinkerWorld()); - pulsar.registerPulse(new TinkerTools()); - pulsar.registerPulse(new TinkerSmeltery()); - pulsar.registerPulse(new TinkerMechworks()); - pulsar.registerPulse(new TinkerArmor()); - /*pulsar.registerPulse(new TinkerPrayers()); - pulsar.registerPulse(new TinkerCropify());*/ + if (PHConstruct.worldModule) + pulsar.registerPulse(new TinkerWorld()); + if (PHConstruct.toolModule) + pulsar.registerPulse(new TinkerTools()); + if (PHConstruct.smelteryModule) + pulsar.registerPulse(new TinkerSmeltery()); + if (PHConstruct.mechworksModule) + pulsar.registerPulse(new TinkerMechworks()); + if (PHConstruct.armorModule) + pulsar.registerPulse(new TinkerArmor()); + /*if (PHConstruct.prayerModule) + pulsar.registerPulse(new TinkerPrayers()); + if (PHConstruct.cropifyModule) + pulsar.registerPulse(new TinkerCropify());*/ TConstructRegistry.materialTab = new TabTools("TConstructMaterials"); TConstructRegistry.toolTab = new TabTools("TConstructTools"); diff --git a/src/main/java/tconstruct/armor/TinkerArmor.java b/src/main/java/tconstruct/armor/TinkerArmor.java index 0febb7b7..0d16b28c 100644 --- a/src/main/java/tconstruct/armor/TinkerArmor.java +++ b/src/main/java/tconstruct/armor/TinkerArmor.java @@ -1,6 +1,5 @@ package tconstruct.armor; -import mantle.pulsar.pulse.IPulse; import mantle.pulsar.pulse.Pulse; import mantle.pulsar.pulse.PulseProxy; import net.minecraft.block.Block; @@ -42,9 +41,9 @@ import cpw.mods.fml.common.registry.GameRegistry.ObjectHolder; @ObjectHolder(TConstruct.modID) @Pulse(id = "Tinkers' Armor", description = "Modifyable armors, such as the traveller's gear.") -public class TinkerArmor implements IPulse //TODO: Remove IPulse implementation, keep annotation +public class TinkerArmor { - @PulseProxy(client = "tconstruct.armor.ArmorProxyClient", server = "tconstruct.armor.ArmorProxyCommon") + @PulseProxy(clientSide = "tconstruct.armor.ArmorProxyClient", serverSide = "tconstruct.armor.ArmorProxyCommon") public static ArmorProxyCommon proxy; public static Item diamondApple; diff --git a/src/main/java/tconstruct/mechworks/TinkerMechworks.java b/src/main/java/tconstruct/mechworks/TinkerMechworks.java index d660b0aa..23cdd31d 100644 --- a/src/main/java/tconstruct/mechworks/TinkerMechworks.java +++ b/src/main/java/tconstruct/mechworks/TinkerMechworks.java @@ -1,6 +1,5 @@ package tconstruct.mechworks; -import mantle.pulsar.pulse.IPulse; import mantle.pulsar.pulse.Pulse; import mantle.pulsar.pulse.PulseProxy; import net.minecraft.block.Block; @@ -10,7 +9,6 @@ import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.ShapedOreRecipe; import tconstruct.TConstruct; -import tconstruct.armor.ArmorProxyCommon; import tconstruct.mechworks.blocks.BlockLandmine; import tconstruct.mechworks.entity.item.EntityLandmineFirework; import tconstruct.mechworks.entity.item.ExplosivePrimed; @@ -29,9 +27,9 @@ import cpw.mods.fml.common.registry.GameRegistry.ObjectHolder; @ObjectHolder(TConstruct.modID) //TODO handle migration of all items/blocks that were owned by the previously seperate mod @Pulse(id = "Tinkers' Mechworks", description = "Mechanical machinations and steampunk inspired shenanigans.") -public class TinkerMechworks implements IPulse //TODO: Remove IPulse implementation, keep annotation +public class TinkerMechworks { - @PulseProxy(client = "tconstruct.mechworks.MechworksProxyClient", server = "tconstruct.mechworks.MechworksProxyCommon") + @PulseProxy(clientSide = "tconstruct.mechworks.MechworksProxyClient", serverSide = "tconstruct.mechworks.MechworksProxyCommon") public static MechworksProxyCommon proxy; public TinkerMechworks() { diff --git a/src/main/java/tconstruct/smeltery/TinkerSmeltery.java b/src/main/java/tconstruct/smeltery/TinkerSmeltery.java index 88a14e7d..54667912 100644 --- a/src/main/java/tconstruct/smeltery/TinkerSmeltery.java +++ b/src/main/java/tconstruct/smeltery/TinkerSmeltery.java @@ -8,7 +8,6 @@ import java.util.Map; import mantle.blocks.BlockUtils; import mantle.blocks.abstracts.MultiServantLogic; -import mantle.pulsar.pulse.IPulse; import mantle.pulsar.pulse.Pulse; import mantle.pulsar.pulse.PulseProxy; import net.minecraft.block.Block; @@ -86,9 +85,9 @@ import cpw.mods.fml.common.registry.GameRegistry.ObjectHolder; @ObjectHolder(TConstruct.modID) @Pulse(id = "Tinker's Smeltery", description = "Liquid metals, casting, and the multiblock structure.") -public class TinkerSmeltery implements IPulse //TODO: Remove IPulse implementation, keep annotation +public class TinkerSmeltery { - @PulseProxy(client = "tconstruct.smeltery.SmelteryProxyClient", server = "tconstruct.smeltery.SmelteryProxyCommon") + @PulseProxy(clientSide = "tconstruct.smeltery.SmelteryProxyClient", serverSide = "tconstruct.smeltery.SmelteryProxyCommon") public static SmelteryProxyCommon proxy; public static Item metalPattern; diff --git a/src/main/java/tconstruct/tools/TinkerTools.java b/src/main/java/tconstruct/tools/TinkerTools.java index 30d23c41..e86c6d3a 100644 --- a/src/main/java/tconstruct/tools/TinkerTools.java +++ b/src/main/java/tconstruct/tools/TinkerTools.java @@ -1,7 +1,6 @@ package tconstruct.tools; import mantle.items.abstracts.CraftingItem; -import mantle.pulsar.pulse.IPulse; import mantle.pulsar.pulse.Pulse; import mantle.pulsar.pulse.PulseProxy; import mantle.utils.RecipeRemover; @@ -107,10 +106,10 @@ import cpw.mods.fml.common.registry.GameRegistry.ObjectHolder; @ObjectHolder(TConstruct.modID) @Pulse(id = "Tinker's Tools", description = "The main core of the mod! All of the tools, the tables, and the patterns are here.") -public class TinkerTools implements IPulse //TODO: Remove IPulse implementation, keep annotation +public class TinkerTools { /* Proxies for sides, used for graphics processing */ - @PulseProxy(client = "tconstruct.tools.ToolProxyClient", server = "tconstruct.tools.ToolProxyCommon") + @PulseProxy(clientSide = "tconstruct.tools.ToolProxyClient", serverSide = "tconstruct.tools.ToolProxyCommon") public static ToolProxyCommon proxy; // Crafting blocks diff --git a/src/main/java/tconstruct/util/config/PHConstruct.java b/src/main/java/tconstruct/util/config/PHConstruct.java index 7eb7f619..344a63ae 100644 --- a/src/main/java/tconstruct/util/config/PHConstruct.java +++ b/src/main/java/tconstruct/util/config/PHConstruct.java @@ -15,12 +15,48 @@ public class PHConstruct public static void initProps (File location) { - File currentConfig = new File(location + "/TConstruct.cfg"); - File legacyConfig = new File(location + "/TinkersWorkshop.txt"); + /* Before we do anything, let's set up which modules can and cannot load. */ + File modules = new File(location + "/TinkersModules.cfg"); + + /* Some basic debugging will go a long way */ try { - if(!currentConfig.exists() && legacyConfig.exists()) - legacyConfig.renameTo(currentConfig); + modules.createNewFile(); + } + catch (IOException e) + { + TConstruct.logger.warn("Could not create module configuration file for TConstruct. Reason:"); + TConstruct.logger.warn(e.getLocalizedMessage()); + } + Configuration config = new Configuration(modules); + config.load(); + worldModule = config.get("Modules: Disabling these will disable a chunk of the mod", "World", true, "Ores, slime islands, essence berries, and the like.").getBoolean(true); + toolModule = config.get("Modules: Disabling these will disable a chunk of the mod", "Tools", true, "The main core of the mod! All of the tools, the tables, and the patterns are here.") + .getBoolean(true); + smelteryModule = config.get("Modules: Disabling these will disable a chunk of the mod", "Smeltery", true, "Liquid metals, casting, and the multiblock structure.").getBoolean(true); + mechworksModule = config.get("Modules: Disabling these will disable a chunk of the mod", "Smeltery", true, "Mechanical machinations and steampunk inspired shenanigans.").getBoolean(true); + armorModule = config.get("Modules: Disabling these will disable a chunk of the mod", "Armor", true, "Modifyable armors, such as the traveller's gear.").getBoolean(true); + prayerModule = config.get("Modules: Disabling these will disable a chunk of the mod", "Prayers", true, "Area of effect and time delayed status changes. Scrolltastic!").getBoolean(true); + cropifyModule = config.get("Modules: Disabling these will disable a chunk of the mod", "Cropify", true, "Tinkering with the world never felt this bushy.").getBoolean(true); + config.save(); + + /* Here we will set up the config file for the mod + * First: Create a folder inside the config folder + * Make sure to read any old configs file if they exist + * Second: Create the actual config file + */ + File mainFile = new File(location + "/TinkersConstruct.cfg"); + File legacyFile16 = new File(location + "/TinkersWorkshop.txt"); + File legacyFile17 = new File(location + "/TConstruct.cfg"); + try + { + if (!mainFile.exists()) + { + if (legacyFile16.exists()) + legacyFile16.renameTo(mainFile); + if (legacyFile17.exists()) + legacyFile17.renameTo(mainFile); + } } catch (Exception e) { @@ -28,10 +64,8 @@ public class PHConstruct TConstruct.logger.warn(e.getLocalizedMessage()); } - Configuration config = new Configuration(currentConfig); - cfglocation = location; - /* Load the configuration file */ - config.load(); + config = new Configuration(mainFile); + //config.load(); /* Load happens in the constructor */ superfunWorld = config.get("Superfun", "All the world is Superfun", false).getBoolean(false); TinkerTools.supressMissingToolLogs = config.get("Logging", "Disable tool build messages", false).getBoolean(false); @@ -66,7 +100,6 @@ public class PHConstruct ingotsManyullynAlloy = config.get("Smeltery Output Modification", "Manyullyn ingot return", 1, "Number of ingots returned from smelting Manyullyn in the smeltery").getDouble(1); ingotsPigironAlloy = config.get("Smeltery Output Modification", "Pig Iron ingot return", 1, "Number of ingots returned from smelting Pig Iron in the smeltery").getDouble(1); - exoCraftingEnabled = config.get("Equipables", "Exo-Armor-Craftable", true).getBoolean(true); capesEnabled = config.get("Superfun", "Enable-TCon-Capes", true).getBoolean(true); boolean ic2 = true; @@ -179,7 +212,7 @@ public class PHConstruct meltableHorses = config.get("Experimental", "Allow horses to be melted down for glue", true).getBoolean(true); /* Save the configuration file only if it has changed */ - if(config.hasChanged()) + if (config.hasChanged()) config.save(); File gt = new File(location + "/GregTech"); @@ -192,7 +225,15 @@ public class PHConstruct } } - public static boolean exoCraftingEnabled; + //Modules + public static boolean worldModule; + public static boolean toolModule; + public static boolean smelteryModule; + public static boolean mechworksModule; + public static boolean armorModule; + public static boolean prayerModule; + public static boolean cropifyModule; + public static boolean capesEnabled; // Ore values @@ -320,7 +361,6 @@ public class PHConstruct // Looks public static int connectedTexturesMode; - public static File cfglocation; // dimensionblacklist public static boolean slimeIslGenDim0Only; diff --git a/src/main/java/tconstruct/world/TinkerWorld.java b/src/main/java/tconstruct/world/TinkerWorld.java index a78dadaa..8fcfb3d9 100644 --- a/src/main/java/tconstruct/world/TinkerWorld.java +++ b/src/main/java/tconstruct/world/TinkerWorld.java @@ -1,6 +1,5 @@ package tconstruct.world; -import mantle.pulsar.pulse.IPulse; import mantle.pulsar.pulse.Pulse; import mantle.pulsar.pulse.PulseProxy; import mantle.utils.RecipeRemover; @@ -91,11 +90,11 @@ import cpw.mods.fml.common.registry.GameRegistry.ObjectHolder; @ObjectHolder(TConstruct.modID) @Pulse(id = "Tinker's World", description = "Ores, slime islands, essence berries, and the like.") -public class TinkerWorld implements IPulse //TODO: Remove IPulse implementation, keep annotation +public class TinkerWorld { @Instance("TinkerWorld") public static TinkerWorld instance; - @PulseProxy(client = "tconstruct.world.TinkerWorldProxyClient", server = "tconstruct.world.TinkerWorldProxyCommon") + @PulseProxy(clientSide = "tconstruct.world.TinkerWorldProxyClient", serverSide = "tconstruct.world.TinkerWorldProxyCommon") public static TinkerWorldProxyCommon proxy; public static Item strangeFood;