diff --git a/build.gradle b/build.gradle index 27aa859..beb0063 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ buildscript { apply plugin: 'forge' -version = "0.7.5" +version = "0.8.2" group= "modtweaker" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "ModTweaker 2" diff --git a/libs/MekanismAll-1.7.10-7.1.2.homebaked-dev.jar b/libs/MekanismAll-1.7.10-7.1.2.homebaked-dev.jar deleted file mode 100644 index 567d17c..0000000 Binary files a/libs/MekanismAll-1.7.10-7.1.2.homebaked-dev.jar and /dev/null differ diff --git a/src/main/java/modtweaker2/Commands.java b/src/main/java/modtweaker2/Commands.java index 1321121..0d64b67 100644 --- a/src/main/java/modtweaker2/Commands.java +++ b/src/main/java/modtweaker2/Commands.java @@ -21,42 +21,45 @@ import modtweaker2.utils.TweakerPlugin; public class Commands { public static void registerCommands() { - MineTweakerAPI.server.addMineTweakerCommand("tooltips", new String[] { "/minetweaker tooltips", " Adds tooltips to all items ingame with their mt script name, press ctrl on an item to print to the log" }, new ICommandFunction() { - @Override - public void execute(String[] arguments, IPlayer player) { - ClientEvents.active = !ClientEvents.active; + if (MineTweakerAPI.server != null) { + + MineTweakerAPI.server.addMineTweakerCommand("tooltips", new String[] { "/minetweaker tooltips", " Adds tooltips to all items ingame with their mt script name, press ctrl on an item to print to the log" }, new ICommandFunction() { + @Override + public void execute(String[] arguments, IPlayer player) { + ClientEvents.active = !ClientEvents.active; + } + }); + + MineTweakerAPI.server.addMineTweakerCommand("entities", new String[] { "/minetweaker entities", " Outputs a list of entities class mapping keys and the entity IDs" }, new EntityMappingLogger()); + + if (TweakerPlugin.isLoaded("Mekanism")) { + MineTweakerAPI.server.addMineTweakerCommand("gases", new String[] { "/minetweaker gases", " Outputs a list of all gas names in the game to the minetweaker log" }, new GasLogger()); } - }); - MineTweakerAPI.server.addMineTweakerCommand("entities", new String[] { "/minetweaker entities", " Outputs a list of entities class mapping keys and the entity IDs" }, new EntityMappingLogger()); + if (TweakerPlugin.isLoaded("Thaumcraft")) { + MineTweakerAPI.server.addMineTweakerCommand("research", new String[] { "/minetweaker research", "/minetweaker research [CATEGORY]", " Outputs a list of all category names in the game to the minetweaker log," + " or outputs a list of all research keys in a category to the log." }, new ResearchLogger()); + MineTweakerAPI.server.addMineTweakerCommand("aspectList", new String[] { "/minetweaker aspectList", " Outputs a list of all aspects registered to entities and items" }, new AspectLogger()); + } - if (TweakerPlugin.isLoaded("Mekanism")) { - MineTweakerAPI.server.addMineTweakerCommand("gases", new String[] { "/minetweaker gases", " Outputs a list of all gas names in the game to the minetweaker log" }, new GasLogger()); - } + if (TweakerPlugin.isLoaded("TConstruct")) { + MineTweakerAPI.server.addMineTweakerCommand("materials", new String[] { "/minetweaker materials", " Outputs a list of all Tinker's Construct material names in the game to the minetweaker log" }, new MaterialLogger()); + } - if (TweakerPlugin.isLoaded("Thaumcraft")) { - MineTweakerAPI.server.addMineTweakerCommand("research", new String[] { "/minetweaker research", "/minetweaker research [CATEGORY]", " Outputs a list of all category names in the game to the minetweaker log," + " or outputs a list of all research keys in a category to the log." }, new ResearchLogger()); - MineTweakerAPI.server.addMineTweakerCommand("aspectList", new String[] { "/minetweaker aspectList", " Outputs a list of all aspects registered to entities and items" }, new AspectLogger()); - } + if (TweakerPlugin.isLoaded("Botania")) { + MineTweakerAPI.server.addMineTweakerCommand("lexiconCategories", new String[] { "/minetweaker lexiconCategories", " Outputs a list of lexicon categories" }, new LexiconCategoryLogger()); + MineTweakerAPI.server.addMineTweakerCommand("lexiconPages", new String[] { "/minetweaker lexiconPages", "/minetweaker lexiconPages [ENTRY]", " Outputs a list of lexicon pages for the entry" }, new LexiconPageLogger()); + MineTweakerAPI.server.addMineTweakerCommand("botaniaBrews", new String[] { "/minetweaker botaniaBrews", " Outputs a list of keys for botania brews" }, new BotaniaBrewLogger()); + MineTweakerAPI.server.addMineTweakerCommand("lexiconKnowledgeTypes", new String[] { "/minetweaker lexiconKnowledgeTypes", " Outputs a list of keys for lexicon knowledge types" }, new LexiconKnowledgeTypesLogger()); + MineTweakerAPI.server.addMineTweakerCommand("botaniaOrchid", new String[] { "/minetweaker botaniaOrechid", " Outputs a list of keys for botania orechid weights" }, new BotaniaOrechidLogger()); + } - if (TweakerPlugin.isLoaded("TConstruct")) { - MineTweakerAPI.server.addMineTweakerCommand("materials", new String[] { "/minetweaker materials", " Outputs a list of all Tinker's Construct material names in the game to the minetweaker log" }, new MaterialLogger()); - } - - if (TweakerPlugin.isLoaded("Botania")) { - MineTweakerAPI.server.addMineTweakerCommand("lexiconCategories", new String[] { "/minetweaker lexiconCategories", " Outputs a list of lexicon categories" }, new LexiconCategoryLogger()); - MineTweakerAPI.server.addMineTweakerCommand("lexiconPages", new String[] { "/minetweaker lexiconPages", "/minetweaker lexiconPages [ENTRY]", " Outputs a list of lexicon pages for the entry" }, new LexiconPageLogger()); - MineTweakerAPI.server.addMineTweakerCommand("botaniaBrews", new String[] { "/minetweaker botaniaBrews", " Outputs a list of keys for botania brews" }, new BotaniaBrewLogger()); - MineTweakerAPI.server.addMineTweakerCommand("lexiconKnowledgeTypes", new String[] { "/minetweaker lexiconKnowledgeTypes", " Outputs a list of keys for lexicon knowledge types" }, new LexiconKnowledgeTypesLogger()); - MineTweakerAPI.server.addMineTweakerCommand("botaniaOrchid", new String[] { "/minetweaker botaniaOrechid", " Outputs a list of keys for botania orechid weights" }, new BotaniaOrechidLogger()); - } - - if (TweakerPlugin.isLoaded("chisel")) { - MineTweakerAPI.server.addMineTweakerCommand("chiselGroups", new String[] { "/minetweaker chiselGroups", " Outputs a list of chisel groups" }, new ChiselGroupLogger()); - MineTweakerAPI.server.addMineTweakerCommand("chiselVariations", new String[] { "/minetweaker chiselVariations", "/minetweaker chiselVariations [GROUP]", " Outputs a list of chisel variations" }, new ChiselVariationLogger()); - } - if (TweakerPlugin.isLoaded("aura")) { - MineTweakerAPI.server.addMineTweakerCommand("auras", new String[] { "/minetweaker auras", "Outputs a list of Aura Types" }, new AuraLogger()); + if (TweakerPlugin.isLoaded("chisel")) { + MineTweakerAPI.server.addMineTweakerCommand("chiselGroups", new String[] { "/minetweaker chiselGroups", " Outputs a list of chisel groups" }, new ChiselGroupLogger()); + MineTweakerAPI.server.addMineTweakerCommand("chiselVariations", new String[] { "/minetweaker chiselVariations", "/minetweaker chiselVariations [GROUP]", " Outputs a list of chisel variations" }, new ChiselVariationLogger()); + } + if (TweakerPlugin.isLoaded("aura")) { + MineTweakerAPI.server.addMineTweakerCommand("auras", new String[] { "/minetweaker auras", "Outputs a list of Aura Types" }, new AuraLogger()); + } } } diff --git a/src/main/java/modtweaker2/ModProps.java b/src/main/java/modtweaker2/ModProps.java index 77c01d3..1cf9041 100644 --- a/src/main/java/modtweaker2/ModProps.java +++ b/src/main/java/modtweaker2/ModProps.java @@ -4,6 +4,6 @@ public class ModProps { public static final String NAME = "Mod Tweaker 2", name = NAME; public static final String MODID = "modtweaker2", modid = MODID; - public static final String VERSION = "0.7", version = VERSION; + public static final String VERSION = "0.8.2", version = VERSION; public static final String DEPENDENCIES = "required-after:MineTweaker3", dependencies = DEPENDENCIES; } diff --git a/src/main/java/modtweaker2/ModTweaker2.java b/src/main/java/modtweaker2/ModTweaker2.java index 47affa0..a169feb 100644 --- a/src/main/java/modtweaker2/ModTweaker2.java +++ b/src/main/java/modtweaker2/ModTweaker2.java @@ -1,5 +1,12 @@ package modtweaker2; +import java.util.Iterator; + +import minetweaker.MineTweakerImplementationAPI; +import minetweaker.MineTweakerImplementationAPI.ReloadEvent; +import minetweaker.runtime.IScriptIterator; +import minetweaker.runtime.IScriptProvider; +import minetweaker.util.IEventHandler; import modtweaker2.mods.appeng.AppliedEnergistics; import modtweaker2.mods.auracascade.AuraCascade; import modtweaker2.mods.botania.Botania; @@ -9,7 +16,6 @@ import modtweaker2.mods.extendedworkbench.ExtendedWorkbench; import modtweaker2.mods.factorization.Factorization; import modtweaker2.mods.forestry.Forestry; import modtweaker2.mods.fsp.Steamcraft; -import modtweaker2.mods.hee.HardcoreEnderExpansion; import modtweaker2.mods.mariculture.Mariculture; import modtweaker2.mods.mekanism.Mekanism; import modtweaker2.mods.metallurgy.Metallurgy; @@ -19,6 +25,7 @@ import modtweaker2.mods.tconstruct.TConstruct; import modtweaker2.mods.tfcraft.TerraFirmaCraft; import modtweaker2.mods.thaumcraft.Thaumcraft; import modtweaker2.mods.thermalexpansion.ThermalExpansion; +import modtweaker2.proxy.CommonProxy; import modtweaker2.utils.TweakerPlugin; import net.minecraftforge.common.MinecraftForge; @@ -29,10 +36,12 @@ 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.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLServerStartingEvent; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.relauncher.Side; @Mod(modid = ModProps.modid, version = ModProps.version, dependencies = ModProps.dependencies) @@ -47,7 +56,10 @@ public class ModTweaker2 { public void preInit(FMLPreInitializationEvent event) { logger.info("Starting PreInitialization for " + ModProps.modid); } - + + @SidedProxy(clientSide = "modtweaker2.proxy.ClientProxy", serverSide = "modtweaker2.proxy.CommonProxy") + public static CommonProxy proxy; + @EventHandler public void init(FMLInitializationEvent event) { logger.info("Starting Initialization for " + ModProps.modid); @@ -56,7 +68,6 @@ public class ModTweaker2 { TweakerPlugin.register("exnihilo", ExNihilo.class); TweakerPlugin.register("extendedWorkbench", ExtendedWorkbench.class); TweakerPlugin.register("factorization", Factorization.class); - TweakerPlugin.register("HardcoreEnderExpansion", HardcoreEnderExpansion.class); TweakerPlugin.register("Mariculture", Mariculture.class); TweakerPlugin.register("Mekanism", Mekanism.class); TweakerPlugin.register("Metallurgy", Metallurgy.class); @@ -74,14 +85,18 @@ public class ModTweaker2 { if (FMLCommonHandler.instance().getSide() == Side.CLIENT) { MinecraftForge.EVENT_BUS.register(new ClientEvents()); } -// MineTweakerImplementationAPI.onReloadEvent(new IEventHandler() { -// -// @Override -// public void handle(ReloadEvent event) { -// Commands.registerCommands(); -// } -// }); + + MineTweakerImplementationAPI.onReloadEvent(new IEventHandler() { + + @Override + public void handle(ReloadEvent event) { + proxy.registerCommands(); + + } + }); + TweakerPlugin.hasInit = true; } + @EventHandler public void postInit(FMLPostInitializationEvent event) { @@ -92,7 +107,7 @@ public class ModTweaker2 { @EventHandler public void serverStart(FMLServerStartingEvent event) { logger.info("Starting ServerStart for " + ModProps.modid); - Commands.registerCommands(); + proxy.registerCommands(); } } diff --git a/src/main/java/modtweaker2/mods/exnihilo/handlers/Sieve.java b/src/main/java/modtweaker2/mods/exnihilo/handlers/Sieve.java index 77f27c4..07a21fa 100644 --- a/src/main/java/modtweaker2/mods/exnihilo/handlers/Sieve.java +++ b/src/main/java/modtweaker2/mods/exnihilo/handlers/Sieve.java @@ -17,20 +17,18 @@ import exnihilo.registries.helpers.SiftingResult; @ZenClass("mods.exnihilo.Sieve") public class Sieve { - //Adding a Ex Nihilo Sieve recipe + // Adding a Ex Nihilo Sieve recipe @ZenMethod public static void addRecipe(IItemStack input, IItemStack output, int rarity) { - if (isABlock(input)) - { + if (isABlock(input)) { Block theBlock = Block.getBlockFromItem(toStack(input).getItem()); int theMeta = toStack(input).getItemDamage(); MineTweakerAPI.apply(new Add(theBlock, theMeta, toStack(output).getItem(), toStack(output).getItemDamage(), rarity)); } } - //Passes the list to the base list implementation, and adds the recipe - private static class Add implements IUndoableAction - { + // Passes the list to the base list implementation, and adds the recipe + private static class Add implements IUndoableAction { Block source; int sourceMeta; Item output; @@ -59,8 +57,7 @@ public class Sieve { } - public String describeUndo() - { + public String describeUndo() { return "Removing ExNihilo Sieve Recipe using " + source.getLocalizedName() + " to get the result of " + output.getUnlocalizedName(); } @@ -69,46 +66,43 @@ public class Sieve { } public void undo() { - if(this.canUndo()) + if (this.canUndo()) SieveRegistry.unregisterReward(this.source, this.sourceMeta, this.output, this.outputMeta); } } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //Removing a Ex Nihilo Sieve recipe + // Removing a Ex Nihilo Sieve recipe @ZenMethod public static void removeRecipe(IItemStack input, IItemStack output) { - if (isABlock(input)) - { + if (isABlock(input)) { Block theBlock = Block.getBlockFromItem(toStack(input).getItem()); int theMeta = toStack(input).getItemDamage(); MineTweakerAPI.apply(new Remove(theBlock, theMeta, toStack(output).getItem(), toStack(output).getItemDamage())); } } - //TODO: Add other 2 remove methods that exNihilo provided - - /*@ZenMethod - public static void removeFirst(IItemStack output) { - MineTweakerAPI.apply(new Remove(toStack(output), Position.FIRST)); - } + // TODO: Add other 2 remove methods that exNihilo provided - @ZenMethod - public static void removeLast(IItemStack output) { - MineTweakerAPI.apply(new Remove(toStack(output), Position.LAST)); - }*/ + /* + * @ZenMethod public static void removeFirst(IItemStack output) { + * MineTweakerAPI.apply(new Remove(toStack(output), Position.FIRST)); } + * + * @ZenMethod public static void removeLast(IItemStack output) { + * MineTweakerAPI.apply(new Remove(toStack(output), Position.LAST)); } + */ - //Removes a recipe, apply is never the same for anything, so will always need to override it - private static class Remove implements IUndoableAction - { + // Removes a recipe, apply is never the same for anything, so will always + // need to override it + private static class Remove implements IUndoableAction { Block source; int sourceMeta; Item output; int outputMeta; - + int rarity; - + public Remove(Block source, int sourceMeta, Item output, int outputMeta) { this.source = source; this.sourceMeta = sourceMeta; @@ -118,18 +112,17 @@ public class Sieve { public void apply() { ArrayList results = SieveRegistry.getSiftingOutput(this.source, this.sourceMeta); - - for(SiftingResult res: results) - { - if(res.item.equals(this.source) && res.meta == this.outputMeta) + + for (SiftingResult res : results) { + if (res.item.equals(this.source) && res.meta == this.outputMeta) this.rarity = res.rarity; } - + SieveRegistry.unregisterReward(source, sourceMeta, output, outputMeta); } public boolean canUndo() { - return false; + return output != null && source != null; } public String describe() { @@ -146,7 +139,7 @@ public class Sieve { } public void undo() { - if(this.canUndo()) + if (this.canUndo()) SieveRegistry.register(this.source, this.sourceMeta, this.output, this.outputMeta, rarity); } } diff --git a/src/main/java/modtweaker2/mods/hee/HardcoreEnderExpansion.java b/src/main/java/modtweaker2/mods/hee/HardcoreEnderExpansion.java deleted file mode 100644 index 4410770..0000000 --- a/src/main/java/modtweaker2/mods/hee/HardcoreEnderExpansion.java +++ /dev/null @@ -1,10 +0,0 @@ -package modtweaker2.mods.hee; - -import minetweaker.MineTweakerAPI; -import modtweaker2.mods.hee.handlers.EssenceAltar; - -public class HardcoreEnderExpansion { - public HardcoreEnderExpansion() { - MineTweakerAPI.registerClass(EssenceAltar.class); - } -} diff --git a/src/main/java/modtweaker2/mods/hee/handlers/EssenceAltar.java b/src/main/java/modtweaker2/mods/hee/handlers/EssenceAltar.java deleted file mode 100644 index 2301ee1..0000000 --- a/src/main/java/modtweaker2/mods/hee/handlers/EssenceAltar.java +++ /dev/null @@ -1,76 +0,0 @@ -package modtweaker2.mods.hee.handlers; - -import static modtweaker2.helpers.InputHelper.toStack; -import static modtweaker2.helpers.StackHelper.areEqual; - -import java.util.List; - -import minetweaker.MineTweakerAPI; -import minetweaker.api.item.IItemStack; -import modtweaker2.helpers.ReflectionHelper; -import modtweaker2.utils.BaseListAddition; -import modtweaker2.utils.BaseListRemoval; -import net.minecraft.item.ItemStack; -import stanhebben.zenscript.annotations.ZenClass; -import stanhebben.zenscript.annotations.ZenMethod; -import chylex.hee.mechanics.essence.handler.DragonEssenceHandler; -import chylex.hee.mechanics.essence.handler.dragon.AltarItemRecipe; - -@ZenClass("mods.hee.EssenceAltar") -public class EssenceAltar { - @ZenMethod - public static void addRecipe(IItemStack source, IItemStack result, int cost) { - MineTweakerAPI.apply(new Add(toStack(result), new AltarItemRecipe(toStack(source), toStack(result), cost))); - } - - private static class Add extends BaseListAddition { - private final ItemStack result; - - public Add(ItemStack result, AltarItemRecipe recipe) { - super("Essence Altar", DragonEssenceHandler.recipes, recipe); - this.result = result; - } - - @Override - public String getRecipeInfo() { - return result.getDisplayName(); - } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - @ZenMethod - public static void removeRecipe(IItemStack output) { - MineTweakerAPI.apply(new Remove(toStack(output))); - } - - private static class Remove extends BaseListRemoval { - public Remove(ItemStack stack) { - super("Essence Altar", DragonEssenceHandler.recipes, stack); - } - - //Returns the output ItemStack - private ItemStack getOutput(Object o) { - return (ItemStack) ReflectionHelper.getObject(o, "result"); - } - - @Override - public void apply() { - for (AltarItemRecipe r : (List) list) { - ItemStack output = getOutput(r); - if (output != null && areEqual(output, stack)) { - recipe = r; - break; - - } - } - - list.remove(recipe); - } - - @Override - public String getRecipeInfo() { - return stack.getDisplayName(); - } - } -} diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalInfuser.java b/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalInfuser.java index f045241..53277ae 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalInfuser.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalInfuser.java @@ -14,23 +14,23 @@ import stanhebben.zenscript.annotations.ZenMethod; @ZenClass("mods.mekanism.chemical.Infuser") public class ChemicalInfuser { - @ZenMethod - public static void addRecipe(IGasStack left, IGasStack right, IGasStack out) { - if (Mekanism.v7) - { - ChemicalPairInput pair = new ChemicalPairInput(toGas(left), toGas(right)); - MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_INFUSER", Recipe.CHEMICAL_INFUSER.get(), pair, toGas(out))); - } - else - { - ChemicalInfuserRecipe recipe = new ChemicalInfuserRecipe(toGas(left),toGas(right), toGas(out)); - MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_INFUSER", Recipe.CHEMICAL_INFUSER.get(), recipe.getInput(), recipe)); - } - } + @ZenMethod + public static void addRecipe(IGasStack left, IGasStack right, IGasStack out) { + if (Mekanism.v7) { + ChemicalPairInput pair = new ChemicalPairInput(toGas(left), toGas(right)); + MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_INFUSER", Recipe.CHEMICAL_INFUSER.get(), pair, toGas(out))); + } else { + ChemicalInfuserRecipe recipe = new ChemicalInfuserRecipe(toGas(left), toGas(right), toGas(out)); + MineTweakerAPI.apply(new AddMekanismRecipe("CHEMICAL_INFUSER", Recipe.CHEMICAL_INFUSER.get(), recipe.getInput(), recipe)); + } + } - @ZenMethod - public static void removeRecipe(IGasStack output) { - if (!Mekanism.v7) throw new UnsupportedOperationException("Function not added to v8 compatibility yet"); - MineTweakerAPI.apply(new RemoveMekanismRecipe("CHEMICAL_INFUSER", Recipe.CHEMICAL_INFUSER.get(), toGas(output))); - } + @ZenMethod + public static void removeRecipe(IGasStack output) { + if (!Mekanism.v7) + throw new UnsupportedOperationException("Function not added to v8 compatibility yet"); + MineTweakerAPI.apply(new RemoveMekanismRecipe("CHEMICAL_INFUSER", Recipe.CHEMICAL_INFUSER.get(), toGas(output))); + + + } } diff --git a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Arcane.java b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Arcane.java index b5afca8..5c94787 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Arcane.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Arcane.java @@ -12,6 +12,7 @@ import minetweaker.api.item.IItemStack; import modtweaker2.mods.thaumcraft.ThaumcraftHelper; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; +import modtweaker2.utils.TweakerPlugin; import net.minecraft.item.ItemStack; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; @@ -24,12 +25,14 @@ import thaumcraft.api.crafting.ShapelessArcaneRecipe; public class Arcane { @ZenMethod public static void addShaped(String key, IItemStack output, String aspects, IIngredient[][] ingredients) { - MineTweakerAPI.apply(new Add(new ShapedArcaneRecipe(key, toStack(output), ThaumcraftHelper.parseAspects(aspects), toShapedObjects(ingredients)))); + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new Add(new ShapedArcaneRecipe(key, toStack(output), ThaumcraftHelper.parseAspects(aspects), toShapedObjects(ingredients)))); } @ZenMethod public static void addShapeless(String key, IItemStack output, String aspects, IIngredient[] ingredients) { - MineTweakerAPI.apply(new Add(new ShapelessArcaneRecipe(key, toStack(output), ThaumcraftHelper.parseAspects(aspects), toObjects(ingredients)))); + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new Add(new ShapelessArcaneRecipe(key, toStack(output), ThaumcraftHelper.parseAspects(aspects), toObjects(ingredients)))); } private static class Add extends BaseListAddition { @@ -51,7 +54,8 @@ public class Arcane { @ZenMethod public static void removeRecipe(IItemStack output) { - MineTweakerAPI.apply(new Remove(toStack(output))); + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new Remove(toStack(output))); } private static class Remove extends BaseListRemoval { diff --git a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Aspects.java b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Aspects.java index 9a088ef..bf83e2e 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Aspects.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Aspects.java @@ -9,6 +9,7 @@ import minetweaker.api.item.IItemStack; import modtweaker2.mods.thaumcraft.ThaumcraftHelper; import modtweaker2.utils.BaseDescriptionAddition; import modtweaker2.utils.BaseDescriptionRemoval; +import modtweaker2.utils.TweakerPlugin; import net.minecraft.entity.EntityList; import net.minecraft.item.ItemStack; import stanhebben.zenscript.annotations.ZenClass; @@ -19,204 +20,212 @@ import thaumcraft.api.aspects.AspectList; @ZenClass("mods.thaumcraft.Aspects") public class Aspects { - /** Add/Remove/Set Aspects for items **/ - @ZenMethod - public static void add(IItemStack stack, String aspects) { - MineTweakerAPI.apply(new Add(toStack(stack), aspects, false)); - } + /** Add/Remove/Set Aspects for items **/ + @ZenMethod + public static void add(IItemStack stack, String aspects) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new Add(toStack(stack), aspects, false)); + } - @ZenMethod - public static void set(IItemStack stack, String aspects) { - MineTweakerAPI.apply(new Add(toStack(stack), aspects, true)); - } + @ZenMethod + public static void set(IItemStack stack, String aspects) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new Add(toStack(stack), aspects, true)); + } - //Adds or sets Aspects - private static class Add extends BaseDescriptionAddition { - private final ItemStack stack; - private final String aspects; - private final boolean replace; - private AspectList oldList; - private AspectList newList; + // Adds or sets Aspects + private static class Add extends BaseDescriptionAddition { + private final ItemStack stack; + private final String aspects; + private final boolean replace; + private AspectList oldList; + private AspectList newList; - public Add(ItemStack stack, String aspects, boolean replace) { - super("Aspects"); - this.stack = stack; - this.aspects = aspects; - this.replace = replace; - } + public Add(ItemStack stack, String aspects, boolean replace) { + super("Aspects"); + this.stack = stack; + this.aspects = aspects; + this.replace = replace; + } - @Override - public void apply() { - oldList = ThaumcraftApiHelper.getObjectAspects(stack); - if (!replace) newList = ThaumcraftHelper.parseAspects(oldList, aspects); - else newList = ThaumcraftHelper.parseAspects(aspects); - ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), newList); - } + @Override + public void apply() { + oldList = ThaumcraftApiHelper.getObjectAspects(stack); + if (!replace) + newList = ThaumcraftHelper.parseAspects(oldList, aspects); + else + newList = ThaumcraftHelper.parseAspects(aspects); + ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), newList); + } - @Override - public void undo() { - if (oldList == null) { - ThaumcraftApi.objectTags.remove(Arrays.asList(stack.getItem(), stack.getItemDamage())); - } else ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), oldList); - } + @Override + public void undo() { + if (oldList == null) { + ThaumcraftApi.objectTags.remove(Arrays.asList(stack.getItem(), stack.getItemDamage())); + } else + ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), oldList); + } - @Override - public String getRecipeInfo() { - return stack.getDisplayName(); - } - } + @Override + public String getRecipeInfo() { + return stack.getDisplayName(); + } + } - ////////////////////////////////////////////////////////////////////////////// + // //////////////////////////////////////////////////////////////////////////// - @ZenMethod - public static void remove(IItemStack stack, String aspects) { - MineTweakerAPI.apply(new Remove(toStack(stack), aspects)); - } + @ZenMethod + public static void remove(IItemStack stack, String aspects) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new Remove(toStack(stack), aspects)); + } - private static class Remove extends BaseDescriptionRemoval { - private final ItemStack stack; - private final String aspects; - private AspectList oldList; - private AspectList newList; + private static class Remove extends BaseDescriptionRemoval { + private final ItemStack stack; + private final String aspects; + private AspectList oldList; + private AspectList newList; - public Remove(ItemStack stack, String aspects) { - super("Aspects"); - this.stack = stack; - this.aspects = aspects; - } + public Remove(ItemStack stack, String aspects) { + super("Aspects"); + this.stack = stack; + this.aspects = aspects; + } - @Override - public void apply() { - oldList = ThaumcraftApiHelper.getObjectAspects(stack); - if (oldList != null) { - newList = ThaumcraftHelper.removeAspects(oldList, aspects); - ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), newList); - } - } + @Override + public void apply() { + oldList = ThaumcraftApiHelper.getObjectAspects(stack); + if (oldList != null) { + newList = ThaumcraftHelper.removeAspects(oldList, aspects); + ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), newList); + } + } - @Override - public boolean canUndo() { - return oldList != null; - } + @Override + public boolean canUndo() { + return oldList != null; + } - @Override - public void undo() { - ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), oldList); - } + @Override + public void undo() { + ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), oldList); + } - @Override - public String getRecipeInfo() { - return stack.getDisplayName(); - } - } + @Override + public String getRecipeInfo() { + return stack.getDisplayName(); + } + } - /** Add/Remove/Set Aspects for entities **/ - @ZenMethod - public static void addEntity(String entityName, String aspects) { - if(!EntityList.stringToClassMapping.containsKey(entityName)) - { - MineTweakerAPI.getLogger().logError("No such entity "+entityName); - return; - } - MineTweakerAPI.apply(new AddEntity(entityName, aspects, false)); - } + /** Add/Remove/Set Aspects for entities **/ + @ZenMethod + public static void addEntity(String entityName, String aspects) { + if (!EntityList.stringToClassMapping.containsKey(entityName)) { + MineTweakerAPI.getLogger().logError("No such entity " + entityName); + return; + } + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new AddEntity(entityName, aspects, false)); + } - @ZenMethod - public static void setEntity(String entityName, String aspects) { - if(!EntityList.stringToClassMapping.containsKey(entityName)) - { - MineTweakerAPI.getLogger().logError("No such entity "+entityName); - return; - } - MineTweakerAPI.apply(new AddEntity(entityName, aspects, true)); - } + @ZenMethod + public static void setEntity(String entityName, String aspects) { + if (!EntityList.stringToClassMapping.containsKey(entityName)) { + MineTweakerAPI.getLogger().logError("No such entity " + entityName); + return; + } + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new AddEntity(entityName, aspects, true)); + } - //Adds or sets Aspects - private static class AddEntity extends BaseDescriptionAddition { - private final String entityName; - private final String aspects; - private final boolean replace; - private AspectList oldList; - private AspectList newList; + // Adds or sets Aspects + private static class AddEntity extends BaseDescriptionAddition { + private final String entityName; + private final String aspects; + private final boolean replace; + private AspectList oldList; + private AspectList newList; - public AddEntity(String entityName, String aspects, boolean replace) { - super("Aspects"); - this.entityName = entityName; - this.aspects = aspects; - this.replace = replace; - } + public AddEntity(String entityName, String aspects, boolean replace) { + super("Aspects"); + this.entityName = entityName; + this.aspects = aspects; + this.replace = replace; + } - @Override - public void apply() { - oldList = ThaumcraftHelper.getEntityAspects(entityName); - if (!replace) newList = ThaumcraftHelper.parseAspects(oldList, aspects); - else newList = ThaumcraftHelper.parseAspects(aspects); - ThaumcraftHelper.removeEntityAspects(entityName); - ThaumcraftApi.registerEntityTag(entityName, newList); - } + @Override + public void apply() { + oldList = ThaumcraftHelper.getEntityAspects(entityName); + if (!replace) + newList = ThaumcraftHelper.parseAspects(oldList, aspects); + else + newList = ThaumcraftHelper.parseAspects(aspects); + ThaumcraftHelper.removeEntityAspects(entityName); + ThaumcraftApi.registerEntityTag(entityName, newList); + } - @Override - public void undo() { - ThaumcraftHelper.removeEntityAspects(entityName); - if (oldList != null) - ThaumcraftApi.registerEntityTag(entityName, oldList); - } + @Override + public void undo() { + ThaumcraftHelper.removeEntityAspects(entityName); + if (oldList != null) + ThaumcraftApi.registerEntityTag(entityName, oldList); + } - @Override - public String getRecipeInfo() { - return entityName; - } - } + @Override + public String getRecipeInfo() { + return entityName; + } + } - ////////////////////////////////////////////////////////////////////////////// + // //////////////////////////////////////////////////////////////////////////// - @ZenMethod - public static void removeEntity(String entityName, String aspects) { - if(!EntityList.stringToClassMapping.containsKey(entityName)) - { - MineTweakerAPI.getLogger().logError("No such entity "+entityName); - return; - } - MineTweakerAPI.apply(new RemoveEntity(entityName, aspects)); - } + @ZenMethod + public static void removeEntity(String entityName, String aspects) { + if (!EntityList.stringToClassMapping.containsKey(entityName)) { + MineTweakerAPI.getLogger().logError("No such entity " + entityName); + return; + } + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new RemoveEntity(entityName, aspects)); + } - private static class RemoveEntity extends BaseDescriptionRemoval { - private final String entityName; - private final String aspects; - private AspectList oldList; - private AspectList newList; + private static class RemoveEntity extends BaseDescriptionRemoval { + private final String entityName; + private final String aspects; + private AspectList oldList; + private AspectList newList; - public RemoveEntity(String entityName, String aspects) { - super("Aspects"); - this.entityName = entityName; - this.aspects = aspects; - } + public RemoveEntity(String entityName, String aspects) { + super("Aspects"); + this.entityName = entityName; + this.aspects = aspects; + } - @Override - public void apply() { - oldList = ThaumcraftHelper.getEntityAspects(entityName); - if (oldList != null) { - newList = ThaumcraftHelper.removeAspects(oldList, aspects); - ThaumcraftHelper.removeEntityAspects(entityName); - ThaumcraftApi.registerEntityTag(entityName, newList); - } - } + @Override + public void apply() { + oldList = ThaumcraftHelper.getEntityAspects(entityName); + if (oldList != null) { + newList = ThaumcraftHelper.removeAspects(oldList, aspects); + ThaumcraftHelper.removeEntityAspects(entityName); + ThaumcraftApi.registerEntityTag(entityName, newList); + } + } - @Override - public boolean canUndo() { - return oldList != null; - } + @Override + public boolean canUndo() { + return oldList != null; + } - @Override - public void undo() { - ThaumcraftHelper.removeEntityAspects(entityName); - ThaumcraftApi.registerEntityTag(entityName, oldList); - } + @Override + public void undo() { + ThaumcraftHelper.removeEntityAspects(entityName); + ThaumcraftApi.registerEntityTag(entityName, oldList); + } + + @Override + public String getRecipeInfo() { + return entityName; + } + } - @Override - public String getRecipeInfo() { - return entityName; - } - } - } diff --git a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Crucible.java b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Crucible.java index e3a109e..e35eaee 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Crucible.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Crucible.java @@ -9,6 +9,7 @@ import minetweaker.api.item.IItemStack; import modtweaker2.mods.thaumcraft.ThaumcraftHelper; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; +import modtweaker2.utils.TweakerPlugin; import net.minecraft.item.ItemStack; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; @@ -17,52 +18,54 @@ import thaumcraft.api.crafting.CrucibleRecipe; @ZenClass("mods.thaumcraft.Crucible") public class Crucible { - @ZenMethod - public static void addRecipe(String key, IItemStack result, IIngredient catalyst, String aspects) { - MineTweakerAPI.apply(new Add(new CrucibleRecipe(key, toStack(result), toObject(catalyst), ThaumcraftHelper.parseAspects(aspects)))); - } + @ZenMethod + public static void addRecipe(String key, IItemStack result, IIngredient catalyst, String aspects) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new Add(new CrucibleRecipe(key, toStack(result), toObject(catalyst), ThaumcraftHelper.parseAspects(aspects)))); + } - private static class Add extends BaseListAddition { - public Add(CrucibleRecipe recipe) { - super("Thaumcraft Crucible", ThaumcraftApi.getCraftingRecipes(), recipe); - } + private static class Add extends BaseListAddition { + public Add(CrucibleRecipe recipe) { + super("Thaumcraft Crucible", ThaumcraftApi.getCraftingRecipes(), recipe); + } - @Override - public String getRecipeInfo() { - return ((CrucibleRecipe) recipe).getRecipeOutput().getDisplayName(); - } - } + @Override + public String getRecipeInfo() { + return ((CrucibleRecipe) recipe).getRecipeOutput().getDisplayName(); + } + } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - @ZenMethod - public static void removeRecipe(IItemStack output) { - MineTweakerAPI.apply(new Remove(toStack(output))); - } + @ZenMethod + public static void removeRecipe(IItemStack output) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new Remove(toStack(output))); + } - private static class Remove extends BaseListRemoval { - public Remove(ItemStack stack) { - super("Thaumcraft Crucible", ThaumcraftApi.getCraftingRecipes(), stack); - } + private static class Remove extends BaseListRemoval { + public Remove(ItemStack stack) { + super("Thaumcraft Crucible", ThaumcraftApi.getCraftingRecipes(), stack); + } - @Override - public void apply() { - for (Object o : ThaumcraftApi.getCraftingRecipes()) { - if (o instanceof CrucibleRecipe) { - CrucibleRecipe r = (CrucibleRecipe) o; - if (r.getRecipeOutput() != null && areEqual(r.getRecipeOutput(), stack)) { - recipe = r; - break; - } - } - } + @Override + public void apply() { + for (Object o : ThaumcraftApi.getCraftingRecipes()) { + if (o instanceof CrucibleRecipe) { + CrucibleRecipe r = (CrucibleRecipe) o; + if (r.getRecipeOutput() != null && areEqual(r.getRecipeOutput(), stack)) { + recipe = r; + break; + } + } + } - ThaumcraftApi.getCraftingRecipes().remove(recipe); - } + ThaumcraftApi.getCraftingRecipes().remove(recipe); + } - @Override - public String getRecipeInfo() { - return stack.getDisplayName(); - } - } + @Override + public String getRecipeInfo() { + return stack.getDisplayName(); + } + } } diff --git a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Infusion.java b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Infusion.java index 6b2e638..e3fd350 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Infusion.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Infusion.java @@ -10,6 +10,7 @@ import modtweaker2.mods.thaumcraft.ThaumcraftHelper; import modtweaker2.mods.thaumcraft.recipe.MTInfusionRecipe; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; +import modtweaker2.utils.TweakerPlugin; import net.minecraft.enchantment.Enchantment; import net.minecraft.item.ItemStack; import stanhebben.zenscript.annotations.ZenClass; @@ -20,156 +21,163 @@ import thaumcraft.api.crafting.InfusionRecipe; @ZenClass("mods.thaumcraft.Infusion") public class Infusion { - @ZenMethod - public static void addRecipe(String key, IItemStack input, IItemStack[] recipe, String aspects, IItemStack result, int instability) { - MineTweakerAPI.apply(new Add(new InfusionRecipe(key, toStack(result), instability, ThaumcraftHelper.parseAspects(aspects), toStack(input), toStacks(recipe)))); - } + @ZenMethod + public static void addRecipe(String key, IItemStack input, IItemStack[] recipe, String aspects, IItemStack result, int instability) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new Add(new InfusionRecipe(key, toStack(result), instability, ThaumcraftHelper.parseAspects(aspects), toStack(input), toStacks(recipe)))); + } - //A version that allows you to specify whether the detection should be fuzzy or not - @ZenMethod - public static void addRecipe(String key, IItemStack input, IItemStack[] recipe, String aspects, IItemStack result, int instability, boolean fuzzyCentre, boolean[] fuzzyRecipe) { - MineTweakerAPI.apply(new Add(new MTInfusionRecipe(key, toStack(result), instability, ThaumcraftHelper.parseAspects(aspects), toStack(input), toStacks(recipe), fuzzyCentre, fuzzyRecipe))); - } + // A version that allows you to specify whether the detection should be + // fuzzy or not + @ZenMethod + public static void addRecipe(String key, IItemStack input, IItemStack[] recipe, String aspects, IItemStack result, int instability, boolean fuzzyCentre, boolean[] fuzzyRecipe) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new Add(new MTInfusionRecipe(key, toStack(result), instability, ThaumcraftHelper.parseAspects(aspects), toStack(input), toStacks(recipe), fuzzyCentre, fuzzyRecipe))); + } - @ZenMethod - public static void addEnchantment(String key, int enchantID, int instability, String aspects, IItemStack[] recipe) { - MineTweakerAPI.apply(new AddEnchant(new InfusionEnchantmentRecipe(key, Enchantment.enchantmentsList[enchantID], instability, ThaumcraftHelper.parseAspects(aspects), toStacks(recipe)))); - } + @ZenMethod + public static void addEnchantment(String key, int enchantID, int instability, String aspects, IItemStack[] recipe) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new AddEnchant(new InfusionEnchantmentRecipe(key, Enchantment.enchantmentsList[enchantID], instability, ThaumcraftHelper.parseAspects(aspects), toStacks(recipe)))); + } - private static class Add extends BaseListAddition { - public Add(InfusionRecipe recipe) { - super("Thaumcraft Infusion", ThaumcraftApi.getCraftingRecipes(), recipe); - } + private static class Add extends BaseListAddition { + public Add(InfusionRecipe recipe) { + super("Thaumcraft Infusion", ThaumcraftApi.getCraftingRecipes(), recipe); + } - @Override - public String getRecipeInfo() { - Object out = ((InfusionRecipe) recipe).getRecipeOutput(); - if (out instanceof ItemStack) { - return ((ItemStack) out).getDisplayName(); - } else return super.getRecipeInfo(); - } - } + @Override + public String getRecipeInfo() { + Object out = ((InfusionRecipe) recipe).getRecipeOutput(); + if (out instanceof ItemStack) { + return ((ItemStack) out).getDisplayName(); + } else + return super.getRecipeInfo(); + } + } - private static class AddEnchant implements IUndoableAction { - InfusionEnchantmentRecipe recipe; + private static class AddEnchant implements IUndoableAction { + InfusionEnchantmentRecipe recipe; - public AddEnchant(InfusionEnchantmentRecipe inp) { - recipe = inp; - } + public AddEnchant(InfusionEnchantmentRecipe inp) { + recipe = inp; + } - @Override - public void apply() { - ThaumcraftApi.getCraftingRecipes().add(recipe); - } + @Override + public void apply() { + ThaumcraftApi.getCraftingRecipes().add(recipe); + } - @Override - public String describe() { - return "Adding Infusion Enchantment Recipe: " + recipe.enchantment.getName(); - } + @Override + public String describe() { + return "Adding Infusion Enchantment Recipe: " + recipe.enchantment.getName(); + } - @Override - public boolean canUndo() { - return recipe != null; - } + @Override + public boolean canUndo() { + return recipe != null; + } - @Override - public void undo() { - ThaumcraftApi.getCraftingRecipes().remove(recipe); - } + @Override + public void undo() { + ThaumcraftApi.getCraftingRecipes().remove(recipe); + } - @Override - public String describeUndo() { - return "Removing Infusion Enchantment Recipe: " + recipe.enchantment.getName(); - } + @Override + public String describeUndo() { + return "Removing Infusion Enchantment Recipe: " + recipe.enchantment.getName(); + } - @Override - public String getOverrideKey() { - return null; - } - } + @Override + public String getOverrideKey() { + return null; + } + } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - @ZenMethod - public static void removeRecipe(IItemStack output) { - MineTweakerAPI.apply(new Remove(toStack(output))); - } + @ZenMethod + public static void removeRecipe(IItemStack output) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new Remove(toStack(output))); + } - @ZenMethod - public static void removeEnchant(int id) { - MineTweakerAPI.apply(new RemoveEnchant(Enchantment.enchantmentsList[id])); - } + @ZenMethod + public static void removeEnchant(int id) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new RemoveEnchant(Enchantment.enchantmentsList[id])); + } - private static class Remove extends BaseListRemoval { - public Remove(ItemStack stack) { - super("Thaumcraft Infusion", ThaumcraftApi.getCraftingRecipes(), stack); - } + private static class Remove extends BaseListRemoval { + public Remove(ItemStack stack) { + super("Thaumcraft Infusion", ThaumcraftApi.getCraftingRecipes(), stack); + } - @Override - public void apply() { - for (Object o : ThaumcraftApi.getCraftingRecipes()) { - if (o instanceof InfusionRecipe) { - InfusionRecipe r = (InfusionRecipe) o; - if (r.getRecipeOutput() != null && r.getRecipeOutput() instanceof ItemStack && areEqual((ItemStack) r.getRecipeOutput(), stack)) { - recipe = r; - break; - } - } - } + @Override + public void apply() { + for (Object o : ThaumcraftApi.getCraftingRecipes()) { + if (o instanceof InfusionRecipe) { + InfusionRecipe r = (InfusionRecipe) o; + if (r.getRecipeOutput() != null && r.getRecipeOutput() instanceof ItemStack && areEqual((ItemStack) r.getRecipeOutput(), stack)) { + recipe = r; + break; + } + } + } - ThaumcraftApi.getCraftingRecipes().remove(recipe); - } + ThaumcraftApi.getCraftingRecipes().remove(recipe); + } - @Override - public String getRecipeInfo() { - return stack.getDisplayName(); - } - } + @Override + public String getRecipeInfo() { + return stack.getDisplayName(); + } + } - private static class RemoveEnchant implements IUndoableAction { - Enchantment enchant; - InfusionEnchantmentRecipe removed; + private static class RemoveEnchant implements IUndoableAction { + Enchantment enchant; + InfusionEnchantmentRecipe removed; - public RemoveEnchant(Enchantment ench) { - enchant = ench; - } + public RemoveEnchant(Enchantment ench) { + enchant = ench; + } - @Override - public void apply() { - for (Object recipe : ThaumcraftApi.getCraftingRecipes()) { - if (recipe instanceof InfusionEnchantmentRecipe) { - InfusionEnchantmentRecipe enchRecipe = (InfusionEnchantmentRecipe) recipe; - if (enchRecipe.getEnchantment() == enchant) { - removed = enchRecipe; - ThaumcraftApi.getCraftingRecipes().remove(enchRecipe); - } - } - } - } + @Override + public void apply() { + for (Object recipe : ThaumcraftApi.getCraftingRecipes()) { + if (recipe instanceof InfusionEnchantmentRecipe) { + InfusionEnchantmentRecipe enchRecipe = (InfusionEnchantmentRecipe) recipe; + if (enchRecipe.getEnchantment() == enchant) { + removed = enchRecipe; + ThaumcraftApi.getCraftingRecipes().remove(enchRecipe); + } + } + } + } - @Override - public String describe() { - return "Removing Infusion Enchantment Recipe: " + enchant.getName(); - } + @Override + public String describe() { + return "Removing Infusion Enchantment Recipe: " + enchant.getName(); + } - @Override - public boolean canUndo() { - return removed != null; - } + @Override + public boolean canUndo() { + return removed != null; + } - @Override - public void undo() { - ThaumcraftApi.getCraftingRecipes().add(removed); - } + @Override + public void undo() { + ThaumcraftApi.getCraftingRecipes().add(removed); + } - @Override - public String describeUndo() { - return "Restoring Infusion Enchantment Recipe: " + enchant.getName(); - } + @Override + public String describeUndo() { + return "Restoring Infusion Enchantment Recipe: " + enchant.getName(); + } - @Override - public String getOverrideKey() { - return null; - } - } + @Override + public String getOverrideKey() { + return null; + } + } } diff --git a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Research.java b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Research.java index da423aa..c2a277e 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Research.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Research.java @@ -21,6 +21,7 @@ import modtweaker2.mods.thaumcraft.research.RemoveResearch; import modtweaker2.mods.thaumcraft.research.RemoveTab; import modtweaker2.mods.thaumcraft.research.SetAspects; import modtweaker2.mods.thaumcraft.research.SetResearch; +import modtweaker2.utils.TweakerPlugin; import net.minecraft.enchantment.Enchantment; import net.minecraft.util.ResourceLocation; import stanhebben.zenscript.annotations.Optional; @@ -32,167 +33,199 @@ import thaumcraft.api.research.ResearchPage.PageType; @ZenClass("mods.thaumcraft.Research") public class Research { - private static final ResourceLocation defaultBackground = new ResourceLocation("thaumcraft", "textures/gui/gui_researchback.png"); + private static final ResourceLocation defaultBackground = new ResourceLocation("thaumcraft", "textures/gui/gui_researchback.png"); - @ZenMethod - public static void addTab(String key, String iconDomain, String iconPath) { - addTab(key, iconDomain, iconPath, null, null); - } + @ZenMethod + public static void addTab(String key, String iconDomain, String iconPath) { + addTab(key, iconDomain, iconPath, null, null); + } - @ZenMethod - public static void addTab(String key, String iconDomain, String iconPath, String backDomain, String backPath) { - ResourceLocation icon = new ResourceLocation(iconDomain, iconPath); - ResourceLocation background; - if (backPath == null) background = defaultBackground; - else background = new ResourceLocation(backDomain, backPath); - addTab(key, icon, background); - } + @ZenMethod + public static void addTab(String key, String iconDomain, String iconPath, String backDomain, String backPath) { + ResourceLocation icon = new ResourceLocation(iconDomain, iconPath); + ResourceLocation background; + if (backPath == null) + background = defaultBackground; + else + background = new ResourceLocation(backDomain, backPath); + addTab(key, icon, background); + } - private static void addTab(String key, ResourceLocation icon, ResourceLocation background) { - MineTweakerAPI.apply(new AddTab(key, icon, background)); - } + private static void addTab(String key, ResourceLocation icon, ResourceLocation background) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new AddTab(key, icon, background)); + } - @ZenMethod - public static void removeTab(String tab) { - MineTweakerAPI.apply(new RemoveTab(tab)); - } + @ZenMethod + public static void removeTab(String tab) { - @ZenMethod - public static void removeResearch(String research) { - MineTweakerAPI.apply(new RemoveResearch(research)); - } + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new RemoveTab(tab)); + } - @ZenMethod - public static void orphanResearch(String research) { - MineTweakerAPI.apply(new OrphanResearch(research)); - } + @ZenMethod + public static void removeResearch(String research) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new RemoveResearch(research)); + } - @ZenMethod - public static void addResearch(String key, String tab, @Optional String aspects, int x, int y, int difficulty, String domain, String path) { - MineTweakerAPI.apply(new AddResearch(new ResearchItem(key, tab, ThaumcraftHelper.parseAspects(aspects), x, y, difficulty, new ResourceLocation(domain, path)))); - } + @ZenMethod + public static void orphanResearch(String research) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new OrphanResearch(research)); + } - @ZenMethod - public static void addResearch(String key, String tab, @Optional String aspects, int x, int y, int difficulty, IItemStack item) { - MineTweakerAPI.apply(new AddResearch(new ResearchItem(key, tab, ThaumcraftHelper.parseAspects(aspects), x, y, difficulty, toStack(item)))); - } + @ZenMethod + public static void addResearch(String key, String tab, @Optional String aspects, int x, int y, int difficulty, String domain, String path) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new AddResearch(new ResearchItem(key, tab, ThaumcraftHelper.parseAspects(aspects), x, y, difficulty, new ResourceLocation(domain, path)))); + } - @ZenMethod - public static void addPage(String key, String unlocalized) { - MineTweakerAPI.apply(new AddPage(key, PageType.TEXT, unlocalized)); - } + @ZenMethod + public static void addResearch(String key, String tab, @Optional String aspects, int x, int y, int difficulty, IItemStack item) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new AddResearch(new ResearchItem(key, tab, ThaumcraftHelper.parseAspects(aspects), x, y, difficulty, toStack(item)))); + } - @ZenMethod - public static void addCraftingPage(String key, IItemStack item) { - MineTweakerAPI.apply(new AddPage(key, PageType.NORMAL_CRAFTING, toStack(item))); - } + @ZenMethod + public static void addPage(String key, String unlocalized) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new AddPage(key, PageType.TEXT, unlocalized)); + } - @ZenMethod - public static void addCruciblePage(String key, IItemStack item) { - MineTweakerAPI.apply(new AddPage(key, PageType.CRUCIBLE_CRAFTING, toStack(item))); - } + @ZenMethod + public static void addCraftingPage(String key, IItemStack item) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new AddPage(key, PageType.NORMAL_CRAFTING, toStack(item))); + } - @ZenMethod - public static void addArcanePage(String key, IItemStack item) { - MineTweakerAPI.apply(new AddPage(key, PageType.ARCANE_CRAFTING, toStack(item))); - } + @ZenMethod + public static void addCruciblePage(String key, IItemStack item) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new AddPage(key, PageType.CRUCIBLE_CRAFTING, toStack(item))); + } - @ZenMethod - public static void addInfusionPage(String key, IItemStack item) { - MineTweakerAPI.apply(new AddPage(key, PageType.INFUSION_CRAFTING, toStack(item))); - } + @ZenMethod + public static void addArcanePage(String key, IItemStack item) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new AddPage(key, PageType.ARCANE_CRAFTING, toStack(item))); + } - @ZenMethod - public static void addEnchantmentPage(String key, int i) { - MineTweakerAPI.apply(new AddPage(key, PageType.INFUSION_ENCHANTMENT, Enchantment.enchantmentsList[i])); - } + @ZenMethod + public static void addInfusionPage(String key, IItemStack item) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new AddPage(key, PageType.INFUSION_CRAFTING, toStack(item))); + } - @ZenMethod - public static void clearPages(String key) { - MineTweakerAPI.apply(new ClearPages(key)); - } + @ZenMethod + public static void addEnchantmentPage(String key, int i) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new AddPage(key, PageType.INFUSION_ENCHANTMENT, Enchantment.enchantmentsList[i])); + } - @ZenMethod - public static void addPrereq(String key, String req, @Optional boolean hidden) { - MineTweakerAPI.apply(new AddPrereq(key, req, hidden)); - } + @ZenMethod + public static void clearPages(String key) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new ClearPages(key)); + } - @ZenMethod - public static void clearPrereqs(String key) { - MineTweakerAPI.apply(new ClearPrereqs(key)); - } + @ZenMethod + public static void addPrereq(String key, String req, @Optional boolean hidden) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new AddPrereq(key, req, hidden)); + } - @ZenMethod - public static void addSibling(String key, String sibling) { - MineTweakerAPI.apply(new AddSibling(key, sibling)); - } + @ZenMethod + public static void clearPrereqs(String key) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new ClearPrereqs(key)); + } - @ZenMethod - public static void clearSiblings(String key) { - MineTweakerAPI.apply(new ClearSiblings(key)); - } + @ZenMethod + public static void addSibling(String key, String sibling) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new AddSibling(key, sibling)); + } - @ZenMethod - public static void setRound(String key, boolean flag) { - MineTweakerAPI.apply(new SetResearch(key, flag, SetType.ROUND)); - } + @ZenMethod + public static void clearSiblings(String key) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new ClearSiblings(key)); + } - @ZenMethod - public static void setSpikey(String key, boolean flag) { - MineTweakerAPI.apply(new SetResearch(key, flag, SetType.SPIKE)); - } + @ZenMethod + public static void setRound(String key, boolean flag) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new SetResearch(key, flag, SetType.ROUND)); + } - @ZenMethod - public static void setStub(String key, boolean flag) { - MineTweakerAPI.apply(new SetResearch(key, flag, SetType.STUB)); - } + @ZenMethod + public static void setSpikey(String key, boolean flag) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new SetResearch(key, flag, SetType.SPIKE)); + } - @ZenMethod - public static void setSecondary(String key, boolean flag) { - MineTweakerAPI.apply(new SetResearch(key, flag, SetType.SECONDARY)); - } + @ZenMethod + public static void setStub(String key, boolean flag) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new SetResearch(key, flag, SetType.STUB)); + } - @ZenMethod - public static void setVirtual(String key, boolean flag) { - MineTweakerAPI.apply(new SetResearch(key, flag, SetType.VIRTUAL)); - } + @ZenMethod + public static void setSecondary(String key, boolean flag) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new SetResearch(key, flag, SetType.SECONDARY)); + } - @ZenMethod - public static void setAutoUnlock(String key, boolean flag) { - MineTweakerAPI.apply(new SetResearch(key, flag, SetType.AUTO)); - } + @ZenMethod + public static void setVirtual(String key, boolean flag) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new SetResearch(key, flag, SetType.VIRTUAL)); + } - @ZenMethod - public static void setConcealed(String key, boolean flag) { - MineTweakerAPI.apply(new SetResearch(key, flag, SetType.CONCEAL)); - } + @ZenMethod + public static void setAutoUnlock(String key, boolean flag) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new SetResearch(key, flag, SetType.AUTO)); + } - @ZenMethod - public static void setAspects(String key, String aspects) { - MineTweakerAPI.apply(new SetAspects(key, ThaumcraftHelper.parseAspects(aspects))); - } + @ZenMethod + public static void setConcealed(String key, boolean flag) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new SetResearch(key, flag, SetType.CONCEAL)); + } - @ZenMethod - public static void setComplexity(String key, int complexity) { - MineTweakerAPI.apply(new Difficulty(key, complexity)); - } + @ZenMethod + public static void setAspects(String key, String aspects) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new SetAspects(key, ThaumcraftHelper.parseAspects(aspects))); + } - @ZenMethod - public static void refreshResearchRecipe(String key) { - MineTweakerAPI.apply(new RefreshResearch(key)); - } + @ZenMethod + public static void setComplexity(String key, int complexity) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new Difficulty(key, complexity)); + } + + @ZenMethod + public static void refreshResearchRecipe(String key) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new RefreshResearch(key)); + } + + @ZenMethod + public static void moveResearch(String key, String destination, int x, int y) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new MoveResearch(key, destination, x, y)); + } - @ZenMethod - public static void moveResearch(String key, String destination, int x, int y) { - MineTweakerAPI.apply(new MoveResearch(key, destination, x, y)); - } - @ZenMethod public static boolean hasResearched(IPlayer player, String key) { + return ThaumcraftApiHelper.isResearchComplete(player.getName(), key); } - public static enum SetType { - AUTO, ROUND, SPIKE, SECONDARY, STUB, VIRTUAL, CONCEAL - } + public static enum SetType { + AUTO, ROUND, SPIKE, SECONDARY, STUB, VIRTUAL, CONCEAL + } } diff --git a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Warp.java b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Warp.java index 655c5b7..8713f56 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Warp.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Warp.java @@ -10,6 +10,7 @@ import minetweaker.IUndoableAction; import minetweaker.MineTweakerAPI; import minetweaker.api.item.IItemStack; import modtweaker2.mods.thaumcraft.ThaumcraftHelper; +import modtweaker2.utils.TweakerPlugin; import net.minecraft.item.ItemStack; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; @@ -18,192 +19,221 @@ import thaumcraft.api.ThaumcraftApi; @ZenClass("mods.thaumcraft.Warp") public class Warp { - @ZenMethod - public static void addToResearch(String key, int warp) { - MineTweakerAPI.apply(new Add(key, warp)); - } + @ZenMethod + public static void addToResearch(String key, int warp) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new Add(key, warp)); + } - @ZenMethod - public static void addToItem(IItemStack stack, int warp) { - MineTweakerAPI.apply(new Add(toStack(stack), warp)); - } + @ZenMethod + public static void addToItem(IItemStack stack, int warp) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new Add(toStack(stack), warp)); + } - private static class Add implements IUndoableAction { - Object target; - int warp; + private static class Add implements IUndoableAction { + Object target; + int warp; - public Add(Object targ, int amount) { - target = targ; - warp = amount; - } + public Add(Object targ, int amount) { + target = targ; + warp = amount; + } - public void apply() { - if (target instanceof String) ThaumcraftApi.addWarpToResearch((String) target, warp); - else if (target instanceof ItemStack) ThaumcraftApi.addWarpToItem((ItemStack) target, warp); - } + public void apply() { + if (target instanceof String) + ThaumcraftApi.addWarpToResearch((String) target, warp); + else if (target instanceof ItemStack) + ThaumcraftApi.addWarpToItem((ItemStack) target, warp); + } - public boolean canUndo() { - return ThaumcraftApi.getWarp(target) > 0; - } + public boolean canUndo() { + return ThaumcraftApi.getWarp(target) > 0; + } - public String describe() { - String desc = "Adding " + warp + " warp to "; - if (target instanceof String) desc += (String) target; - else if (target instanceof ItemStack) desc += ((ItemStack) target).getDisplayName(); - return desc; - } + public String describe() { + String desc = "Adding " + warp + " warp to "; + if (target instanceof String) + desc += (String) target; + else if (target instanceof ItemStack) + desc += ((ItemStack) target).getDisplayName(); + return desc; + } - public void undo() { - if (target instanceof String) ThaumcraftHelper.warpList.remove(target); - else if (target instanceof ItemStack) ThaumcraftHelper.warpList.remove(Arrays.asList(((ItemStack) target).getItem(), ((ItemStack) target).getItemDamage())); - } + public void undo() { + if (target instanceof String) + ThaumcraftHelper.warpList.remove(target); + else if (target instanceof ItemStack) + ThaumcraftHelper.warpList.remove(Arrays.asList(((ItemStack) target).getItem(), ((ItemStack) target).getItemDamage())); + } - public String describeUndo() { - String desc = "Removing warp from "; - if (target instanceof String) desc += (String) target; - else if (target instanceof ItemStack) desc += ((ItemStack) target).getDisplayName(); - return desc; - } + public String describeUndo() { + String desc = "Removing warp from "; + if (target instanceof String) + desc += (String) target; + else if (target instanceof ItemStack) + desc += ((ItemStack) target).getDisplayName(); + return desc; + } - public Object getOverrideKey() { - return null; - } + public Object getOverrideKey() { + return null; + } - } + } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - @ZenMethod - public static void removeFromResearch(String key) { - MineTweakerAPI.apply(new Remove(key)); - } + @ZenMethod + public static void removeFromResearch(String key) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new Remove(key)); + } - @ZenMethod - public static void removeFromItem(IItemStack stack) { - MineTweakerAPI.apply(new Remove(toStack(stack))); - } + @ZenMethod + public static void removeFromItem(IItemStack stack) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new Remove(toStack(stack))); + } - @ZenMethod - public static void removeAll() { - MineTweakerAPI.apply(new MassRemove(RemoveType.BOTH)); - } + @ZenMethod + public static void removeAll() { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new MassRemove(RemoveType.BOTH)); + } - @ZenMethod - public static void removeAllResearch() { - MineTweakerAPI.apply(new MassRemove(RemoveType.RESEARCH)); - } + @ZenMethod + public static void removeAllResearch() { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new MassRemove(RemoveType.RESEARCH)); + } - @ZenMethod - public static void removeAllItems() { - MineTweakerAPI.apply(new MassRemove(RemoveType.ITEMS)); - } + @ZenMethod + public static void removeAllItems() { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new MassRemove(RemoveType.ITEMS)); + } - private static class Remove implements IUndoableAction { - Object target; - int warp; + private static class Remove implements IUndoableAction { + Object target; + int warp; - public Remove(Object targ) { - target = targ; - } + public Remove(Object targ) { + target = targ; + } - public void apply() { - if (target instanceof String) warp = ThaumcraftHelper.warpList.remove(target); - else if (target instanceof ItemStack) warp = ThaumcraftHelper.warpList.remove(Arrays.asList(((ItemStack) target).getItem(), ((ItemStack) target).getItemDamage())); - } + public void apply() { + if (target instanceof String) + warp = ThaumcraftHelper.warpList.remove(target); + else if (target instanceof ItemStack) + warp = ThaumcraftHelper.warpList.remove(Arrays.asList(((ItemStack) target).getItem(), ((ItemStack) target).getItemDamage())); + } - public boolean canUndo() { - return warp > 0; - } + public boolean canUndo() { + return warp > 0; + } - public String describe() { - String desc = "Removing warp from "; - if (target instanceof String) desc += (String) target; - else if (target instanceof ItemStack) desc += ((ItemStack) target).getDisplayName(); - return desc; - } + public String describe() { + String desc = "Removing warp from "; + if (target instanceof String) + desc += (String) target; + else if (target instanceof ItemStack) + desc += ((ItemStack) target).getDisplayName(); + return desc; + } - public void undo() { - if (target instanceof String) ThaumcraftApi.addWarpToResearch((String) target, warp); - else if (target instanceof ItemStack) ThaumcraftApi.addWarpToItem((ItemStack) target, warp); - } + public void undo() { + if (target instanceof String) + ThaumcraftApi.addWarpToResearch((String) target, warp); + else if (target instanceof ItemStack) + ThaumcraftApi.addWarpToItem((ItemStack) target, warp); + } - public String describeUndo() { - String desc = "Restoring " + warp + " warp to "; - if (target instanceof String) desc += (String) target; - else if (target instanceof ItemStack) desc += ((ItemStack) target).getDisplayName(); - return desc; - } + public String describeUndo() { + String desc = "Restoring " + warp + " warp to "; + if (target instanceof String) + desc += (String) target; + else if (target instanceof ItemStack) + desc += ((ItemStack) target).getDisplayName(); + return desc; + } - public Object getOverrideKey() { - return null; - } + public Object getOverrideKey() { + return null; + } - } + } - public static enum RemoveType { - RESEARCH, ITEMS, BOTH - } + public static enum RemoveType { + RESEARCH, ITEMS, BOTH + } - private static class MassRemove implements IUndoableAction { - HashMap oldMap = new HashMap(); - RemoveType type; + private static class MassRemove implements IUndoableAction { + HashMap oldMap = new HashMap(); + RemoveType type; - public MassRemove(RemoveType typ) { - type = typ; - } + public MassRemove(RemoveType typ) { + type = typ; + } - public void apply() { - if (type == RemoveType.BOTH) { - for (Object key : ThaumcraftHelper.warpList.keySet()) { - oldMap.put(key, ThaumcraftHelper.warpList.get(key)); - } - ThaumcraftHelper.warpList.clear(); - } else if (type == RemoveType.ITEMS) { - for (Object key : ThaumcraftHelper.warpList.keySet()) { - if (key instanceof List) { - oldMap.put(key, ThaumcraftHelper.warpList.get(key)); - } - } - for (Object key : oldMap.keySet()) { - ThaumcraftHelper.warpList.remove(key); - } - } else if (type == RemoveType.RESEARCH) { - for (Object key : ThaumcraftHelper.warpList.keySet()) { - if (key instanceof String) { - oldMap.put(key, ThaumcraftHelper.warpList.get(key)); - } - } - for (Object key : oldMap.keySet()) { - ThaumcraftHelper.warpList.remove(key); - } - } - } + public void apply() { + if (type == RemoveType.BOTH) { + for (Object key : ThaumcraftHelper.warpList.keySet()) { + oldMap.put(key, ThaumcraftHelper.warpList.get(key)); + } + ThaumcraftHelper.warpList.clear(); + } else if (type == RemoveType.ITEMS) { + for (Object key : ThaumcraftHelper.warpList.keySet()) { + if (key instanceof List) { + oldMap.put(key, ThaumcraftHelper.warpList.get(key)); + } + } + for (Object key : oldMap.keySet()) { + ThaumcraftHelper.warpList.remove(key); + } + } else if (type == RemoveType.RESEARCH) { + for (Object key : ThaumcraftHelper.warpList.keySet()) { + if (key instanceof String) { + oldMap.put(key, ThaumcraftHelper.warpList.get(key)); + } + } + for (Object key : oldMap.keySet()) { + ThaumcraftHelper.warpList.remove(key); + } + } + } - public boolean canUndo() { - return oldMap.size() > 0; - } + public boolean canUndo() { + return oldMap.size() > 0; + } - public String describe() { - if (type == RemoveType.RESEARCH) return "Clearing All Research Warp"; - else if (type == RemoveType.ITEMS) return "Clearing All Item Warp"; - else return "Clearing All Warp"; - } + public String describe() { + if (type == RemoveType.RESEARCH) + return "Clearing All Research Warp"; + else if (type == RemoveType.ITEMS) + return "Clearing All Item Warp"; + else + return "Clearing All Warp"; + } - public void undo() { - for (Object key : oldMap.keySet()) { - ThaumcraftHelper.warpList.put(key, oldMap.get(key)); - } - } + public void undo() { + for (Object key : oldMap.keySet()) { + ThaumcraftHelper.warpList.put(key, oldMap.get(key)); + } + } - public String describeUndo() { - if (type == RemoveType.RESEARCH) return "Restoring All Research Warp"; - else if (type == RemoveType.ITEMS) return "Restoring All Item Warp"; - else return "Restoring All Warp"; - } + public String describeUndo() { + if (type == RemoveType.RESEARCH) + return "Restoring All Research Warp"; + else if (type == RemoveType.ITEMS) + return "Restoring All Item Warp"; + else + return "Restoring All Warp"; + } - public Object getOverrideKey() { - return null; - } + public Object getOverrideKey() { + return null; + } - } + } } diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/AddPage.java b/src/main/java/modtweaker2/mods/thaumcraft/research/AddPage.java index b8d6867..88c83ee 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/AddPage.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/research/AddPage.java @@ -1,6 +1,5 @@ package modtweaker2.mods.thaumcraft.research; -import static modtweaker2.helpers.StackHelper.areEqual; import minetweaker.IUndoableAction; import modtweaker2.mods.thaumcraft.ThaumcraftHelper; import net.minecraft.enchantment.Enchantment; @@ -15,6 +14,8 @@ import thaumcraft.api.crafting.InfusionRecipe; import thaumcraft.api.research.ResearchCategories; import thaumcraft.api.research.ResearchPage; import thaumcraft.api.research.ResearchPage.PageType; +import static modtweaker2.helpers.InputHelper.*; +import static modtweaker2.helpers.StackHelper.*; public class AddPage implements IUndoableAction { String key; diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/RefreshResearch.java b/src/main/java/modtweaker2/mods/thaumcraft/research/RefreshResearch.java index 251cad5..c430b21 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/RefreshResearch.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/research/RefreshResearch.java @@ -1,6 +1,5 @@ package modtweaker2.mods.thaumcraft.research; -import static modtweaker2.helpers.StackHelper.areEqual; import minetweaker.IUndoableAction; import modtweaker2.mods.thaumcraft.ThaumcraftHelper; import net.minecraft.item.ItemStack; @@ -13,6 +12,8 @@ import thaumcraft.api.crafting.InfusionRecipe; import thaumcraft.api.research.ResearchCategories; import thaumcraft.api.research.ResearchItem; import thaumcraft.api.research.ResearchPage; +import static modtweaker2.helpers.InputHelper.*; +import static modtweaker2.helpers.StackHelper.*; public class RefreshResearch implements IUndoableAction { String research; diff --git a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Crucible.java b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Crucible.java index 682d4d0..fe2d3a3 100644 --- a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Crucible.java +++ b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Crucible.java @@ -7,6 +7,7 @@ import minetweaker.IUndoableAction; import minetweaker.MineTweakerAPI; import minetweaker.api.item.IItemStack; import minetweaker.api.liquid.ILiquidStack; +import modtweaker2.utils.TweakerPlugin; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import stanhebben.zenscript.annotations.ZenClass; @@ -16,89 +17,91 @@ import cofh.thermalexpansion.util.crafting.CrucibleManager.RecipeCrucible; @ZenClass("mods.thermalexpansion.Crucible") public class Crucible { - @ZenMethod - public static void addRecipe(int energy, IItemStack input, ILiquidStack output) { - MineTweakerAPI.apply(new Add(energy, toStack(input), toFluid(output))); - } + @ZenMethod + public static void addRecipe(int energy, IItemStack input, ILiquidStack output) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new Add(energy, toStack(input), toFluid(output))); + } - private static class Add implements IUndoableAction { - ItemStack input; - FluidStack output; - int energy; - boolean applied = false; + private static class Add implements IUndoableAction { + ItemStack input; + FluidStack output; + int energy; + boolean applied = false; - public Add(int rf, ItemStack inp, FluidStack out) { - energy = rf; - input = inp; - output = out; - } + public Add(int rf, ItemStack inp, FluidStack out) { + energy = rf; + input = inp; + output = out; + } - public void apply() { - applied = CrucibleManager.addRecipe(energy, input, output); - } + public void apply() { + applied = CrucibleManager.addRecipe(energy, input, output); + } - public boolean canUndo() { - return input != null && applied; - } + public boolean canUndo() { + return input != null && applied; + } - public String describe() { - return "Adding TE Magma Crucible Recipe using " + input.getDisplayName(); - } + public String describe() { + return "Adding TE Magma Crucible Recipe using " + input.getDisplayName(); + } - public void undo() { - removeCrucibleRecipe(input); - } + public void undo() { + removeCrucibleRecipe(input); + } - public String describeUndo() { - return "Removing TE Magma Crucible Recipe using " + input.getDisplayName(); - } + public String describeUndo() { + return "Removing TE Magma Crucible Recipe using " + input.getDisplayName(); + } - public Object getOverrideKey() { - return null; - } + public Object getOverrideKey() { + return null; + } - } + } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - @ZenMethod - public static void removeRecipe(IItemStack input) { - MineTweakerAPI.apply(new Remove(toStack(input))); - } + @ZenMethod + public static void removeRecipe(IItemStack input) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new Remove(toStack(input))); + } - private static class Remove implements IUndoableAction { - ItemStack input; - RecipeCrucible removed; + private static class Remove implements IUndoableAction { + ItemStack input; + RecipeCrucible removed; - public Remove(ItemStack inp) { - input = inp; - } + public Remove(ItemStack inp) { + input = inp; + } - public void apply() { - removed = CrucibleManager.getRecipe(input); - removeCrucibleRecipe(input); - } + public void apply() { + removed = CrucibleManager.getRecipe(input); + removeCrucibleRecipe(input); + } - public boolean canUndo() { - return removed != null; - } + public boolean canUndo() { + return removed != null; + } - public String describe() { - return "Removing TE Magma Crucible Recipe using " + input.getDisplayName(); - } + public String describe() { + return "Removing TE Magma Crucible Recipe using " + input.getDisplayName(); + } - public void undo() { - CrucibleManager.addRecipe(removed.getEnergy(), removed.getInput(), removed.getOutput()); - } + public void undo() { + CrucibleManager.addRecipe(removed.getEnergy(), removed.getInput(), removed.getOutput()); + } - public String describeUndo() { - return "Restoring TE Magma Crucible Recipe using " + input.getDisplayName(); - } + public String describeUndo() { + return "Restoring TE Magma Crucible Recipe using " + input.getDisplayName(); + } - public Object getOverrideKey() { - return null; - } + public Object getOverrideKey() { + return null; + } - } + } } diff --git a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Furnace.java b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Furnace.java index d9f657a..6182819 100644 --- a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Furnace.java +++ b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Furnace.java @@ -4,6 +4,7 @@ import static modtweaker2.helpers.InputHelper.toStack; import minetweaker.IUndoableAction; import minetweaker.MineTweakerAPI; import minetweaker.api.item.IItemStack; +import modtweaker2.utils.TweakerPlugin; import net.minecraft.item.ItemStack; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; @@ -12,121 +13,125 @@ import cofh.thermalexpansion.util.crafting.FurnaceManager.RecipeFurnace; @ZenClass("mods.thermalexpansion.Furnace") public class Furnace { - @ZenMethod - public static void addRecipe(int energy, IItemStack input, IItemStack output) { - MineTweakerAPI.apply(new Add(energy, toStack(input), toStack(output))); - } + @ZenMethod + public static void addRecipe(int energy, IItemStack input, IItemStack output) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new Add(energy, toStack(input), toStack(output))); + } - private static class Add implements IUndoableAction { - ItemStack input; - ItemStack output; - int energy; - boolean applied = false; + private static class Add implements IUndoableAction { + ItemStack input; + ItemStack output; + int energy; + boolean applied = false; - public Add(int rf, ItemStack inp, ItemStack out) { - energy = rf; - input = inp; - output = out; - } + public Add(int rf, ItemStack inp, ItemStack out) { + energy = rf; + input = inp; + output = out; + } - public void apply() { - FurnaceManager.addRecipe(energy, input, output, false); - } + public void apply() { + FurnaceManager.addRecipe(energy, input, output, false); + } - public boolean canUndo() { - return input != null; - } + public boolean canUndo() { + return input != null; + } - public String describe() { - return "Adding Redstone Furnace Recipe using " + input.getDisplayName(); - } + public String describe() { + return "Adding Redstone Furnace Recipe using " + input.getDisplayName(); + } - public void undo() { - FurnaceManager.removeRecipe(input); - } + public void undo() { + FurnaceManager.removeRecipe(input); + } - public String describeUndo() { - return "Removing Redstone Furnace Recipe using " + input.getDisplayName(); - } + public String describeUndo() { + return "Removing Redstone Furnace Recipe using " + input.getDisplayName(); + } - public Object getOverrideKey() { - return null; - } + public Object getOverrideKey() { + return null; + } - } + } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - @ZenMethod - public static void removeRecipe(IItemStack input) { - MineTweakerAPI.apply(new Remove(toStack(input))); - } + @ZenMethod + public static void removeRecipe(IItemStack input) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new Remove(toStack(input))); + } - private static class Remove implements IUndoableAction { - ItemStack input; - RecipeFurnace removed; + private static class Remove implements IUndoableAction { + ItemStack input; + RecipeFurnace removed; - public Remove(ItemStack inp) { - input = inp; - } - public void apply() { - removed = FurnaceManager.getRecipe(input); - FurnaceManager.removeRecipe(input); - } + public Remove(ItemStack inp) { + input = inp; + } - public boolean canUndo() { - return removed != null; - } + public void apply() { + removed = FurnaceManager.getRecipe(input); + FurnaceManager.removeRecipe(input); + } - public String describe() { - return "Removing Redstone Furnace Recipe using " + input.getDisplayName(); - } + public boolean canUndo() { + return removed != null; + } - public void undo() { - FurnaceManager.addRecipe(removed.getEnergy(), removed.getInput(), removed.getOutput(), false); - } + public String describe() { + return "Removing Redstone Furnace Recipe using " + input.getDisplayName(); + } - public String describeUndo() { - return "Restoring Redstone Furnace Recipe using " + input.getDisplayName(); - } + public void undo() { + FurnaceManager.addRecipe(removed.getEnergy(), removed.getInput(), removed.getOutput(), false); + } - public Object getOverrideKey() { - return null; - } + public String describeUndo() { + return "Restoring Redstone Furnace Recipe using " + input.getDisplayName(); + } - } + public Object getOverrideKey() { + return null; + } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + } - @ZenMethod - public static void refreshRecipes() { - MineTweakerAPI.apply(new Refresh()); - } + // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - private static class Refresh implements IUndoableAction { + @ZenMethod + public static void refreshRecipes() { + MineTweakerAPI.apply(new Refresh()); + } - public void apply() { - FurnaceManager.loadRecipes(); - } + private static class Refresh implements IUndoableAction { - public boolean canUndo() { - return false; - } + public void apply() { + FurnaceManager.loadRecipes(); + } - public String describe() { - return "Refreshing Redstone Furnace Recipes"; - } + public boolean canUndo() { + return false; + } - public void undo() {} + public String describe() { + return "Refreshing Redstone Furnace Recipes"; + } - public String describeUndo() { - return "Can't Undo Redstone Furnace Refresh"; - } + public void undo() { + } - public Object getOverrideKey() { - return null; - } + public String describeUndo() { + return "Can't Undo Redstone Furnace Refresh"; + } - } + public Object getOverrideKey() { + return null; + } + + } } diff --git a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Pulverizer.java b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Pulverizer.java index dc0af73..25d93a1 100644 --- a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Pulverizer.java +++ b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Pulverizer.java @@ -4,6 +4,7 @@ import static modtweaker2.helpers.InputHelper.toStack; import minetweaker.IUndoableAction; import minetweaker.MineTweakerAPI; import minetweaker.api.item.IItemStack; +import modtweaker2.utils.TweakerPlugin; import net.minecraft.item.ItemStack; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; @@ -12,98 +13,101 @@ import cofh.thermalexpansion.util.crafting.PulverizerManager.RecipePulverizer; @ZenClass("mods.thermalexpansion.Pulverizer") public class Pulverizer { - @ZenMethod - public static void addRecipe(int energy, IItemStack input, IItemStack output) { - MineTweakerAPI.apply(new Add(energy, toStack(input), toStack(output), null, 0)); - } + @ZenMethod + public static void addRecipe(int energy, IItemStack input, IItemStack output) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new Add(energy, toStack(input), toStack(output), null, 0)); + } - @ZenMethod - public static void addRecipe(int energy, IItemStack input, IItemStack output, IItemStack secondary, int secondaryChance) { - MineTweakerAPI.apply(new Add(energy, toStack(input), toStack(output), toStack(secondary), secondaryChance)); - } + @ZenMethod + public static void addRecipe(int energy, IItemStack input, IItemStack output, IItemStack secondary, int secondaryChance) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new Add(energy, toStack(input), toStack(output), toStack(secondary), secondaryChance)); + } - private static class Add implements IUndoableAction { - ItemStack input; - ItemStack output; - ItemStack secondary; - int secondaryChance; - int energy; - boolean applied = false; + private static class Add implements IUndoableAction { + ItemStack input; + ItemStack output; + ItemStack secondary; + int secondaryChance; + int energy; + boolean applied = false; - public Add(int rf, ItemStack inp, ItemStack out, ItemStack sec, int chance) { - energy = rf; - input = inp; - output = out; - secondary = sec; - secondaryChance = chance; - } + public Add(int rf, ItemStack inp, ItemStack out, ItemStack sec, int chance) { + energy = rf; + input = inp; + output = out; + secondary = sec; + secondaryChance = chance; + } - public void apply() { - applied = PulverizerManager.addRecipe(energy, input, output, secondary, secondaryChance); - } + public void apply() { + applied = PulverizerManager.addRecipe(energy, input, output, secondary, secondaryChance); + } - public boolean canUndo() { - return input != null && applied; - } + public boolean canUndo() { + return input != null && applied; + } - public String describe() { - return "Adding Pulverizer Recipe using " + input.getDisplayName(); - } + public String describe() { + return "Adding Pulverizer Recipe using " + input.getDisplayName(); + } - public void undo() { - PulverizerManager.removeRecipe(input); - } + public void undo() { + PulverizerManager.removeRecipe(input); + } - public String describeUndo() { - return "Removing Pulverizer Recipe using " + input.getDisplayName(); - } + public String describeUndo() { + return "Removing Pulverizer Recipe using " + input.getDisplayName(); + } - public Object getOverrideKey() { - return null; - } + public Object getOverrideKey() { + return null; + } - } + } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - @ZenMethod - public static void removeRecipe(IItemStack input) { - MineTweakerAPI.apply(new Remove(toStack(input))); - } + @ZenMethod + public static void removeRecipe(IItemStack input) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new Remove(toStack(input))); + } - private static class Remove implements IUndoableAction { - ItemStack input; - RecipePulverizer removed; + private static class Remove implements IUndoableAction { + ItemStack input; + RecipePulverizer removed; - public Remove(ItemStack inp) { - input = inp; - } + public Remove(ItemStack inp) { + input = inp; + } - public void apply() { - removed = PulverizerManager.getRecipe(input); - PulverizerManager.removeRecipe(input); - } + public void apply() { + removed = PulverizerManager.getRecipe(input); + PulverizerManager.removeRecipe(input); + } - public boolean canUndo() { - return removed != null; - } + public boolean canUndo() { + return removed != null; + } - public String describe() { - return "Removing Pulverizer Recipe using " + input.getDisplayName(); - } + public String describe() { + return "Removing Pulverizer Recipe using " + input.getDisplayName(); + } - public void undo() { - PulverizerManager.addRecipe(removed.getEnergy(), removed.getInput(), removed.getPrimaryOutput(), removed.getSecondaryOutput(), removed.getSecondaryOutputChance()); - } + public void undo() { + PulverizerManager.addRecipe(removed.getEnergy(), removed.getInput(), removed.getPrimaryOutput(), removed.getSecondaryOutput(), removed.getSecondaryOutputChance()); + } - public String describeUndo() { - return "Restoring Pulverizer Recipe using " + input.getDisplayName(); - } + public String describeUndo() { + return "Restoring Pulverizer Recipe using " + input.getDisplayName(); + } - public Object getOverrideKey() { - return null; - } + public Object getOverrideKey() { + return null; + } - } + } } diff --git a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Sawmill.java b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Sawmill.java index 710f1a6..d596844 100644 --- a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Sawmill.java +++ b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Sawmill.java @@ -4,6 +4,7 @@ import static modtweaker2.helpers.InputHelper.toStack; import minetweaker.IUndoableAction; import minetweaker.MineTweakerAPI; import minetweaker.api.item.IItemStack; +import modtweaker2.utils.TweakerPlugin; import net.minecraft.item.ItemStack; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; @@ -12,98 +13,99 @@ import cofh.thermalexpansion.util.crafting.SawmillManager.RecipeSawmill; @ZenClass("mods.thermalexpansion.Sawmill") public class Sawmill { - @ZenMethod - public static void addRecipe(int energy, IItemStack input, IItemStack output) { - MineTweakerAPI.apply(new Add(energy, toStack(input), toStack(output), null, 0)); - } + @ZenMethod + public static void addRecipe(int energy, IItemStack input, IItemStack output) { + MineTweakerAPI.apply(new Add(energy, toStack(input), toStack(output), null, 0)); + } - @ZenMethod - public static void addRecipe(int energy, IItemStack input, IItemStack output, IItemStack secondary, int secondaryChance) { - MineTweakerAPI.apply(new Add(energy, toStack(input), toStack(output), toStack(secondary), secondaryChance)); - } + @ZenMethod + public static void addRecipe(int energy, IItemStack input, IItemStack output, IItemStack secondary, int secondaryChance) { + MineTweakerAPI.apply(new Add(energy, toStack(input), toStack(output), toStack(secondary), secondaryChance)); + } - private static class Add implements IUndoableAction { - ItemStack input; - ItemStack output; - ItemStack secondary; - int secondaryChance; - int energy; - boolean applied = false; + private static class Add implements IUndoableAction { + ItemStack input; + ItemStack output; + ItemStack secondary; + int secondaryChance; + int energy; + boolean applied = false; - public Add(int rf, ItemStack inp, ItemStack out, ItemStack sec, int chance) { - energy = rf; - input = inp; - output = out; - secondary = sec; - secondaryChance = chance; - } + public Add(int rf, ItemStack inp, ItemStack out, ItemStack sec, int chance) { + energy = rf; + input = inp; + output = out; + secondary = sec; + secondaryChance = chance; + } - public void apply() { - applied = SawmillManager.addRecipe(energy, input, output, secondary, secondaryChance); - } + public void apply() { + applied = SawmillManager.addRecipe(energy, input, output, secondary, secondaryChance); + } - public boolean canUndo() { - return input != null && applied; - } + public boolean canUndo() { + return input != null && applied; + } - public String describe() { - return "Adding Sawmill Recipe using " + input.getDisplayName(); - } + public String describe() { + return "Adding Sawmill Recipe using " + input.getDisplayName(); + } - public void undo() { - SawmillManager.removeRecipe(input); - } + public void undo() { + SawmillManager.removeRecipe(input); + } - public String describeUndo() { - return "Removing Sawmill Recipe using " + input.getDisplayName(); - } + public String describeUndo() { + return "Removing Sawmill Recipe using " + input.getDisplayName(); + } - public Object getOverrideKey() { - return null; - } + public Object getOverrideKey() { + return null; + } - } + } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - @ZenMethod - public static void removeRecipe(IItemStack input) { - MineTweakerAPI.apply(new Remove(toStack(input))); - } + @ZenMethod + public static void removeRecipe(IItemStack input) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new Remove(toStack(input))); + } - private static class Remove implements IUndoableAction { - ItemStack input; - RecipeSawmill removed; + private static class Remove implements IUndoableAction { + ItemStack input; + RecipeSawmill removed; - public Remove(ItemStack inp) { - input = inp; - } + public Remove(ItemStack inp) { + input = inp; + } - public void apply() { - removed = SawmillManager.getRecipe(input); - SawmillManager.removeRecipe(input); - } + public void apply() { + removed = SawmillManager.getRecipe(input); + SawmillManager.removeRecipe(input); + } - public boolean canUndo() { - return removed != null; - } + public boolean canUndo() { + return removed != null; + } - public String describe() { - return "Removing Sawmill Recipe using " + input.getDisplayName(); - } + public String describe() { + return "Removing Sawmill Recipe using " + input.getDisplayName(); + } - public void undo() { - SawmillManager.addRecipe(removed.getEnergy(), removed.getInput(), removed.getPrimaryOutput(), removed.getSecondaryOutput(), removed.getSecondaryOutputChance()); - } + public void undo() { + SawmillManager.addRecipe(removed.getEnergy(), removed.getInput(), removed.getPrimaryOutput(), removed.getSecondaryOutput(), removed.getSecondaryOutputChance()); + } - public String describeUndo() { - return "Restoring Sawmill Recipe using " + input.getDisplayName(); - } + public String describeUndo() { + return "Restoring Sawmill Recipe using " + input.getDisplayName(); + } - public Object getOverrideKey() { - return null; - } + public Object getOverrideKey() { + return null; + } - } + } } diff --git a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Smelter.java b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Smelter.java index 1a67ca4..54692e4 100644 --- a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Smelter.java +++ b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Smelter.java @@ -11,6 +11,7 @@ import minetweaker.api.item.IItemStack; import modtweaker2.mods.thermalexpansion.ThermalHelper; import modtweaker2.utils.BaseDescriptionAddition; import modtweaker2.utils.BaseDescriptionRemoval; +import modtweaker2.utils.TweakerPlugin; import net.minecraft.item.ItemStack; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; @@ -47,7 +48,8 @@ public class Smelter { ItemStack out1 = toStack(output); ItemStack out2 = toStack(output2); RecipeSmelter recipe = (RecipeSmelter) ThermalHelper.getTERecipe(ThermalHelper.smelterRecipe, in1, in2, out1, out2, chance, energy); - MineTweakerAPI.apply(new Add(in1, in2, recipe)); + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new Add(in1, in2, recipe)); } private static class Add extends BaseDescriptionAddition { @@ -93,7 +95,8 @@ public class Smelter { @ZenMethod public static void removeRecipe(IItemStack input, IItemStack input2) { - MineTweakerAPI.apply(new Remove(toStack(input), toStack(input2))); + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new Remove(toStack(input), toStack(input2))); } private static class Remove extends BaseDescriptionRemoval { diff --git a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Transposer.java b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Transposer.java index 3f20072..09ffac0 100644 --- a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Transposer.java +++ b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Transposer.java @@ -13,6 +13,7 @@ import minetweaker.api.liquid.ILiquidStack; import modtweaker2.mods.thermalexpansion.ThermalHelper; import modtweaker2.utils.BaseDescriptionAddition; import modtweaker2.utils.BaseDescriptionRemoval; +import modtweaker2.utils.TweakerPlugin; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import stanhebben.zenscript.annotations.ZenClass; @@ -22,158 +23,162 @@ import cofh.thermalexpansion.util.crafting.TransposerManager.RecipeTransposer; @ZenClass("mods.thermalexpansion.Transposer") public class Transposer { - private static boolean removeValidated(ComparableItemStackSafe stack) { - //Check if there is a recipe that requires this in the validation set for filling - for (Map.Entry entry : ThermalHelper.getFillMap().entrySet()) { - RecipeTransposer recipe = (RecipeTransposer) entry.getValue(); - if (stack.equals(new ComparableItemStackSafe(recipe.getInput()))) { - return false; - } - } + private static boolean removeValidated(ComparableItemStackSafe stack) { + // Check if there is a recipe that requires this in the validation set + // for filling + for (Map.Entry entry : ThermalHelper.getFillMap().entrySet()) { + RecipeTransposer recipe = (RecipeTransposer) entry.getValue(); + if (stack.equals(new ComparableItemStackSafe(recipe.getInput()))) { + return false; + } + } - //Check if there is a recipe that requires this in the validation set for extracting - for (Map.Entry entry : ThermalHelper.getExtractMap().entrySet()) { - RecipeTransposer recipe = (RecipeTransposer) entry.getValue(); - if (stack.equals(new ComparableItemStackSafe(recipe.getInput()))) { - return false; - } - } + // Check if there is a recipe that requires this in the validation set + // for extracting + for (Map.Entry entry : ThermalHelper.getExtractMap().entrySet()) { + RecipeTransposer recipe = (RecipeTransposer) entry.getValue(); + if (stack.equals(new ComparableItemStackSafe(recipe.getInput()))) { + return false; + } + } - return ThermalHelper.transposerValid.remove(stack); - } + return ThermalHelper.transposerValid.remove(stack); + } - @ZenMethod - public static void addFillRecipe(int energy, IItemStack input, IItemStack output, ILiquidStack liquid) { - addRecipe(energy, input, output, liquid, 100, true); - } + @ZenMethod + public static void addFillRecipe(int energy, IItemStack input, IItemStack output, ILiquidStack liquid) { + addRecipe(energy, input, output, liquid, 100, true); + } - @ZenMethod - public static void addExtractRecipe(int energy, IItemStack input, IItemStack output, ILiquidStack liquid, int chance) { - addRecipe(energy, input, output, liquid, chance, false); - } + @ZenMethod + public static void addExtractRecipe(int energy, IItemStack input, IItemStack output, ILiquidStack liquid, int chance) { + addRecipe(energy, input, output, liquid, chance, false); + } - @ZenMethod - public static void addRecipe(int energy, IItemStack input, IItemStack output, ILiquidStack liquid, int chance, boolean isFillRecipe) { - ItemStack in = toStack(input); - ItemStack out = toStack(output); - FluidStack fluid = toFluid(liquid); - RecipeTransposer recipe = (RecipeTransposer) ThermalHelper.getTERecipe(ThermalHelper.transposerRecipe, in, out, fluid, energy, chance); - MineTweakerAPI.apply(new Add(in, fluid, recipe, isFillRecipe)); - } + @ZenMethod + public static void addRecipe(int energy, IItemStack input, IItemStack output, ILiquidStack liquid, int chance, boolean isFillRecipe) { + ItemStack in = toStack(input); + ItemStack out = toStack(output); + FluidStack fluid = toFluid(liquid); + RecipeTransposer recipe = (RecipeTransposer) ThermalHelper.getTERecipe(ThermalHelper.transposerRecipe, in, out, fluid, energy, chance); + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new Add(in, fluid, recipe, isFillRecipe)); + } - private static class Add extends BaseDescriptionAddition { - private List key; - private boolean isFillRecipe; - private final ComparableItemStackSafe input; - private final RecipeTransposer recipe; + private static class Add extends BaseDescriptionAddition { + private List key; + private boolean isFillRecipe; + private final ComparableItemStackSafe input; + private final RecipeTransposer recipe; - public Add(ItemStack input, FluidStack fluid, RecipeTransposer recipe, boolean isFillRecipe) { - super("Transposer"); - this.isFillRecipe = isFillRecipe; - this.input = new ComparableItemStackSafe(input); + public Add(ItemStack input, FluidStack fluid, RecipeTransposer recipe, boolean isFillRecipe) { + super("Transposer"); + this.isFillRecipe = isFillRecipe; + this.input = new ComparableItemStackSafe(input); - this.recipe = recipe; - if (this.isFillRecipe) { - this.key = Arrays.asList(new Integer[] { Integer.valueOf(new ComparableItemStackSafe(input).hashCode()), Integer.valueOf(fluid.fluidID) }); - } - } + this.recipe = recipe; + if (this.isFillRecipe) { + this.key = Arrays.asList(new Integer[] { Integer.valueOf(new ComparableItemStackSafe(input).hashCode()), Integer.valueOf(fluid.fluidID) }); + } + } - @Override - public void apply() { - if (isFillRecipe) { - ThermalHelper.getFillMap().put(key, recipe); - } else { - ThermalHelper.getExtractMap().put(input, recipe); - } + @Override + public void apply() { + if (isFillRecipe) { + ThermalHelper.getFillMap().put(key, recipe); + } else { + ThermalHelper.getExtractMap().put(input, recipe); + } - ThermalHelper.transposerValid.add(input); - } + ThermalHelper.transposerValid.add(input); + } - @Override - public boolean canUndo() { - return input != null; - } + @Override + public boolean canUndo() { + return input != null; + } - @Override - public void undo() { - if (isFillRecipe) { - ThermalHelper.getFillMap().remove(key); - } else { - ThermalHelper.getExtractMap().remove(input); - } + @Override + public void undo() { + if (isFillRecipe) { + ThermalHelper.getFillMap().remove(key); + } else { + ThermalHelper.getExtractMap().remove(input); + } - removeValidated(input); - } + removeValidated(input); + } - @Override - public String getRecipeInfo() { - return ((RecipeTransposer) recipe).getOutput().getDisplayName(); - } - } + @Override + public String getRecipeInfo() { + return ((RecipeTransposer) recipe).getOutput().getDisplayName(); + } + } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - @ZenMethod - public static void removeFillRecipe(IItemStack input, ILiquidStack liquid) { - removeRecipe(input, liquid, true); - } + // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + @ZenMethod + public static void removeFillRecipe(IItemStack input, ILiquidStack liquid) { + removeRecipe(input, liquid, true); + } - @ZenMethod - public static void removeExtractRecipe(IItemStack input) { - removeRecipe(input, null, false); - } + @ZenMethod + public static void removeExtractRecipe(IItemStack input) { + removeRecipe(input, null, false); + } - @ZenMethod - public static void removeRecipe(IItemStack input, ILiquidStack liquid, boolean isFillRecipe) { - MineTweakerAPI.apply(new Remove(toStack(input), toFluid(liquid), isFillRecipe)); - } + @ZenMethod + public static void removeRecipe(IItemStack input, ILiquidStack liquid, boolean isFillRecipe) { + if (!TweakerPlugin.hasInit()) + MineTweakerAPI.apply(new Remove(toStack(input), toFluid(liquid), isFillRecipe)); + } - private static class Remove extends BaseDescriptionRemoval { - private final boolean isFillRecipe; - private final ComparableItemStackSafe input; - private List key; - private RecipeTransposer recipe; + private static class Remove extends BaseDescriptionRemoval { + private final boolean isFillRecipe; + private final ComparableItemStackSafe input; + private List key; + private RecipeTransposer recipe; - public Remove(ItemStack input, FluidStack fluid, boolean isFillRecipe) { - super("Transposer"); - this.isFillRecipe = isFillRecipe; - this.input = new ComparableItemStackSafe(input); - if (this.isFillRecipe) { - this.key = Arrays.asList(new Integer[] { Integer.valueOf(new ComparableItemStackSafe(input).hashCode()), Integer.valueOf(fluid.fluidID) }); - } - } + public Remove(ItemStack input, FluidStack fluid, boolean isFillRecipe) { + super("Transposer"); + this.isFillRecipe = isFillRecipe; + this.input = new ComparableItemStackSafe(input); + if (this.isFillRecipe) { + this.key = Arrays.asList(new Integer[] { Integer.valueOf(new ComparableItemStackSafe(input).hashCode()), Integer.valueOf(fluid.fluidID) }); + } + } - @Override - public void apply() { - if (isFillRecipe) { - recipe = ThermalHelper.getFillMap().get(key); - ThermalHelper.getFillMap().remove(key); - } else { - recipe = ThermalHelper.getExtractMap().get(input); - ThermalHelper.getExtractMap().remove(input); - } + @Override + public void apply() { + if (isFillRecipe) { + recipe = ThermalHelper.getFillMap().get(key); + ThermalHelper.getFillMap().remove(key); + } else { + recipe = ThermalHelper.getExtractMap().get(input); + ThermalHelper.getExtractMap().remove(input); + } - removeValidated(input); - } + removeValidated(input); + } - @Override - public boolean canUndo() { - return input != null; - } + @Override + public boolean canUndo() { + return input != null; + } - @Override - public void undo() { - if (isFillRecipe) { - ThermalHelper.getFillMap().put(key, recipe); - } else { - ThermalHelper.getExtractMap().put(input, recipe); - } + @Override + public void undo() { + if (isFillRecipe) { + ThermalHelper.getFillMap().put(key, recipe); + } else { + ThermalHelper.getExtractMap().put(input, recipe); + } - ThermalHelper.transposerValid.add(input); - } + ThermalHelper.transposerValid.add(input); + } - @Override - public String getRecipeInfo() { - return input.toItemStack().getDisplayName(); - } - } + @Override + public String getRecipeInfo() { + return input.toItemStack().getDisplayName(); + } + } } diff --git a/src/main/java/modtweaker2/proxy/ClientProxy.java b/src/main/java/modtweaker2/proxy/ClientProxy.java new file mode 100644 index 0000000..03fc8f6 --- /dev/null +++ b/src/main/java/modtweaker2/proxy/ClientProxy.java @@ -0,0 +1,12 @@ +package modtweaker2.proxy; + +import modtweaker2.Commands; + +public class ClientProxy extends CommonProxy{ + + @Override + public void registerCommands() { + Commands.registerCommands(); + } + +} diff --git a/src/main/java/modtweaker2/proxy/CommonProxy.java b/src/main/java/modtweaker2/proxy/CommonProxy.java new file mode 100644 index 0000000..e25b202 --- /dev/null +++ b/src/main/java/modtweaker2/proxy/CommonProxy.java @@ -0,0 +1,11 @@ +package modtweaker2.proxy; + +import modtweaker2.Commands; + +public class CommonProxy { + + public void registerCommands(){ + Commands.registerCommands(); + } + +} diff --git a/src/main/java/modtweaker2/utils/TweakerPlugin.java b/src/main/java/modtweaker2/utils/TweakerPlugin.java index fd7bdae..cff464f 100644 --- a/src/main/java/modtweaker2/utils/TweakerPlugin.java +++ b/src/main/java/modtweaker2/utils/TweakerPlugin.java @@ -6,6 +6,8 @@ import cpw.mods.fml.common.Loader; public class TweakerPlugin { private static ArrayList isLoaded = new ArrayList(); + + public static boolean hasInit = false; public static void register(String mod, Class clazz) { if (Loader.isModLoaded(mod)) { @@ -25,4 +27,8 @@ public class TweakerPlugin { public static boolean isLoaded(String string) { return isLoaded.contains(string); } + + public static boolean hasInit(){ + return hasInit; + } } diff --git a/src/main/resources/tfc_at.cfg b/src/main/resources/tfc_at.cfg new file mode 100644 index 0000000..4fb1a16 --- /dev/null +++ b/src/main/resources/tfc_at.cfg @@ -0,0 +1,20 @@ +public net.minecraft.world.gen.ChunkProviderGenerate field_147430_m +public net.minecraft.world.gen.ChunkProviderGenerate field_73220_k +public net.minecraft.world.gen.ChunkProviderGenerate field_73230_p +public net.minecraft.world.gen.ChunkProviderGenerate func_147423_a(III)V +public net.minecraft.world.gen.ChunkProviderGenerate field_147434_q +public net.minecraft.world.WorldType (ILjava/lang/String;)V +public-f net.minecraft.world.WorldType field_77137_b #Default WorldType +public-f net.minecraft.world.WorldType field_77138_c #Flat WorldType +public-f net.minecraft.world.WorldType field_77135_d #LargeBiomes WorldType +public-f net.minecraft.world.WorldType field_151360_e #Amplified WorldType +protected net.minecraft.client.gui.inventory.GuiContainer func_146977_a(Lnet.minecraft.inventory.Slot;)V +public-f net.minecraft.init.Items field_151058_ca #Items.lead +public-f net.minecraft.init.Items field_151031_f #Items.bow +public net.minecraft.entity.player.EntityPlayer field_71076_b #sleepTimer +public-f net.minecraft.init.Blocks field_150431_aC #snow_layer +public net.minecraft.client.gui.inventory.GuiContainer func_146975_c(II)Lnet/minecraft/inventory/Slot; #getSlotAtPosition +public net.minecraft.client.gui.inventory.GuiContainer field_147003_i #guiLeft +public net.minecraft.client.gui.inventory.GuiContainer field_147009_r #guiTop +public net.minecraft.block.BlockDynamicLiquid func_149807_p(Lnet/minecraft/world/World;III)Z #displaceBlocks +public net.minecraft.entity.passive.EntityHorse field_110296_bG #horseChest \ No newline at end of file