diff --git a/src/compileHelper/java/naruto1310/extendedWorkbench/crafting/ExtendedCraftingManager.java b/src/compileHelper/java/naruto1310/extendedWorkbench/crafting/ExtendedCraftingManager.java index 468a004..2738e35 100644 --- a/src/compileHelper/java/naruto1310/extendedWorkbench/crafting/ExtendedCraftingManager.java +++ b/src/compileHelper/java/naruto1310/extendedWorkbench/crafting/ExtendedCraftingManager.java @@ -6,12 +6,12 @@ import net.minecraft.item.crafting.IRecipe; public class ExtendedCraftingManager { - public static final ExtendedCraftingManager getInstance() { - throw new UnsupportedOperationException(); - } + public static final ExtendedCraftingManager getInstance() { + throw new UnsupportedOperationException(); + } - public List getRecipeList() { - throw new UnsupportedOperationException(); - } + public List getRecipeList() { + throw new UnsupportedOperationException(); + } } diff --git a/src/compileHelper/java/naruto1310/extendedWorkbench/crafting/ExtendedShapedRecipes.java b/src/compileHelper/java/naruto1310/extendedWorkbench/crafting/ExtendedShapedRecipes.java index 21caf25..fa72306 100644 --- a/src/compileHelper/java/naruto1310/extendedWorkbench/crafting/ExtendedShapedRecipes.java +++ b/src/compileHelper/java/naruto1310/extendedWorkbench/crafting/ExtendedShapedRecipes.java @@ -6,24 +6,24 @@ import net.minecraft.world.World; public class ExtendedShapedRecipes implements IExtendedRecipe { - public ExtendedShapedRecipes(int width, int height, ItemStack[] recipe, ItemStack stack) { - throw new UnsupportedOperationException(); - } + public ExtendedShapedRecipes(int width, int height, ItemStack[] recipe, ItemStack stack) { + throw new UnsupportedOperationException(); + } - public boolean matches(InventoryCrafting inventory, World world) { - throw new UnsupportedOperationException(); - } + public boolean matches(InventoryCrafting inventory, World world) { + throw new UnsupportedOperationException(); + } - public ItemStack getCraftingResult(InventoryCrafting inventory) { - throw new UnsupportedOperationException(); - } + public ItemStack getCraftingResult(InventoryCrafting inventory) { + throw new UnsupportedOperationException(); + } - public int getRecipeSize() { - throw new UnsupportedOperationException(); - } + public int getRecipeSize() { + throw new UnsupportedOperationException(); + } - public ItemStack getRecipeOutput() { - throw new UnsupportedOperationException(); - } + public ItemStack getRecipeOutput() { + throw new UnsupportedOperationException(); + } } diff --git a/src/compileHelper/java/naruto1310/extendedWorkbench/crafting/ExtendedShapelessRecipes.java b/src/compileHelper/java/naruto1310/extendedWorkbench/crafting/ExtendedShapelessRecipes.java index d3fde08..f9cdc4a 100644 --- a/src/compileHelper/java/naruto1310/extendedWorkbench/crafting/ExtendedShapelessRecipes.java +++ b/src/compileHelper/java/naruto1310/extendedWorkbench/crafting/ExtendedShapelessRecipes.java @@ -8,24 +8,24 @@ import net.minecraft.world.World; public class ExtendedShapelessRecipes implements IExtendedRecipe { - public ExtendedShapelessRecipes(ItemStack output, List input) { - throw new UnsupportedOperationException(); - } + public ExtendedShapelessRecipes(ItemStack output, List input) { + throw new UnsupportedOperationException(); + } - public boolean matches(InventoryCrafting inventory, World world) { - throw new UnsupportedOperationException(); - } + public boolean matches(InventoryCrafting inventory, World world) { + throw new UnsupportedOperationException(); + } - public ItemStack getCraftingResult(InventoryCrafting inventory) { - throw new UnsupportedOperationException(); - } + public ItemStack getCraftingResult(InventoryCrafting inventory) { + throw new UnsupportedOperationException(); + } - public int getRecipeSize() { - throw new UnsupportedOperationException(); - } + public int getRecipeSize() { + throw new UnsupportedOperationException(); + } - public ItemStack getRecipeOutput() { - throw new UnsupportedOperationException(); - } + public ItemStack getRecipeOutput() { + throw new UnsupportedOperationException(); + } } diff --git a/src/main/java/modtweaker2/ClientEvents.java b/src/main/java/modtweaker2/ClientEvents.java index abcfb4f..d27961c 100644 --- a/src/main/java/modtweaker2/ClientEvents.java +++ b/src/main/java/modtweaker2/ClientEvents.java @@ -1,41 +1,43 @@ package modtweaker2; import static modtweaker2.helpers.LogHelper.print; + import minetweaker.api.item.IItemStack; import minetweaker.api.minecraft.MineTweakerMC; import minetweaker.api.player.IPlayer; + import net.minecraft.client.Minecraft; import net.minecraft.client.settings.GameSettings; import net.minecraftforge.event.entity.player.ItemTooltipEvent; + import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class ClientEvents { - public static int cooldown; - public static boolean active; - @SubscribeEvent - public void onDrawTooltip(ItemTooltipEvent event) { + public static int cooldown; + public static boolean active; - IPlayer player = MineTweakerMC.getIPlayer(event.entityPlayer); - if (player != null) { - IItemStack hand = MineTweakerMC.getIItemStack(event.itemStack); - if (hand != null) { - if (active) { + @SubscribeEvent + public void onDrawTooltip(ItemTooltipEvent event) { - String print = hand.toString(); - event.toolTip.add(print); - if (GameSettings.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindSprint)) { - if (cooldown <= 0) { - cooldown = 30; - print(print + " -- " + hand.getDisplayName()); - } else - cooldown--; - } else - cooldown--; - } + IPlayer player = MineTweakerMC.getIPlayer(event.entityPlayer); + if (player != null) { + IItemStack hand = MineTweakerMC.getIItemStack(event.itemStack); + if (hand != null) { + if (active) { - } - } - } + String print = hand.toString(); + event.toolTip.add(print); + if (GameSettings.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindSprint)) { + if (cooldown <= 0) { + cooldown = 30; + print(print + " -- " + hand.getDisplayName()); + } else cooldown--; + } else cooldown--; + } + + } + } + } } diff --git a/src/main/java/modtweaker2/Commands.java b/src/main/java/modtweaker2/Commands.java index 57a802b..e582cec 100644 --- a/src/main/java/modtweaker2/Commands.java +++ b/src/main/java/modtweaker2/Commands.java @@ -30,80 +30,174 @@ import modtweaker2.utils.TweakerPlugin; public class Commands { - public static void registerCommands() { - if (MineTweakerAPI.server != null) { + public static void registerCommands() { + 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( + "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() { - 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("appliedenergistics2-core")) { - MineTweakerAPI.server.addMineTweakerCommand("appeng", new String[] {"/minetweaker appeng [HANDLER]", " Outputs a list of all Applied Energistics 2 recipes."}, new AppliedEnergisticsLogger()); - } + @Override + public void execute(String[] arguments, IPlayer player) { + ClientEvents.active = !ClientEvents.active; + } + }); - if (TweakerPlugin.isLoaded("aura")) { - MineTweakerAPI.server.addMineTweakerCommand("auras", new String[] { "/minetweaker auras", "Outputs a list of Aura Types" }, new AuraLogger()); - } + 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("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("botaniaOrechid", new String[] { "/minetweaker botaniaOrechid", " Outputs a list of keys for botania orechid weights" }, new BotaniaOrechidLogger()); - MineTweakerAPI.server.addMineTweakerCommand("botania", new String[] { "/minetweaker botania [HANDLER]", " Outputs a list of all Botania recipes." }, new BotaniaLogger()); - } + if (TweakerPlugin.isLoaded("appliedenergistics2-core")) { + MineTweakerAPI.server.addMineTweakerCommand( + "appeng", + new String[] { "/minetweaker appeng [HANDLER]", + " Outputs a list of all Applied Energistics 2 recipes." }, + new AppliedEnergisticsLogger()); + } - if (TweakerPlugin.isLoaded("shadowfox_botany")) { - MineTweakerAPI.server.addMineTweakerCommand("treeCrafting", new String[] { "/minetweaker treeCrafting", " Outputs a list of all Botanical Addons Tree Crafting recipes." }, new BotanicalAddonsDendricLogger()); - } + 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("exnihilo")) { - MineTweakerAPI.server.addMineTweakerCommand("exnihilo", new String[] {"/minetweaker exnihilo [HANDLER]", " Outputs a list of all ExNihilo recipes."}, new ExNihiloLogger()); - } - - if (TweakerPlugin.isLoaded("factorization")) { - MineTweakerAPI.server.addMineTweakerCommand("factorization", new String[] {"/minetweaker factorization [HANDLER]", " Outputs a list of all Factorization recipes."}, new FactorizationLogger()); - } + 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( + "botaniaOrechid", + new String[] { "/minetweaker botaniaOrechid", + " Outputs a list of keys for botania orechid weights" }, + new BotaniaOrechidLogger()); + MineTweakerAPI.server.addMineTweakerCommand( + "botania", + new String[] { "/minetweaker botania [HANDLER]", " Outputs a list of all Botania recipes." }, + new BotaniaLogger()); + } - 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("mekanism", new String[] { "/minetweaker mekanism [HANDLER]", " Outputs a list of all Mekanism recipes." }, new MekanismLogger()); - } - - if (TweakerPlugin.isLoaded("Railcraft")) { - MineTweakerAPI.server.addMineTweakerCommand("railcraft", new String[] {"/minetweaker railcraft [HANDLER]", " Outputs a list of all Railcraft recipes."}, new RailcraftLogger()); - } + if (TweakerPlugin.isLoaded("shadowfox_botany")) { + MineTweakerAPI.server.addMineTweakerCommand( + "treeCrafting", + new String[] { "/minetweaker treeCrafting", + " Outputs a list of all Botanical Addons Tree Crafting recipes." }, + new BotanicalAddonsDendricLogger()); + } - 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()); - MineTweakerAPI.server.addMineTweakerCommand("modifiers", new String[] { "/minetweaker modifiers", " Outputs a list of all Tinker's Construct modifier names in the game to the minetweaker log" }, new ModifierLogger()); - MineTweakerAPI.server.addMineTweakerCommand("tconstruct", new String[]{ "/minetweaker tconstruct [HANDLER]", " Outputs a list of all Tinkers Construct recipes."}, new TConstructLogger()); - } + 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("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("ThermalExpansion")) { - MineTweakerAPI.server.addMineTweakerCommand("thermalexpansion", new String[] {"/minetweaker thermalexpansion [HANDLER]", " Outputs a list of all Thermal Expansion recipes."}, new ThermalExpansionLogger()); - } - } - } + if (TweakerPlugin.isLoaded("exnihilo")) { + MineTweakerAPI.server.addMineTweakerCommand( + "exnihilo", + new String[] { "/minetweaker exnihilo [HANDLER]", + " Outputs a list of all ExNihilo recipes." }, + new ExNihiloLogger()); + } - public static void registerMineTweakerCommand(String commandName, String[] usages, ICommandFunction commandFunction) { - MineTweakerAPI.server.addMineTweakerCommand(commandName, usages, commandFunction); - ModTweaker2.logger.info("\nRegistering command " + commandName + "."); - } + if (TweakerPlugin.isLoaded("factorization")) { + MineTweakerAPI.server.addMineTweakerCommand( + "factorization", + new String[] { "/minetweaker factorization [HANDLER]", + " Outputs a list of all Factorization recipes." }, + new FactorizationLogger()); + } + + 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( + "mekanism", + new String[] { "/minetweaker mekanism [HANDLER]", + " Outputs a list of all Mekanism recipes." }, + new MekanismLogger()); + } + + if (TweakerPlugin.isLoaded("Railcraft")) { + MineTweakerAPI.server.addMineTweakerCommand( + "railcraft", + new String[] { "/minetweaker railcraft [HANDLER]", + " Outputs a list of all Railcraft recipes." }, + new RailcraftLogger()); + } + + 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()); + MineTweakerAPI.server.addMineTweakerCommand( + "modifiers", + new String[] { "/minetweaker modifiers", + " Outputs a list of all Tinker's Construct modifier names in the game to the minetweaker log" }, + new ModifierLogger()); + MineTweakerAPI.server.addMineTweakerCommand( + "tconstruct", + new String[] { "/minetweaker tconstruct [HANDLER]", + " Outputs a list of all Tinkers Construct recipes." }, + new TConstructLogger()); + } + + 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("ThermalExpansion")) { + MineTweakerAPI.server.addMineTweakerCommand( + "thermalexpansion", + new String[] { "/minetweaker thermalexpansion [HANDLER]", + " Outputs a list of all Thermal Expansion recipes." }, + new ThermalExpansionLogger()); + } + } + } + + public static void registerMineTweakerCommand(String commandName, String[] usages, + ICommandFunction commandFunction) { + MineTweakerAPI.server.addMineTweakerCommand(commandName, usages, commandFunction); + ModTweaker2.logger.info("\nRegistering command " + commandName + "."); + } } diff --git a/src/main/java/modtweaker2/ModProps.java b/src/main/java/modtweaker2/ModProps.java index 5e92be7..6a9cea4 100644 --- a/src/main/java/modtweaker2/ModProps.java +++ b/src/main/java/modtweaker2/ModProps.java @@ -2,8 +2,9 @@ package modtweaker2; 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 = "GRADLETOKEN_VERSION", version = VERSION; - public static final String DEPENDENCIES = "required-after:MineTweaker3;after:Forestry@[4.1.0,);", dependencies = DEPENDENCIES; + public static final String NAME = "Mod Tweaker 2", name = NAME; + public static final String MODID = "modtweaker2", modid = MODID; + public static final String VERSION = "GRADLETOKEN_VERSION", version = VERSION; + public static final String DEPENDENCIES = "required-after:MineTweaker3;after:Forestry@[4.1.0,);", + dependencies = DEPENDENCIES; } diff --git a/src/main/java/modtweaker2/ModTweaker2.java b/src/main/java/modtweaker2/ModTweaker2.java index 522ed48..9e4a4f4 100644 --- a/src/main/java/modtweaker2/ModTweaker2.java +++ b/src/main/java/modtweaker2/ModTweaker2.java @@ -27,6 +27,7 @@ import modtweaker2.mods.thaumcraft.Thaumcraft; import modtweaker2.mods.thermalexpansion.ThermalExpansion; import modtweaker2.proxy.CommonProxy; import modtweaker2.utils.TweakerPlugin; + import net.minecraftforge.common.MinecraftForge; import org.apache.logging.log4j.LogManager; @@ -46,73 +47,72 @@ import cpw.mods.fml.relauncher.Side; @Mod(modid = ModProps.modid, version = ModProps.version, dependencies = ModProps.dependencies) public class ModTweaker2 { - public static Logger logger = LogManager.getLogger(ModProps.modid); + public static Logger logger = LogManager.getLogger(ModProps.modid); - public static File baseIMCFolder; - @Instance(ModProps.modid) - public ModTweaker2 instance; + public static File baseIMCFolder; + @Instance(ModProps.modid) + public ModTweaker2 instance; - @EventHandler - public void preInit(FMLPreInitializationEvent event) { - logger.info("Starting PreInitialization for " + ModProps.modid); - } + @EventHandler + 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; + @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); - TweakerPlugin.register("appliedenergistics2-core", AppliedEnergistics.class); - TweakerPlugin.register("Botania", Botania.class); - TweakerPlugin.register("shadowfox_botany", BotanicalAddons.class); - TweakerPlugin.register("exnihilo", ExNihilo.class); - TweakerPlugin.register("extendedWorkbench", ExtendedWorkbench.class); - TweakerPlugin.register("factorization", Factorization.class); - TweakerPlugin.register("Mariculture", Mariculture.class); - TweakerPlugin.register("Mekanism", Mekanism.class); - TweakerPlugin.register("Metallurgy", Metallurgy.class); - TweakerPlugin.register("PneumaticCraft", PneumaticCraft.class); - TweakerPlugin.register("Railcraft", Railcraft.class); - TweakerPlugin.register("TConstruct", TConstruct.class); - TweakerPlugin.register("Thaumcraft", Thaumcraft.class); - TweakerPlugin.register("ThermalExpansion", ThermalExpansion.class); - TweakerPlugin.register("Forestry", Forestry.class); - TweakerPlugin.register("chisel", Chisel.class); - TweakerPlugin.register("aura", AuraCascade.class); - TweakerPlugin.register("ExtraUtilities", ExtraUtils.class); - TweakerPlugin.register("IC2", IC2C.class); - + @EventHandler + public void init(FMLInitializationEvent event) { + logger.info("Starting Initialization for " + ModProps.modid); + TweakerPlugin.register("appliedenergistics2-core", AppliedEnergistics.class); + TweakerPlugin.register("Botania", Botania.class); + TweakerPlugin.register("shadowfox_botany", BotanicalAddons.class); + TweakerPlugin.register("exnihilo", ExNihilo.class); + TweakerPlugin.register("extendedWorkbench", ExtendedWorkbench.class); + TweakerPlugin.register("factorization", Factorization.class); + TweakerPlugin.register("Mariculture", Mariculture.class); + TweakerPlugin.register("Mekanism", Mekanism.class); + TweakerPlugin.register("Metallurgy", Metallurgy.class); + TweakerPlugin.register("PneumaticCraft", PneumaticCraft.class); + TweakerPlugin.register("Railcraft", Railcraft.class); + TweakerPlugin.register("TConstruct", TConstruct.class); + TweakerPlugin.register("Thaumcraft", Thaumcraft.class); + TweakerPlugin.register("ThermalExpansion", ThermalExpansion.class); + TweakerPlugin.register("Forestry", Forestry.class); + TweakerPlugin.register("chisel", Chisel.class); + TweakerPlugin.register("aura", AuraCascade.class); + TweakerPlugin.register("ExtraUtilities", ExtraUtils.class); + TweakerPlugin.register("IC2", IC2C.class); - if (FMLCommonHandler.instance().getSide() == Side.CLIENT) { - MinecraftForge.EVENT_BUS.register(new ClientEvents()); - } + if (FMLCommonHandler.instance().getSide() == Side.CLIENT) { + MinecraftForge.EVENT_BUS.register(new ClientEvents()); + } - MineTweakerImplementationAPI.onReloadEvent(new IEventHandler() { + MineTweakerImplementationAPI.onReloadEvent(new IEventHandler() { - @Override - public void handle(ReloadEvent event) { - proxy.registerCommands(); + @Override + public void handle(ReloadEvent event) { + proxy.registerCommands(); - } - }); + } + }); - File scripts = new File("scripts"); - if (!scripts.exists()) { - scripts.mkdir(); - } - MineTweakerImplementationAPI.setScriptProvider(new ScriptProviderDirectory(scripts)); - } + File scripts = new File("scripts"); + if (!scripts.exists()) { + scripts.mkdir(); + } + MineTweakerImplementationAPI.setScriptProvider(new ScriptProviderDirectory(scripts)); + } - @EventHandler - public void postInit(FMLPostInitializationEvent event) { - logger.info("Starting PostInitialization for " + ModProps.modid); - } + @EventHandler + public void postInit(FMLPostInitializationEvent event) { + logger.info("Starting PostInitialization for " + ModProps.modid); + } - @EventHandler - public void serverStart(FMLServerStartingEvent event) { - logger.info("Starting ServerStart for " + ModProps.modid); - proxy.registerCommands(); + @EventHandler + public void serverStart(FMLServerStartingEvent event) { + logger.info("Starting ServerStart for " + ModProps.modid); + proxy.registerCommands(); - } + } } diff --git a/src/main/java/modtweaker2/commands/EntityMappingLogger.java b/src/main/java/modtweaker2/commands/EntityMappingLogger.java index 309fb63..5af2215 100644 --- a/src/main/java/modtweaker2/commands/EntityMappingLogger.java +++ b/src/main/java/modtweaker2/commands/EntityMappingLogger.java @@ -7,26 +7,29 @@ import minetweaker.MineTweakerImplementationAPI; import minetweaker.api.player.IPlayer; import minetweaker.api.server.ICommandFunction; import modtweaker2.ModTweaker2; + import net.minecraft.entity.EntityList; public class EntityMappingLogger implements ICommandFunction { - @Override - public void execute(String[] arguments, IPlayer player) { + @Override + public void execute(String[] arguments, IPlayer player) { - @SuppressWarnings("unchecked") + @SuppressWarnings("unchecked") Set keys = EntityList.stringToIDMapping.keySet(); - - System.out.println("Mob Keys: " + keys.size()); - - for (Integer key : keys) { - ModTweaker2.logger.info("Mob Key " + EntityList.getStringFromID(key) + " : " + key); - MineTweakerAPI.logCommand("Mob Key " + EntityList.getStringFromID(key) + " : " + key); - } + System.out.println("Mob Keys: " + keys.size()); - if (player != null) { - player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir")); - } - } + for (Integer key : keys) { + ModTweaker2.logger.info("Mob Key " + EntityList.getStringFromID(key) + " : " + key); + MineTweakerAPI.logCommand("Mob Key " + EntityList.getStringFromID(key) + " : " + key); + + } + + if (player != null) { + player.sendChat( + MineTweakerImplementationAPI.platform + .getMessage("List generated; see minetweaker.log in your minecraft dir")); + } + } } diff --git a/src/main/java/modtweaker2/helpers/ForgeHelper.java b/src/main/java/modtweaker2/helpers/ForgeHelper.java index b196bea..7a1a458 100644 --- a/src/main/java/modtweaker2/helpers/ForgeHelper.java +++ b/src/main/java/modtweaker2/helpers/ForgeHelper.java @@ -13,11 +13,13 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import net.minecraftforge.common.ChestGenHooks; import net.minecraftforge.common.ForgeHooks; + import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.Side; public class ForgeHelper { + @SuppressWarnings("rawtypes") public static Map translate = null; @SuppressWarnings("rawtypes") @@ -28,16 +30,20 @@ public class ForgeHelper { try { seeds = getStaticObject(ForgeHooks.class, "seedList"); loot = getStaticObject(ChestGenHooks.class, "chestInfo"); - translate = getFinalObject(getStaticObject(StatCollector.class, "localizedName", "field_74839_a"), "languageList", "field_74816_c"); - } catch (Exception e) { } + translate = getFinalObject( + getStaticObject(StatCollector.class, "localizedName", "field_74839_a"), + "languageList", + "field_74816_c"); + } catch (Exception e) {} } - private ForgeHelper() { - } + private ForgeHelper() {} public static Object getSeedEntry(ItemStack stack, int weight) { - Object seedEntry = getInstance(getConstructor("net.minecraftforge.common.ForgeHooks$SeedEntry", - ItemStack.class, int.class), stack, weight); + Object seedEntry = getInstance( + getConstructor("net.minecraftforge.common.ForgeHooks$SeedEntry", ItemStack.class, int.class), + stack, + weight); if (seedEntry == null) { throw new NullPointerException("Failed to instantiate SeedEntry"); diff --git a/src/main/java/modtweaker2/helpers/InputHelper.java b/src/main/java/modtweaker2/helpers/InputHelper.java index 83a8fd7..c5982cf 100644 --- a/src/main/java/modtweaker2/helpers/InputHelper.java +++ b/src/main/java/modtweaker2/helpers/InputHelper.java @@ -10,6 +10,7 @@ import minetweaker.api.liquid.ILiquidStack; import minetweaker.api.oredict.IOreDictEntry; import minetweaker.mc1710.item.MCItemStack; import minetweaker.mc1710.liquid.MCLiquidStack; + import net.minecraft.entity.Entity; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; @@ -18,181 +19,173 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; public class InputHelper { - public static boolean isABlock(IItemStack block) { - if (!(isABlock(toStack(block)))) { - return false; - } else - return true; - } - - public static T[][] getMultiDimensionalArray(Class clazz, T[] array, int height, int width) { - - @SuppressWarnings("unchecked") - T[][] multiDim = (T[][])Array.newInstance(clazz, new int[] {height, width}); - - for(int y = 0; y < height; y++) { - for(int x = 0; x < width; x++) { - multiDim[y][x] = array[x + (y * width)]; - } - } - - return multiDim; - } - - public static IItemStack[] toStacks(IIngredient[] iIngredient) { - ArrayList stacks = new ArrayList(); - - for (IIngredient ing : iIngredient) { - for (IItemStack stack : ing.getItems()) { - stacks.add(stack); - } - } - - return stacks.toArray(new IItemStack[stacks.size()]); - } - public static boolean isABlock(ItemStack block) { - return block.getItem() instanceof ItemBlock; - } + public static boolean isABlock(IItemStack block) { + if (!(isABlock(toStack(block)))) { + return false; + } else return true; + } - public static Entity toEntity(IEntity iEntity) { - return null; - } + public static T[][] getMultiDimensionalArray(Class clazz, T[] array, int height, int width) { - public static ItemStack toStack(IItemStack iStack) { - if (iStack == null) { - return null; - } else { - Object internal = iStack.getInternal(); - if (!(internal instanceof ItemStack)) { - LogHelper.logError("Not a valid item stack: " + iStack); - } + @SuppressWarnings("unchecked") + T[][] multiDim = (T[][]) Array.newInstance(clazz, new int[] { height, width }); - return (ItemStack) internal; - } - } - - public static IIngredient toIngredient(ItemStack stack) { + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) { + multiDim[y][x] = array[x + (y * width)]; + } + } + + return multiDim; + } + + public static IItemStack[] toStacks(IIngredient[] iIngredient) { + ArrayList stacks = new ArrayList(); + + for (IIngredient ing : iIngredient) { + for (IItemStack stack : ing.getItems()) { + stacks.add(stack); + } + } + + return stacks.toArray(new IItemStack[stacks.size()]); + } + + public static boolean isABlock(ItemStack block) { + return block.getItem() instanceof ItemBlock; + } + + public static Entity toEntity(IEntity iEntity) { + return null; + } + + public static ItemStack toStack(IItemStack iStack) { + if (iStack == null) { + return null; + } else { + Object internal = iStack.getInternal(); + if (!(internal instanceof ItemStack)) { + LogHelper.logError("Not a valid item stack: " + iStack); + } + + return (ItemStack) internal; + } + } + + public static IIngredient toIngredient(ItemStack stack) { return toIItemStack(stack); - } - - public static IIngredient toIngredient(FluidStack stack) { - if(stack == null) { - return null; - } - - return new MCLiquidStack(stack); - } - - public static IItemStack toIItemStack(ItemStack stack) { - if(stack == null) { - return null; - } - - return new MCItemStack(stack); - } - - public static ILiquidStack toILiquidStack(FluidStack stack) { - if(stack == null) { - return null; - } - - return new MCLiquidStack(stack); - } + } - public static ItemStack[] toStacks(IItemStack[] iStack) { - if (iStack == null) { - return null; - } else { - ItemStack[] output = new ItemStack[iStack.length]; - for (int i = 0; i < iStack.length; i++) { - output[i] = toStack(iStack[i]); - } + public static IIngredient toIngredient(FluidStack stack) { + if (stack == null) { + return null; + } - return output; - } - } + return new MCLiquidStack(stack); + } - public static Object toObject(IIngredient iStack) { - if (iStack == null) - return null; - else { - if (iStack instanceof IOreDictEntry) { - return toString((IOreDictEntry) iStack); - } else if (iStack instanceof IItemStack) { - return toStack((IItemStack) iStack); - } else - return null; - } - } + public static IItemStack toIItemStack(ItemStack stack) { + if (stack == null) { + return null; + } - public static Object[] toObjects(IIngredient[] ingredient) { - if (ingredient == null) - return null; - else { - Object[] output = new Object[ingredient.length]; - for (int i = 0; i < ingredient.length; i++) { - if (ingredient[i] != null) { - output[i] = toObject(ingredient[i]); - } else - output[i] = ""; - } + return new MCItemStack(stack); + } - return output; - } - } + public static ILiquidStack toILiquidStack(FluidStack stack) { + if (stack == null) { + return null; + } - @SuppressWarnings({ "rawtypes", "unchecked" }) + return new MCLiquidStack(stack); + } + + public static ItemStack[] toStacks(IItemStack[] iStack) { + if (iStack == null) { + return null; + } else { + ItemStack[] output = new ItemStack[iStack.length]; + for (int i = 0; i < iStack.length; i++) { + output[i] = toStack(iStack[i]); + } + + return output; + } + } + + public static Object toObject(IIngredient iStack) { + if (iStack == null) return null; + else { + if (iStack instanceof IOreDictEntry) { + return toString((IOreDictEntry) iStack); + } else if (iStack instanceof IItemStack) { + return toStack((IItemStack) iStack); + } else return null; + } + } + + public static Object[] toObjects(IIngredient[] ingredient) { + if (ingredient == null) return null; + else { + Object[] output = new Object[ingredient.length]; + for (int i = 0; i < ingredient.length; i++) { + if (ingredient[i] != null) { + output[i] = toObject(ingredient[i]); + } else output[i] = ""; + } + + return output; + } + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) public static Object[] toShapedObjects(IIngredient[][] ingredients) { - if (ingredients == null) - return null; - else { - ArrayList prep = new ArrayList(); - prep.add("abc"); - prep.add("def"); - prep.add("ghi"); - char[][] map = new char[][]{{'a', 'b', 'c'}, {'d', 'e', 'f'}, {'g', 'h', 'i'}}; - for (int x = 0; x < ingredients.length; x++) { - if (ingredients[x] != null) { - for (int y = 0; y < ingredients[x].length; y++) { - if (ingredients[x][y] != null && x < map.length && y < map[x].length) { - prep.add(map[x][y]); - prep.add(toObject(ingredients[x][y])); - } - } - } - } - return prep.toArray(); - } - } + if (ingredients == null) return null; + else { + ArrayList prep = new ArrayList(); + prep.add("abc"); + prep.add("def"); + prep.add("ghi"); + char[][] map = new char[][] { { 'a', 'b', 'c' }, { 'd', 'e', 'f' }, { 'g', 'h', 'i' } }; + for (int x = 0; x < ingredients.length; x++) { + if (ingredients[x] != null) { + for (int y = 0; y < ingredients[x].length; y++) { + if (ingredients[x][y] != null && x < map.length && y < map[x].length) { + prep.add(map[x][y]); + prep.add(toObject(ingredients[x][y])); + } + } + } + } + return prep.toArray(); + } + } - public static String toString(IOreDictEntry entry) { - return ((IOreDictEntry) entry).getName(); - } + public static String toString(IOreDictEntry entry) { + return ((IOreDictEntry) entry).getName(); + } - public static FluidStack toFluid(ILiquidStack iStack) { - if (iStack == null) { - return null; - } else - return FluidRegistry.getFluidStack(iStack.getName(), iStack.getAmount()); - } + public static FluidStack toFluid(ILiquidStack iStack) { + if (iStack == null) { + return null; + } else return FluidRegistry.getFluidStack(iStack.getName(), iStack.getAmount()); + } - public static Fluid getFluid(ILiquidStack iStack) { - if (iStack == null) { - return null; - } else - return FluidRegistry.getFluid(iStack.getName()); + public static Fluid getFluid(ILiquidStack iStack) { + if (iStack == null) { + return null; + } else return FluidRegistry.getFluid(iStack.getName()); - } + } - public static FluidStack[] toFluids(IIngredient[] input) { - return toFluids((IItemStack[]) input); - } + public static FluidStack[] toFluids(IIngredient[] input) { + return toFluids((IItemStack[]) input); + } - public static FluidStack[] toFluids(ILiquidStack[] iStack) { - FluidStack[] stack = new FluidStack[iStack.length]; - for (int i = 0; i < stack.length; i++) - stack[i] = toFluid(iStack[i]); - return stack; - } + public static FluidStack[] toFluids(ILiquidStack[] iStack) { + FluidStack[] stack = new FluidStack[iStack.length]; + for (int i = 0; i < stack.length; i++) stack[i] = toFluid(iStack[i]); + return stack; + } } diff --git a/src/main/java/modtweaker2/helpers/LogHelper.java b/src/main/java/modtweaker2/helpers/LogHelper.java index a92ead4..732a305 100644 --- a/src/main/java/modtweaker2/helpers/LogHelper.java +++ b/src/main/java/modtweaker2/helpers/LogHelper.java @@ -15,6 +15,7 @@ import modtweaker2.mods.mekanism.gas.MCGasStack; import modtweaker2.mods.thaumcraft.aspect.AspectStack; import modtweaker2.mods.thaumcraft.aspect.MCAspectStack; import modtweaker2.utils.TweakerPlugin; + import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; @@ -24,13 +25,17 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; + import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; public class LogHelper { + public static void logPrinted(IPlayer player) { if (player != null) { - player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir")); + player.sendChat( + MineTweakerImplementationAPI.platform + .getMessage("List generated; see minetweaker.log in your minecraft dir")); } } @@ -44,19 +49,19 @@ public class LogHelper { System.out.println(string); MineTweakerAPI.logCommand(string); } - + public static void logError(String message) { MineTweakerAPI.logError("[ModTweaker2] " + message); } - + public static void logError(String message, Throwable exception) { MineTweakerAPI.logError("[ModTweaker2] " + message, exception); } - + public static void logWarning(String message) { MineTweakerAPI.logWarning("[ModTweaker2] " + message); } - + public static void logInfo(String message) { MineTweakerAPI.logInfo("[ModTweaker2] " + message); } @@ -65,37 +70,37 @@ public class LogHelper { * Returns a string representation of the item which can also be used in scripts */ public static String getStackDescription(Object object) { - if(object instanceof IIngredient) { - return getStackDescription((IIngredient)object); + if (object instanceof IIngredient) { + return getStackDescription((IIngredient) object); } else if (object instanceof ItemStack) { - return new MCItemStack((ItemStack)object).toString(); + return new MCItemStack((ItemStack) object).toString(); } else if (object instanceof FluidStack) { return getStackDescription((FluidStack) object); } else if (object instanceof Block) { - return new MCItemStack(new ItemStack((Block)object, 1, 0)).toString(); + return new MCItemStack(new ItemStack((Block) object, 1, 0)).toString(); } else if (TweakerPlugin.isLoaded("Mekanism") && object instanceof GasStack) { - return new MCGasStack((GasStack)object).toString(); + return new MCGasStack((GasStack) object).toString(); } else if (TweakerPlugin.isLoaded("Thaumcraft") && object instanceof AspectStack) { - return new MCAspectStack((AspectStack)object).toString(); - } else if(TweakerPlugin.isLoaded("Thaumcraft") && object instanceof AspectList) { + return new MCAspectStack((AspectStack) object).toString(); + } else if (TweakerPlugin.isLoaded("Thaumcraft") && object instanceof AspectList) { List stacks = new LinkedList(); - for(Aspect a : ((AspectList)object).getAspects()) { - stacks.add(new AspectStack(a, ((AspectList)object).getAmount(a))); + for (Aspect a : ((AspectList) object).getAspects()) { + stacks.add(new AspectStack(a, ((AspectList) object).getAmount(a))); } - return(getListDescription(stacks)); + return (getListDescription(stacks)); } else if (object instanceof String) { // Check if string specifies an oredict entry - List ores = OreDictionary.getOres((String)object); + List ores = OreDictionary.getOres((String) object); - if(!ores.isEmpty()) { - return ""; + if (!ores.isEmpty()) { + return ""; } else { - return "\"" + (String)object + "\""; + return "\"" + (String) object + "\""; } } else if (object instanceof List) { - return getListDescription((List)object); - } else if(object instanceof Object[]) { - return getListDescription(Arrays.asList((Object[])object)); + return getListDescription((List) object); + } else if (object instanceof Object[]) { + return getListDescription(Arrays.asList((Object[]) object)); } else if (object != null) { return "\"" + object.toString() + "\""; } else { @@ -119,49 +124,45 @@ public class LogHelper { public static String getStackDescription(FluidStack stack) { StringBuilder sb = new StringBuilder(); - + sb.append("'); - - if(stack.amount > 1) { + + if (stack.amount > 1) { sb.append(" * ").append(stack.amount); } - + return sb.toString(); } - + public static String getListDescription(List objects) { StringBuilder sb = new StringBuilder(); - - if(objects.isEmpty()) { + + if (objects.isEmpty()) { sb.append("[]"); } else { sb.append('['); - for(Object object : objects) { - if(object instanceof List) { - sb.append(getListDescription((List)object)).append(", "); - } else if(object instanceof Object[]) { - sb.append(getListDescription(Arrays.asList((Object[])object))).append(", "); - } else { + for (Object object : objects) { + if (object instanceof List) { + sb.append(getListDescription((List) object)).append(", "); + } else if (object instanceof Object[]) { + sb.append(getListDescription(Arrays.asList((Object[]) object))).append(", "); + } else { sb.append(getStackDescription(object)).append(", "); } } sb.setLength(sb.length() - 2); sb.append(']'); } - + return sb.toString(); } public static String getCraftingDescription(IRecipe recipe) { - if(recipe instanceof ShapelessOreRecipe) - return LogHelper.getCraftingDescription((ShapelessOreRecipe)recipe); - else if(recipe instanceof ShapedOreRecipe) - return LogHelper.getCraftingDescription((ShapedOreRecipe)recipe); - else if(recipe instanceof ShapelessRecipes) - return LogHelper.getCraftingDescription((ShapelessRecipes)recipe); - else if(recipe instanceof ShapedRecipes) - return LogHelper.getCraftingDescription((ShapedRecipes)recipe); - + if (recipe instanceof ShapelessOreRecipe) return LogHelper.getCraftingDescription((ShapelessOreRecipe) recipe); + else if (recipe instanceof ShapedOreRecipe) return LogHelper.getCraftingDescription((ShapedOreRecipe) recipe); + else if (recipe instanceof ShapelessRecipes) return LogHelper.getCraftingDescription((ShapelessRecipes) recipe); + else if (recipe instanceof ShapedRecipes) return LogHelper.getCraftingDescription((ShapedRecipes) recipe); + return recipe.toString(); } @@ -176,14 +177,15 @@ public class LogHelper { public static String getCraftingDescription(ShapedOreRecipe recipe) { int height = ReflectionHelper.getObject(recipe, "width"); int width = ReflectionHelper.getObject(recipe, "height"); - + Object[][] recipes = InputHelper.getMultiDimensionalArray(Object.class, recipe.getInput(), height, width); - + return getListDescription(Arrays.asList(recipes)); } public static String getCraftingDescription(ShapedRecipes recipe) { - ItemStack[][] recipes = InputHelper.getMultiDimensionalArray(ItemStack.class, recipe.recipeItems, recipe.recipeHeight, recipe.recipeWidth); + ItemStack[][] recipes = InputHelper + .getMultiDimensionalArray(ItemStack.class, recipe.recipeItems, recipe.recipeHeight, recipe.recipeWidth); return getListDescription(Arrays.asList(recipes)); } } diff --git a/src/main/java/modtweaker2/helpers/ReflectionHelper.java b/src/main/java/modtweaker2/helpers/ReflectionHelper.java index 73fb3c5..11086f3 100644 --- a/src/main/java/modtweaker2/helpers/ReflectionHelper.java +++ b/src/main/java/modtweaker2/helpers/ReflectionHelper.java @@ -5,46 +5,53 @@ import java.lang.reflect.Field; import java.lang.reflect.Modifier; public class ReflectionHelper { - + /** * Creates a new instance with the provided constructor and arguments. + * * @param constructor The constructor of the class for which a new instance should be created. - * @param arguments Array of objects to be passed as arguments to the constructor call. + * @param arguments Array of objects to be passed as arguments to the constructor call. * @return A new object created by calling the constructor. */ public static T getInstance(Constructor constructor, Object... arguments) { try { return constructor.newInstance(arguments); - } catch (Exception e) { LogHelper.logError("Exception creating instance of " + constructor.getClass().getName(), e); } + } catch (Exception e) { + LogHelper.logError("Exception creating instance of " + constructor.getClass().getName(), e); + } return null; } - + /** * Obtains the constructor for the named class identified by the parameter types. - * @param className The fully qualified name of the class. + * + * @param className The fully qualified name of the class. * @param argumentTypes Parameter types to identify the constructor. * @return Constructor object representing the declared constructor for the parameter types. */ public static Constructor getConstructor(final String className, final Class... argumentTypes) { - if(className == null || argumentTypes == null) { + if (className == null || argumentTypes == null) { LogHelper.logError("The provided class name or arguments can't be null."); return null; } - + try { Class clazz = Class.forName(className); Constructor constructor = clazz.getDeclaredConstructor(argumentTypes); constructor.setAccessible(true); return constructor; - } catch (Exception ex) { LogHelper.logError("Exception getting constructor of " + className, ex); } + } catch (Exception ex) { + LogHelper.logError("Exception getting constructor of " + className, ex); + } return null; } - + /** * Obtains the constructor for the class identified by the parameter types. - * @param clazz The Class for which the constructor should be obtained. + * + * @param clazz The Class for which the constructor should be obtained. * @param argumentTypes Parameter types to identify the constructor. * @return Constructor object representing the declared constructor for the parameter types. */ @@ -53,16 +60,19 @@ public class ReflectionHelper { Constructor constructor = clazz.getDeclaredConstructor(types); constructor.setAccessible(true); return constructor; - } catch (Exception ex) { LogHelper.logError("Exception getting constructor of " + clazz.getName(), ex); } + } catch (Exception ex) { + LogHelper.logError("Exception getting constructor of " + clazz.getName(), ex); + } return null; } /** * Returns the value of a private field for an object instance. - * @param object An object instance from which the field value is to be extracted. - * @param fieldNames A list of field names for which the value should be extracted. - * The functions returns value of the first field found. + * + * @param object An object instance from which the field value is to be extracted. + * @param fieldNames A list of field names for which the value should be extracted. The functions returns value of + * the first field found. * @return The value of the provided field name. */ @SuppressWarnings("unchecked") @@ -73,19 +83,22 @@ public class ReflectionHelper { Field result = cls.getDeclaredField(field); result.setAccessible(true); return (T) result.get(object); - } catch (Exception ex) { LogHelper.logError("Exception in getObject()", ex); } + } catch (Exception ex) { + LogHelper.logError("Exception in getObject()", ex); + } } LogHelper.logError("Could not retrieve any object for the provided field names."); - + return null; } /** * Returns the value of a private final field for an object instance and removes the final modifier. - * @param object An object instance from which the field value is to be extracted. - * @param fieldNames A list of field names for which the value should be extracted. - * The functions returns value of the first field found. + * + * @param object An object instance from which the field value is to be extracted. + * @param fieldNames A list of field names for which the value should be extracted. The functions returns value of + * the first field found. * @return The value of the provided field name. */ @SuppressWarnings("unchecked") @@ -99,17 +112,20 @@ public class ReflectionHelper { modifiersField.setAccessible(true); modifiersField.setInt(result, result.getModifiers() & ~Modifier.FINAL); return (T) result.get(object); - } catch (Exception ex) { LogHelper.logError("Exception in getFinalObject()", ex); } + } catch (Exception ex) { + LogHelper.logError("Exception in getFinalObject()", ex); + } } - + LogHelper.logError("Could not retrieve any final object for the provided field names."); - + return null; } /** * Returns the value of a private static field for a class. - * @param clazz The class for which the field value is to be extracted. + * + * @param clazz The class for which the field value is to be extracted. * @param fieldNames A list of field names for which the value should be extracted. * @return The value of the provided field name. */ @@ -120,17 +136,20 @@ public class ReflectionHelper { Field result = clazz.getDeclaredField(field); result.setAccessible(true); return (T) result.get(null); - } catch (Exception e) { LogHelper.logError("Exception in getStaticObject()", e); } + } catch (Exception e) { + LogHelper.logError("Exception in getStaticObject()", e); + } } - + LogHelper.logError("Could not retrieve any static object for the provided field names."); return null; } - + /** * Returns the value of a private static field for a class. - * @param className The fully qualified name of the class. + * + * @param className The fully qualified name of the class. * @param fieldNames A list of field names for which the value should be extracted. * @return The value of the provided field name. */ @@ -138,10 +157,12 @@ public class ReflectionHelper { try { Class clazz = Class.forName(className); return getStaticObject(clazz, fieldNames); - } catch (ClassNotFoundException e) { LogHelper.logError("Exception in getStaticObject()", e); } - + } catch (ClassNotFoundException e) { + LogHelper.logError("Exception in getStaticObject()", e); + } + LogHelper.logError("Could not retrieve any static object for the provided field names."); - + return null; } @@ -150,11 +171,13 @@ public class ReflectionHelper { Field f = cls.getDeclaredField(field); f.setAccessible(true); f.setInt(null, var); - } catch (Exception e) { LogHelper.logError("Exception in setPrivateValue()", e); } + } catch (Exception e) { + LogHelper.logError("Exception in setPrivateValue()", e); + } } - + @SuppressWarnings({ "rawtypes", "unchecked" }) - public static void setPrivateValue( Class cls, Object o, String field, Object var) { + public static void setPrivateValue(Class cls, Object o, String field, Object var) { cpw.mods.fml.relauncher.ReflectionHelper.setPrivateValue(cls, o, var, field); } } diff --git a/src/main/java/modtweaker2/helpers/StackHelper.java b/src/main/java/modtweaker2/helpers/StackHelper.java index 2702254..cc37b5e 100644 --- a/src/main/java/modtweaker2/helpers/StackHelper.java +++ b/src/main/java/modtweaker2/helpers/StackHelper.java @@ -1,6 +1,7 @@ package modtweaker2.helpers; import static modtweaker2.helpers.InputHelper.toStack; + import minetweaker.api.item.IIngredient; import minetweaker.api.item.IItemStack; import minetweaker.api.item.IngredientAny; @@ -9,120 +10,122 @@ import modtweaker2.mods.botania.Botania; import modtweaker2.mods.mekanism.MekanismHelper; import modtweaker2.mods.mekanism.gas.IGasStack; import modtweaker2.utils.TweakerPlugin; + import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; public class StackHelper { + /** * Compares two ItemStack instances, trying to match the referenced item. */ - public static boolean areEqual(ItemStack stack1, ItemStack stack2) { - if (stack1 == null || stack2 == null) { - return false; - } else if (TweakerPlugin.isLoaded("Botania") && Botania.isSubtile(stack1) && Botania.isSubtile(stack2)) { - return Botania.subtileMatches(stack1, stack2); - } else { - return stack1.isItemEqual(stack2); - } - } - - public static boolean areEqual(FluidStack stack1, FluidStack stack2) { - if(stack1 == null || stack2 == null) { - return false; - } - - return stack1.isFluidEqual(stack2); - } - - /** - * Compares two ItemStack instances if they reference the same object or - * are both null. If false, the method areEqual() is called to check if the - * two instances reference the same item. - */ + public static boolean areEqual(ItemStack stack1, ItemStack stack2) { + if (stack1 == null || stack2 == null) { + return false; + } else if (TweakerPlugin.isLoaded("Botania") && Botania.isSubtile(stack1) && Botania.isSubtile(stack2)) { + return Botania.subtileMatches(stack1, stack2); + } else { + return stack1.isItemEqual(stack2); + } + } + + public static boolean areEqual(FluidStack stack1, FluidStack stack2) { + if (stack1 == null || stack2 == null) { + return false; + } + + return stack1.isFluidEqual(stack2); + } + + /** + * Compares two ItemStack instances if they reference the same object or are both null. If false, the method + * areEqual() is called to check if the two instances reference the same item. + */ public static boolean areEqualOrNull(ItemStack stack1, ItemStack stack2) { // Check if they reference the same object or are are both null - if(stack1 == stack2) { + if (stack1 == stack2) { return true; } - return(areEqual(stack1, stack2)); + return (areEqual(stack1, stack2)); } - + public static boolean areEqualOrNull(FluidStack stack1, FluidStack stack2) { // Check if they reference the same object or are are both null - if(stack1 == stack2) { + if (stack1 == stack2) { return true; } - - return(areEqual(stack1, stack2)); + + return (areEqual(stack1, stack2)); } - + /** - * Adds extra check to IIngredient matches() for Botania special flowers + * Adds extra check to IIngredient matches() for Botania special flowers */ public static boolean matches(IIngredient ingredient, IItemStack itemStack) { - if(ingredient == null) { + if (ingredient == null) { return false; } - - if(!ingredient.matches(itemStack)) { + + if (!ingredient.matches(itemStack)) { return false; } - + // Check for Botania special flowers - if(ingredient.getItems() != null && TweakerPlugin.isLoaded("Botania") && Botania.isSubtile(toStack(itemStack))) { - for(IItemStack item : ingredient.getItems()) { - if(areEqual(toStack(item), toStack(itemStack))) { + if (ingredient.getItems() != null && TweakerPlugin.isLoaded("Botania") + && Botania.isSubtile(toStack(itemStack))) { + for (IItemStack item : ingredient.getItems()) { + if (areEqual(toStack(item), toStack(itemStack))) { return true; } } } else { return true; } - + return false; } - + /** - * This function compares an ingredient with a fluid. MCLiquidStack.matches() function - * is currently broken in MineTweaker3, thus this function is only a workaround. + * This function compares an ingredient with a fluid. MCLiquidStack.matches() function is currently broken in + * MineTweaker3, thus this function is only a workaround. */ public static boolean matches(IIngredient ingredient, ILiquidStack liquidStack) { - if(ingredient == null) { + if (ingredient == null) { return false; } // Do we have a wildcard (<*>) ? - if(ingredient.matches(liquidStack)) { + if (ingredient.matches(liquidStack)) { return true; } - + // Does ingredient reference liquids? - if(ingredient.getLiquids() != null) { + if (ingredient.getLiquids() != null) { for (ILiquidStack liquid : ingredient.getLiquids()) { - if(InputHelper.toFluid(liquid).isFluidEqual(InputHelper.toFluid(liquidStack))) { + if (InputHelper.toFluid(liquid).isFluidEqual(InputHelper.toFluid(liquidStack))) { return true; } } } - + return false; } - + public static boolean matches(IIngredient ingredient, IGasStack gasStack) { - if(ingredient == null) { + if (ingredient == null) { return false; } - - if(ingredient == IngredientAny.INSTANCE) { + + if (ingredient == IngredientAny.INSTANCE) { return true; } - - if(ingredient instanceof IGasStack) { - return MekanismHelper.toGas((IGasStack)ingredient).isGasEqual(MekanismHelper.toGas(gasStack)); + + if (ingredient instanceof IGasStack) { + return MekanismHelper.toGas((IGasStack) ingredient).isGasEqual(MekanismHelper.toGas(gasStack)); } return false; } - + } diff --git a/src/main/java/modtweaker2/helpers/StringHelper.java b/src/main/java/modtweaker2/helpers/StringHelper.java index 945689e..de096ce 100644 --- a/src/main/java/modtweaker2/helpers/StringHelper.java +++ b/src/main/java/modtweaker2/helpers/StringHelper.java @@ -4,52 +4,53 @@ import java.util.List; import java.util.ListIterator; public class StringHelper { + public static List toLowerCase(List stringList) { ListIterator iterator = stringList.listIterator(); - - while(iterator.hasNext()) { + + while (iterator.hasNext()) { iterator.set(iterator.next().toLowerCase()); } - + return stringList; } - + public static String join(List list, String conjunction) { StringBuilder sb = new StringBuilder(); - - if(conjunction == null) { + + if (conjunction == null) { conjunction = ", "; } - - if(list != null && !list.isEmpty()) { - for(String string : list) { + + if (list != null && !list.isEmpty()) { + for (String string : list) { sb.append(string).append(conjunction); } - + sb.setLength(sb.length() - conjunction.length()); } - + return sb.toString(); } - + public static String wildcardToRegex(String expression) { - if(expression == null) return null; - + if (expression == null) return null; + StringBuilder sb = new StringBuilder(); sb.append('^'); - - for(int i = 0; i < expression.length(); i ++) { + + for (int i = 0; i < expression.length(); i++) { char c = expression.charAt(i); - - switch(c) { + + switch (c) { case '*': sb.append(".*"); break; case '?': sb.append('.'); break; - - case '(': + + case '(': case ')': case '[': case ']': @@ -67,7 +68,7 @@ public class StringHelper { break; } } - + sb.append('$'); return sb.toString(); } diff --git a/src/main/java/modtweaker2/mods/appeng/AppliedEnergistics.java b/src/main/java/modtweaker2/mods/appeng/AppliedEnergistics.java index 42ba6af..2953100 100644 --- a/src/main/java/modtweaker2/mods/appeng/AppliedEnergistics.java +++ b/src/main/java/modtweaker2/mods/appeng/AppliedEnergistics.java @@ -6,8 +6,8 @@ import modtweaker2.mods.appeng.handlers.Inscriber; public class AppliedEnergistics { - public AppliedEnergistics() { - MineTweakerAPI.registerClass(Inscriber.class); - MineTweakerAPI.registerClass(Grind.class); - } + public AppliedEnergistics() { + MineTweakerAPI.registerClass(Inscriber.class); + MineTweakerAPI.registerClass(Grind.class); + } } diff --git a/src/main/java/modtweaker2/mods/appeng/AppliedEnergisticsHelper.java b/src/main/java/modtweaker2/mods/appeng/AppliedEnergisticsHelper.java index c1579d1..c8d46d3 100644 --- a/src/main/java/modtweaker2/mods/appeng/AppliedEnergisticsHelper.java +++ b/src/main/java/modtweaker2/mods/appeng/AppliedEnergisticsHelper.java @@ -1,77 +1,79 @@ package modtweaker2.mods.appeng; import static modtweaker2.helpers.StackHelper.areEqualOrNull; + import net.minecraft.item.ItemStack; + import appeng.api.features.IGrinderEntry; import appeng.api.features.IInscriberRecipe; public class AppliedEnergisticsHelper { + /** * Compares two IInscriberRecipe objects, if they are the same or have the same inputs */ public static boolean equals(IInscriberRecipe r1, IInscriberRecipe r2) { - if(r1 == r2) { + if (r1 == r2) { return true; } - + if (r1 == null || r2 == null) { return false; } - if(!areEqualOrNull(r1.getTopOptional().orNull(), r2.getTopOptional().orNull())) { - return false; - } - - if(!areEqualOrNull(r1.getBottomOptional().orNull(), r2.getBottomOptional().orNull())) { - return false; - } - - if(r1.getInputs() == null && r2.getInputs() != null || r1.getInputs() != null && r2.getInputs() == null) { + if (!areEqualOrNull(r1.getTopOptional().orNull(), r2.getTopOptional().orNull())) { return false; } - - if(r1.getInputs() != null && r2.getInputs() != null) { - if(r1.getInputs().size() != r2.getInputs().size()) { + + if (!areEqualOrNull(r1.getBottomOptional().orNull(), r2.getBottomOptional().orNull())) { + return false; + } + + if (r1.getInputs() == null && r2.getInputs() != null || r1.getInputs() != null && r2.getInputs() == null) { + return false; + } + + if (r1.getInputs() != null && r2.getInputs() != null) { + if (r1.getInputs().size() != r2.getInputs().size()) { return false; } - + // Check if every item in recipe 1 is in recipe 2 - for(ItemStack i1 : r1.getInputs()) { + for (ItemStack i1 : r1.getInputs()) { boolean found = false; - - for(ItemStack i2 : r2.getInputs()) { - if(areEqualOrNull(i1, i2)) { + + for (ItemStack i2 : r2.getInputs()) { + if (areEqualOrNull(i1, i2)) { found = true; } } - - if(!found) { + + if (!found) { return false; } } } - + return true; } - + /** * Compares two IGrinderEntry objects, if they are the same or have the same inputs */ public static boolean equals(IGrinderEntry r1, IGrinderEntry r2) { - if(r1 == r2) { + if (r1 == r2) { return true; } - + if (r1 == null || r2 == null) { return false; } - - if(!areEqualOrNull(r1.getInput(), r2.getInput())) { + + if (!areEqualOrNull(r1.getInput(), r2.getInput())) { return false; } return true; } - } diff --git a/src/main/java/modtweaker2/mods/appeng/commands/AppliedEnergisticsLogger.java b/src/main/java/modtweaker2/mods/appeng/commands/AppliedEnergisticsLogger.java index 3fa9ef6..c8048c2 100644 --- a/src/main/java/modtweaker2/mods/appeng/commands/AppliedEnergisticsLogger.java +++ b/src/main/java/modtweaker2/mods/appeng/commands/AppliedEnergisticsLogger.java @@ -17,48 +17,57 @@ import appeng.api.features.IInscriberRecipe; public class AppliedEnergisticsLogger implements ICommandFunction { private static final List validArguments = new LinkedList(); - + static { validArguments.add("Grinder"); validArguments.add("Inscriber"); } - - @Override - public void execute(String[] arguments, IPlayer player) { - List args = StringHelper.toLowerCase(Arrays.asList(arguments)); - - if(!validArguments.containsAll(args)) { - if(player != null) { - player.sendChat(MineTweakerImplementationAPI.platform.getMessage("Invalid arguments for command. Valid arguments: " + StringHelper.join(validArguments, ", "))); - } - } else { - if(args.isEmpty() || args.contains("Grinder")) { - for(IGrinderEntry recipe : AEApi.instance().registries().grinder().getRecipes()) { - MineTweakerAPI.logCommand(String.format("mods.appeng.Grinder.addRecipe(%s, %s, %d, %s, %s, %s, %s);", - LogHelper.getStackDescription(recipe.getInput()), - LogHelper.getStackDescription(recipe.getOutput()), - recipe.getEnergyCost(), - LogHelper.getStackDescription(recipe.getOptionalOutput()), - recipe.getOptionalChance(), - LogHelper.getStackDescription(recipe.getSecondOptionalOutput()), - recipe.getSecondOptionalChance())); - } - } - - if(args.isEmpty() || args.contains("Inscriber")) { - for(IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes()) { - MineTweakerAPI.logCommand(String.format("mods.appeng.Inscriber.addRecipe(%s, %s, %s, %s, \"%s\");", - LogHelper.getListDescription(recipe.getInputs()), - LogHelper.getStackDescription(recipe.getTopOptional().orNull()), - LogHelper.getStackDescription(recipe.getBottomOptional().orNull()), - LogHelper.getStackDescription(recipe.getOutput()), - recipe.getProcessType().toString())); - } - } - - if (player != null) { - player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir")); - } - } - } + + @Override + public void execute(String[] arguments, IPlayer player) { + List args = StringHelper.toLowerCase(Arrays.asList(arguments)); + + if (!validArguments.containsAll(args)) { + if (player != null) { + player.sendChat( + MineTweakerImplementationAPI.platform.getMessage( + "Invalid arguments for command. Valid arguments: " + + StringHelper.join(validArguments, ", "))); + } + } else { + if (args.isEmpty() || args.contains("Grinder")) { + for (IGrinderEntry recipe : AEApi.instance().registries().grinder().getRecipes()) { + MineTweakerAPI.logCommand( + String.format( + "mods.appeng.Grinder.addRecipe(%s, %s, %d, %s, %s, %s, %s);", + LogHelper.getStackDescription(recipe.getInput()), + LogHelper.getStackDescription(recipe.getOutput()), + recipe.getEnergyCost(), + LogHelper.getStackDescription(recipe.getOptionalOutput()), + recipe.getOptionalChance(), + LogHelper.getStackDescription(recipe.getSecondOptionalOutput()), + recipe.getSecondOptionalChance())); + } + } + + if (args.isEmpty() || args.contains("Inscriber")) { + for (IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes()) { + MineTweakerAPI.logCommand( + String.format( + "mods.appeng.Inscriber.addRecipe(%s, %s, %s, %s, \"%s\");", + LogHelper.getListDescription(recipe.getInputs()), + LogHelper.getStackDescription(recipe.getTopOptional().orNull()), + LogHelper.getStackDescription(recipe.getBottomOptional().orNull()), + LogHelper.getStackDescription(recipe.getOutput()), + recipe.getProcessType().toString())); + } + } + + if (player != null) { + player.sendChat( + MineTweakerImplementationAPI.platform + .getMessage("List generated; see minetweaker.log in your minecraft dir")); + } + } + } } diff --git a/src/main/java/modtweaker2/mods/appeng/handlers/Grind.java b/src/main/java/modtweaker2/mods/appeng/handlers/Grind.java index f6794ab..90951ab 100644 --- a/src/main/java/modtweaker2/mods/appeng/handlers/Grind.java +++ b/src/main/java/modtweaker2/mods/appeng/handlers/Grind.java @@ -1,8 +1,11 @@ package modtweaker2.mods.appeng.handlers; -import appeng.api.AEApi; -import appeng.api.features.IGrinderEntry; -import appeng.core.features.registries.entries.AppEngGrinderRecipe; +import static modtweaker2.helpers.InputHelper.toIItemStack; +import static modtweaker2.helpers.InputHelper.toStack; +import static modtweaker2.helpers.StackHelper.matches; + +import java.util.LinkedList; + import minetweaker.MineTweakerAPI; import minetweaker.api.item.IIngredient; import minetweaker.api.item.IItemStack; @@ -15,178 +18,229 @@ import modtweaker2.utils.BaseListRemoval; import stanhebben.zenscript.annotations.Optional; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; - -import java.util.LinkedList; - -import static modtweaker2.helpers.InputHelper.toIItemStack; -import static modtweaker2.helpers.InputHelper.toStack; -import static modtweaker2.helpers.StackHelper.matches; +import appeng.api.AEApi; +import appeng.api.features.IGrinderEntry; +import appeng.core.features.registries.entries.AppEngGrinderRecipe; @ZenClass("mods.appeng.Grinder") public class Grind { - protected static final String name = "Applied Energistics 2 Grindstone"; + protected static final String name = "Applied Energistics 2 Grindstone"; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /** - * Adds a shaped recipe for the Grindstone - * @param outputs - * @param inputStack - * @param turns - */ - @ZenMethod - public static void addRecipe(WeightedItemStack[] outputs, IItemStack inputStack, int turns) { - IGrinderEntry recipe; - if (outputs.length == 1) - recipe = new AppEngGrinderRecipe(InputHelper.toStack(inputStack), InputHelper.toStack(outputs[0].getStack()), turns); - else if (outputs.length == 2) - recipe = new AppEngGrinderRecipe(InputHelper.toStack(inputStack), InputHelper.toStack(outputs[0].getStack()), InputHelper.toStack(outputs[1].getStack()), outputs[1].getChance(), turns); - else if (outputs.length == 3) - recipe = new AppEngGrinderRecipe(InputHelper.toStack(inputStack), InputHelper.toStack(outputs[0].getStack()), InputHelper.toStack(outputs[1].getStack()), InputHelper.toStack(outputs[2].getStack()), outputs[1].getChance(), outputs[2].getChance(), turns); - else { - LogHelper.logWarning(String.format("No more then 3 output stacks are allowed in %s. Command ignored!", name, LogHelper.getStackDescription(toStack(inputStack)))); - return; - } + /** + * Adds a shaped recipe for the Grindstone + * + * @param outputs + * @param inputStack + * @param turns + */ + @ZenMethod + public static void addRecipe(WeightedItemStack[] outputs, IItemStack inputStack, int turns) { + IGrinderEntry recipe; + if (outputs.length == 1) recipe = new AppEngGrinderRecipe( + InputHelper.toStack(inputStack), + InputHelper.toStack(outputs[0].getStack()), + turns); + else if (outputs.length == 2) recipe = new AppEngGrinderRecipe( + InputHelper.toStack(inputStack), + InputHelper.toStack(outputs[0].getStack()), + InputHelper.toStack(outputs[1].getStack()), + outputs[1].getChance(), + turns); + else if (outputs.length == 3) recipe = new AppEngGrinderRecipe( + InputHelper.toStack(inputStack), + InputHelper.toStack(outputs[0].getStack()), + InputHelper.toStack(outputs[1].getStack()), + InputHelper.toStack(outputs[2].getStack()), + outputs[1].getChance(), + outputs[2].getChance(), + turns); + else { + LogHelper.logWarning( + String.format( + "No more then 3 output stacks are allowed in %s. Command ignored!", + name, + LogHelper.getStackDescription(toStack(inputStack)))); + return; + } - // Check if the recipe is already present, we don't want to add duplicates - for (IGrinderEntry r : AEApi.instance().registries().grinder().getRecipes()) { - if (r != null && AppliedEnergisticsHelper.equals(r, recipe)) { - LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s. Command ignored!", name, LogHelper.getStackDescription(toStack(inputStack)))); - return; - } - } + // Check if the recipe is already present, we don't want to add duplicates + for (IGrinderEntry r : AEApi.instance().registries().grinder().getRecipes()) { + if (r != null && AppliedEnergisticsHelper.equals(r, recipe)) { + LogHelper.logWarning( + String.format( + "Duplicate %s Recipe found for %s. Command ignored!", + name, + LogHelper.getStackDescription(toStack(inputStack)))); + return; + } + } - MineTweakerAPI.apply(new Add(recipe)); - } + MineTweakerAPI.apply(new Add(recipe)); + } - /** - * Adds a shaped recipe for the Grindstone - * - * @param outputStack - Product of the Recipe - * @param inputStack - Ingredient of the Recipe - * @param inputEnergy - Energy requirement of the Recipe - * @optionalParam outputStack2 - Second product of the Recipe - * @optionalParam outputStack2Chance - Chance for the acquirement of the second product - * @optionalParam outputStack3 - Third product of the Recipe - * @optionalParam outputStack3Chance - Chance for the acquirement of the third product - **/ - @Deprecated - @ZenMethod - public static void addRecipe(IItemStack outputStack, IItemStack inputStack, @Optional IItemStack outputStack2, @Optional float outputStack2Chance, @Optional IItemStack outputStack3, @Optional float outputStack3Chance, int inputEnergy) { - if (inputStack == null || outputStack == null) { - LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); - return; - } + /** + * Adds a shaped recipe for the Grindstone + * + * @param outputStack - Product of the Recipe + * @param inputStack - Ingredient of the Recipe + * @param inputEnergy - Energy requirement of the Recipe + * @optionalParam outputStack2 - Second product of the Recipe + * @optionalParam outputStack2Chance - Chance for the acquirement of the second product + * @optionalParam outputStack3 - Third product of the Recipe + * @optionalParam outputStack3Chance - Chance for the acquirement of the third product + **/ + @Deprecated + @ZenMethod + public static void addRecipe(IItemStack outputStack, IItemStack inputStack, @Optional IItemStack outputStack2, + @Optional float outputStack2Chance, @Optional IItemStack outputStack3, @Optional float outputStack3Chance, + int inputEnergy) { + if (inputStack == null || outputStack == null) { + LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); + return; + } - // Create recipe - IGrinderEntry recipe; + // Create recipe + IGrinderEntry recipe; - if (outputStack2 != null && outputStack3 != null) - recipe = new AppEngGrinderRecipe(InputHelper.toStack(inputStack), InputHelper.toStack(outputStack), InputHelper.toStack(outputStack2), InputHelper.toStack(outputStack3), outputStack2Chance, outputStack3Chance, inputEnergy); - else if (outputStack2 != null) - recipe = new AppEngGrinderRecipe(InputHelper.toStack(inputStack), InputHelper.toStack(outputStack), InputHelper.toStack(outputStack2), outputStack2Chance, inputEnergy); - else - recipe = new AppEngGrinderRecipe(InputHelper.toStack(inputStack), InputHelper.toStack(outputStack), inputEnergy); + if (outputStack2 != null && outputStack3 != null) recipe = new AppEngGrinderRecipe( + InputHelper.toStack(inputStack), + InputHelper.toStack(outputStack), + InputHelper.toStack(outputStack2), + InputHelper.toStack(outputStack3), + outputStack2Chance, + outputStack3Chance, + inputEnergy); + else if (outputStack2 != null) recipe = new AppEngGrinderRecipe( + InputHelper.toStack(inputStack), + InputHelper.toStack(outputStack), + InputHelper.toStack(outputStack2), + outputStack2Chance, + inputEnergy); + else recipe = new AppEngGrinderRecipe( + InputHelper.toStack(inputStack), + InputHelper.toStack(outputStack), + inputEnergy); - // Check if the recipe is already present, we don't want to add duplicates - for (IGrinderEntry r : AEApi.instance().registries().grinder().getRecipes()) { - if (r != null && AppliedEnergisticsHelper.equals(r, recipe)) { - LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s. Command ignored!", name, LogHelper.getStackDescription(toStack(inputStack)))); - return; - } - } + // Check if the recipe is already present, we don't want to add duplicates + for (IGrinderEntry r : AEApi.instance().registries().grinder().getRecipes()) { + if (r != null && AppliedEnergisticsHelper.equals(r, recipe)) { + LogHelper.logWarning( + String.format( + "Duplicate %s Recipe found for %s. Command ignored!", + name, + LogHelper.getStackDescription(toStack(inputStack)))); + return; + } + } - MineTweakerAPI.apply(new Add(recipe)); - } + MineTweakerAPI.apply(new Add(recipe)); + } - @Deprecated - @ZenMethod - public static void addRecipe(IItemStack input, IItemStack output, int energy, @Optional IItemStack output2, @Optional float chance2, @Optional IItemStack output3, @Optional float chance3) { - if (input == null || output == null) { - LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); - return; - } + @Deprecated + @ZenMethod + public static void addRecipe(IItemStack input, IItemStack output, int energy, @Optional IItemStack output2, + @Optional float chance2, @Optional IItemStack output3, @Optional float chance3) { + if (input == null || output == null) { + LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); + return; + } - // Create recipe - IGrinderEntry recipe; + // Create recipe + IGrinderEntry recipe; - if (output2 != null && output3 != null) - recipe = new AppEngGrinderRecipe(InputHelper.toStack(input), InputHelper.toStack(output), InputHelper.toStack(output2), InputHelper.toStack(output3), chance2, chance3, energy); - else if (output2 != null) - recipe = new AppEngGrinderRecipe(InputHelper.toStack(input), InputHelper.toStack(output), InputHelper.toStack(output2), chance2, energy); - else - recipe = new AppEngGrinderRecipe(InputHelper.toStack(input), InputHelper.toStack(output), energy); + if (output2 != null && output3 != null) recipe = new AppEngGrinderRecipe( + InputHelper.toStack(input), + InputHelper.toStack(output), + InputHelper.toStack(output2), + InputHelper.toStack(output3), + chance2, + chance3, + energy); + else if (output2 != null) recipe = new AppEngGrinderRecipe( + InputHelper.toStack(input), + InputHelper.toStack(output), + InputHelper.toStack(output2), + chance2, + energy); + else recipe = new AppEngGrinderRecipe(InputHelper.toStack(input), InputHelper.toStack(output), energy); - // Check if the recipe is already present, we don't want to add duplicates - for (IGrinderEntry r : AEApi.instance().registries().grinder().getRecipes()) { - if (r != null && AppliedEnergisticsHelper.equals(r, recipe)) { - LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s. Command ignored!", name, LogHelper.getStackDescription(toStack(input)))); - return; - } - } + // Check if the recipe is already present, we don't want to add duplicates + for (IGrinderEntry r : AEApi.instance().registries().grinder().getRecipes()) { + if (r != null && AppliedEnergisticsHelper.equals(r, recipe)) { + LogHelper.logWarning( + String.format( + "Duplicate %s Recipe found for %s. Command ignored!", + name, + LogHelper.getStackDescription(toStack(input)))); + return; + } + } - MineTweakerAPI.apply(new Add(recipe)); - } + MineTweakerAPI.apply(new Add(recipe)); + } - private static class Add extends BaseListAddition { + private static class Add extends BaseListAddition { - public Add(IGrinderEntry recipe) { - super(Grind.name, AEApi.instance().registries().grinder().getRecipes()); - recipes.add(recipe); - } + public Add(IGrinderEntry recipe) { + super(Grind.name, AEApi.instance().registries().grinder().getRecipes()); + recipes.add(recipe); + } - @Override - public String getRecipeInfo(IGrinderEntry recipe) { - return LogHelper.getStackDescription(recipe.getInput()); - } + @Override + public String getRecipeInfo(IGrinderEntry recipe) { + return LogHelper.getStackDescription(recipe.getInput()); + } - @Override - protected boolean equals(IGrinderEntry recipe, IGrinderEntry otherRecipe) { - return AppliedEnergisticsHelper.equals(recipe, otherRecipe); - } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + @Override + protected boolean equals(IGrinderEntry recipe, IGrinderEntry otherRecipe) { + return AppliedEnergisticsHelper.equals(recipe, otherRecipe); + } + } - /** - * Removes a recipe for the Grindstone - * - * @param input - Product of the Recipe - **/ - @ZenMethod - public static void removeRecipe(IIngredient input) { - if (input == null) { - LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); - return; - } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Get list of existing recipes, matching with parameter - LinkedList result = new LinkedList(); + /** + * Removes a recipe for the Grindstone + * + * @param input - Product of the Recipe + **/ + @ZenMethod + public static void removeRecipe(IIngredient input) { + if (input == null) { + LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); + return; + } - for (IGrinderEntry entry : AEApi.instance().registries().grinder().getRecipes()) { - if (entry != null && entry.getOutput() != null && matches(input, toIItemStack(entry.getOutput()))) { - result.add(entry); - } - } + // Get list of existing recipes, matching with parameter + LinkedList result = new LinkedList(); - // Check if we found the recipes and apply the action - if (!result.isEmpty()) { - MineTweakerAPI.apply(new Remove(result)); - } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", name, input.toString())); - } - } + for (IGrinderEntry entry : AEApi.instance().registries().grinder().getRecipes()) { + if (entry != null && entry.getOutput() != null && matches(input, toIItemStack(entry.getOutput()))) { + result.add(entry); + } + } - private static class Remove extends BaseListRemoval { - public Remove(LinkedList recipes) { - super(Grind.name, AEApi.instance().registries().grinder().getRecipes(), recipes); - } + // Check if we found the recipes and apply the action + if (!result.isEmpty()) { + MineTweakerAPI.apply(new Remove(result)); + } else { + LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", name, input.toString())); + } + } - @Override - public String getRecipeInfo(IGrinderEntry recipe) { - return LogHelper.getStackDescription(recipe.getInput()); - } - } + private static class Remove extends BaseListRemoval { -} \ No newline at end of file + public Remove(LinkedList recipes) { + super(Grind.name, AEApi.instance().registries().grinder().getRecipes(), recipes); + } + + @Override + public String getRecipeInfo(IGrinderEntry recipe) { + return LogHelper.getStackDescription(recipe.getInput()); + } + } + +} diff --git a/src/main/java/modtweaker2/mods/appeng/handlers/Inscriber.java b/src/main/java/modtweaker2/mods/appeng/handlers/Inscriber.java index 8b02cc0..809b1f7 100644 --- a/src/main/java/modtweaker2/mods/appeng/handlers/Inscriber.java +++ b/src/main/java/modtweaker2/mods/appeng/handlers/Inscriber.java @@ -25,173 +25,208 @@ import appeng.core.features.registries.entries.InscriberRecipe; @ZenClass("mods.appeng.Inscriber") public class Inscriber { - + protected static final String name = "Applied Energistics 2 Inscriber"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** - * Adds a shaped recipe for the Carpenter - * - * @param outputStack - Product of the Recipe - * @param inputArray - Ingredients of the Recipe - * @param inputStackPlateA - Ingredient of the Recipe for Plate Slot A - * @param inputStackPlateB - Ingredient of the Recipe for Plate Slot B - * @param typeString - Type that decides whether to consume the ItemStack in Plate Slot A/B - **/ - @ZenMethod - public static void addRecipe(IItemStack outputStack, IItemStack[] inputArray, IItemStack inputStackPlateA, IItemStack inputStackPlateB, String typeString) { - if(inputArray == null || outputStack == null || (!typeString.equals("Press") && !typeString.equals("Inscribe"))) { + * Adds a shaped recipe for the Carpenter + * + * @param outputStack - Product of the Recipe + * @param inputArray - Ingredients of the Recipe + * @param inputStackPlateA - Ingredient of the Recipe for Plate Slot A + * @param inputStackPlateB - Ingredient of the Recipe for Plate Slot B + * @param typeString - Type that decides whether to consume the ItemStack in Plate Slot A/B + **/ + @ZenMethod + public static void addRecipe(IItemStack outputStack, IItemStack[] inputArray, IItemStack inputStackPlateA, + IItemStack inputStackPlateB, String typeString) { + if (inputArray == null || outputStack == null + || (!typeString.equals("Press") && !typeString.equals("Inscribe"))) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", Inscriber.name)); return; } - - // Create recipe - IInscriberRecipe recipe = new InscriberRecipe(ArrayUtils.toArrayList(toStacks(inputArray)), toStack(outputStack), toStack(inputStackPlateA), toStack(inputStackPlateB), InscriberProcessType.valueOf(typeString)); - + + // Create recipe + IInscriberRecipe recipe = new InscriberRecipe( + ArrayUtils.toArrayList(toStacks(inputArray)), + toStack(outputStack), + toStack(inputStackPlateA), + toStack(inputStackPlateB), + InscriberProcessType.valueOf(typeString)); + // Check if the recipe is already present, we don't want to add duplicates - for(IInscriberRecipe r : AEApi.instance().registries().inscriber().getRecipes()) { - if(r != null && AppliedEnergisticsHelper.equals(r, recipe)) { - LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s. Command ignored!", Inscriber.name, LogHelper.getStackDescription(toStack(outputStack)))); - return; - } - } - - MineTweakerAPI.apply(new Add(recipe)); - } - - @Deprecated - @ZenMethod - public static void addRecipe(IItemStack[] imprintable, IItemStack plateA, IItemStack plateB, IItemStack out, String type) { - if(imprintable == null || out == null || (!type.equals("Press") && !type.equals("Inscribe"))) { + for (IInscriberRecipe r : AEApi.instance().registries().inscriber().getRecipes()) { + if (r != null && AppliedEnergisticsHelper.equals(r, recipe)) { + LogHelper.logWarning( + String.format( + "Duplicate %s Recipe found for %s. Command ignored!", + Inscriber.name, + LogHelper.getStackDescription(toStack(outputStack)))); + return; + } + } + + MineTweakerAPI.apply(new Add(recipe)); + } + + @Deprecated + @ZenMethod + public static void addRecipe(IItemStack[] imprintable, IItemStack plateA, IItemStack plateB, IItemStack out, + String type) { + if (imprintable == null || out == null || (!type.equals("Press") && !type.equals("Inscribe"))) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", Inscriber.name)); return; } - - // Create recipe - IInscriberRecipe recipe = new InscriberRecipe(ArrayUtils.toArrayList(toStacks(imprintable)), toStack(out), toStack(plateA), toStack(plateB), InscriberProcessType.valueOf(type)); - + + // Create recipe + IInscriberRecipe recipe = new InscriberRecipe( + ArrayUtils.toArrayList(toStacks(imprintable)), + toStack(out), + toStack(plateA), + toStack(plateB), + InscriberProcessType.valueOf(type)); + // Check if the recipe is already present, we don't want to add duplicates - for(IInscriberRecipe r : AEApi.instance().registries().inscriber().getRecipes()) { - if(r != null && AppliedEnergisticsHelper.equals(r, recipe)) { - LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s. Command ignored!", Inscriber.name, LogHelper.getStackDescription(toStack(out)))); - return; - } - } - - MineTweakerAPI.apply(new Add(recipe)); - } + for (IInscriberRecipe r : AEApi.instance().registries().inscriber().getRecipes()) { + if (r != null && AppliedEnergisticsHelper.equals(r, recipe)) { + LogHelper.logWarning( + String.format( + "Duplicate %s Recipe found for %s. Command ignored!", + Inscriber.name, + LogHelper.getStackDescription(toStack(out)))); + return; + } + } - public static class Add extends BaseListAddition { - public Add(IInscriberRecipe recipe) { - super(Inscriber.name, new ArrayList<>(AEApi.instance().registries().inscriber().getRecipes())); - recipes.add(recipe); - } + MineTweakerAPI.apply(new Add(recipe)); + } - @Override - public void apply() { - if(recipes.isEmpty()) { - return; - } + public static class Add extends BaseListAddition { - for(IInscriberRecipe recipe : recipes) { - try { - AEApi.instance().registries().inscriber().addRecipe(recipe); - successful.add(recipe); - } catch (Exception ex) { LogHelper.logError("Error adding inscriber recipe.", ex); } - } - } - - @Override - public void undo() { - if(successful.isEmpty()) { - return; - } + public Add(IInscriberRecipe recipe) { + super(Inscriber.name, new ArrayList<>(AEApi.instance().registries().inscriber().getRecipes())); + recipes.add(recipe); + } - for(IInscriberRecipe recipe : successful) { + @Override + public void apply() { + if (recipes.isEmpty()) { + return; + } + + for (IInscriberRecipe recipe : recipes) { + try { + AEApi.instance().registries().inscriber().addRecipe(recipe); + successful.add(recipe); + } catch (Exception ex) { + LogHelper.logError("Error adding inscriber recipe.", ex); + } + } + } + + @Override + public void undo() { + if (successful.isEmpty()) { + return; + } + + for (IInscriberRecipe recipe : successful) { try { AEApi.instance().registries().inscriber().removeRecipe(recipe); - } catch (Exception ex) { LogHelper.logError("Error removing inscriber recipe.", ex); } - } - } - + } catch (Exception ex) { + LogHelper.logError("Error removing inscriber recipe.", ex); + } + } + } + @Override public String getRecipeInfo(IInscriberRecipe recipe) { return LogHelper.getStackDescription(recipe.getOutput()); } - + @Override protected boolean equals(IInscriberRecipe recipe, IInscriberRecipe otherRecipe) { return AppliedEnergisticsHelper.equals(recipe, otherRecipe); } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** - * Adds a shaped recipe for the Carpenter - * - * @param outputStack - Product of the Recipe - **/ - @ZenMethod - public static void removeRecipe(IIngredient outputStack) { - if(outputStack == null) { + * Adds a shaped recipe for the Carpenter + * + * @param outputStack - Product of the Recipe + **/ + @ZenMethod + public static void removeRecipe(IIngredient outputStack) { + if (outputStack == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", Inscriber.name)); return; } - + // Get list of existing recipes, matching with parameter LinkedList result = new LinkedList(); - - for(IInscriberRecipe entry : AEApi.instance().registries().inscriber().getRecipes()) { - if(entry != null && entry.getOutput() != null && matches(outputStack, toIItemStack(entry.getOutput()))) { + + for (IInscriberRecipe entry : AEApi.instance().registries().inscriber().getRecipes()) { + if (entry != null && entry.getOutput() != null && matches(outputStack, toIItemStack(entry.getOutput()))) { result.add(entry); } } - + // Check if we found the recipes and apply the action - if(!result.isEmpty()) { + if (!result.isEmpty()) { MineTweakerAPI.apply(new Remove(result)); } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Inscriber.name, outputStack.toString())); + LogHelper.logWarning( + String.format( + "No %s Recipe found for %s. Command ignored!", + Inscriber.name, + outputStack.toString())); } - } + } - public static class Remove extends BaseListRemoval { - public Remove(LinkedList recipes) { - super(Inscriber.name, new ArrayList<>(AEApi.instance().registries().inscriber().getRecipes()), recipes); - } - - @Override - public void apply() { - if(this.recipes.isEmpty()) { - return; - } - - for(IInscriberRecipe recipe : recipes) { + public static class Remove extends BaseListRemoval { + + public Remove(LinkedList recipes) { + super(Inscriber.name, new ArrayList<>(AEApi.instance().registries().inscriber().getRecipes()), recipes); + } + + @Override + public void apply() { + if (this.recipes.isEmpty()) { + return; + } + + for (IInscriberRecipe recipe : recipes) { try { AEApi.instance().registries().inscriber().removeRecipe(recipe); successful.add(recipe); - } catch (Exception ex) { LogHelper.logError("Error removing inscriber recipe.", ex); } + } catch (Exception ex) { + LogHelper.logError("Error removing inscriber recipe.", ex); + } } - } - - @Override - public void undo() { - if(successful.isEmpty()) { - return; - } - - for(IInscriberRecipe recipe : successful) { + } + + @Override + public void undo() { + if (successful.isEmpty()) { + return; + } + + for (IInscriberRecipe recipe : successful) { try { AEApi.instance().registries().inscriber().addRecipe(recipe); - } catch (Exception ex) { LogHelper.logError("Error restoring inscriber recipe.", ex); } + } catch (Exception ex) { + LogHelper.logError("Error restoring inscriber recipe.", ex); + } } - } + } - @Override - public String getRecipeInfo(IInscriberRecipe recipe) { - return LogHelper.getStackDescription(recipe.getOutput()); - } - } + @Override + public String getRecipeInfo(IInscriberRecipe recipe) { + return LogHelper.getStackDescription(recipe.getOutput()); + } + } } diff --git a/src/main/java/modtweaker2/mods/auracascade/AuraCascade.java b/src/main/java/modtweaker2/mods/auracascade/AuraCascade.java index 3833d02..98f661c 100644 --- a/src/main/java/modtweaker2/mods/auracascade/AuraCascade.java +++ b/src/main/java/modtweaker2/mods/auracascade/AuraCascade.java @@ -5,9 +5,10 @@ import modtweaker2.mods.auracascade.aura.AuraBracketHandler; import modtweaker2.mods.auracascade.handlers.Pylon; public class AuraCascade { - public AuraCascade(){ - MineTweakerAPI.registerBracketHandler(new AuraBracketHandler()); - MineTweakerAPI.registerClass(Pylon.class); - } + + public AuraCascade() { + MineTweakerAPI.registerBracketHandler(new AuraBracketHandler()); + MineTweakerAPI.registerClass(Pylon.class); + } } diff --git a/src/main/java/modtweaker2/mods/auracascade/AuraCascadeHelper.java b/src/main/java/modtweaker2/mods/auracascade/AuraCascadeHelper.java index 5d581e0..72c78b9 100644 --- a/src/main/java/modtweaker2/mods/auracascade/AuraCascadeHelper.java +++ b/src/main/java/modtweaker2/mods/auracascade/AuraCascadeHelper.java @@ -5,20 +5,21 @@ import pixlepix.auracascade.data.AuraQuantity; import pixlepix.auracascade.data.EnumAura; public class AuraCascadeHelper { - public static AuraQuantity toAura(IAuraStack iStack) { - if (iStack == null) { - return null; - } else return new AuraQuantity(EnumAura.valueOf(iStack.getName()), iStack.getAmount()); - } -// public static GasStack[] toGases(IIngredient[] input) { -// return toGases((IGasStack[]) input); -// } -// -// public static GasStack[] toGases(IGasStack[] iStack) { -// GasStack[] stack = new GasStack[iStack.length]; -// for (int i = 0; i < stack.length; i++) -// stack[i] = toGas(iStack[i]); -// return stack; -// } + public static AuraQuantity toAura(IAuraStack iStack) { + if (iStack == null) { + return null; + } else return new AuraQuantity(EnumAura.valueOf(iStack.getName()), iStack.getAmount()); + } + + // public static GasStack[] toGases(IIngredient[] input) { + // return toGases((IGasStack[]) input); + // } + // + // public static GasStack[] toGases(IGasStack[] iStack) { + // GasStack[] stack = new GasStack[iStack.length]; + // for (int i = 0; i < stack.length; i++) + // stack[i] = toGas(iStack[i]); + // return stack; + // } } diff --git a/src/main/java/modtweaker2/mods/auracascade/aura/AuraBracketHandler.java b/src/main/java/modtweaker2/mods/auracascade/aura/AuraBracketHandler.java index d773a5f..bb02537 100644 --- a/src/main/java/modtweaker2/mods/auracascade/aura/AuraBracketHandler.java +++ b/src/main/java/modtweaker2/mods/auracascade/aura/AuraBracketHandler.java @@ -20,66 +20,67 @@ import stanhebben.zenscript.util.ZenPosition; @BracketHandler(priority = 100) public class AuraBracketHandler implements IBracketHandler { - public static IAuraStack getAura(String name) { - EnumAura aura = EnumAura.valueOf(name); - if (aura != null) { - return new MCAuraStack(new AuraQuantity(aura, 1)); - } else { - return null; - } - } + public static IAuraStack getAura(String name) { + EnumAura aura = EnumAura.valueOf(name); + if (aura != null) { + return new MCAuraStack(new AuraQuantity(aura, 1)); + } else { + return null; + } + } - private final IZenSymbol symbolAny; - private final IJavaMethod method; + private final IZenSymbol symbolAny; + private final IJavaMethod method; - public AuraBracketHandler() { - symbolAny = MineTweakerAPI.getJavaStaticFieldSymbol(IngredientAny.class, "INSTANCE"); - method = MineTweakerAPI.getJavaMethod(AuraBracketHandler.class, "getAura", String.class); - } + public AuraBracketHandler() { + symbolAny = MineTweakerAPI.getJavaStaticFieldSymbol(IngredientAny.class, "INSTANCE"); + method = MineTweakerAPI.getJavaMethod(AuraBracketHandler.class, "getAura", String.class); + } - @Override - public IZenSymbol resolve(IEnvironmentGlobal environment, List tokens) { - // any symbol - if (tokens.size() == 1 && tokens.get(0).getValue().equals("*")) { - return symbolAny; - } + @Override + public IZenSymbol resolve(IEnvironmentGlobal environment, List tokens) { + // any symbol + if (tokens.size() == 1 && tokens.get(0).getValue().equals("*")) { + return symbolAny; + } - if (tokens.size() > 2) { - if (tokens.get(0).getValue().equals("aura") && tokens.get(1).getValue().equals(":")) { - return find(environment, tokens, 2, tokens.size()); - } - } + if (tokens.size() > 2) { + if (tokens.get(0).getValue().equals("aura") && tokens.get(1).getValue().equals(":")) { + return find(environment, tokens, 2, tokens.size()); + } + } - return null; - } + return null; + } - private IZenSymbol find(IEnvironmentGlobal environment, List tokens, int startIndex, int endIndex) { - //StringBuilder valueBuilder = new StringBuilder(); + private IZenSymbol find(IEnvironmentGlobal environment, List tokens, int startIndex, int endIndex) { + // StringBuilder valueBuilder = new StringBuilder(); - for (EnumAura a : EnumAura.values()) { - for (int i = startIndex; i < endIndex; i++) { - Token token = tokens.get(i); - if (a.name().equals(token.getValue())) { - return new AuraReferenceSymbol(environment, token.getValue()); - } - } - } + for (EnumAura a : EnumAura.values()) { + for (int i = startIndex; i < endIndex; i++) { + Token token = tokens.get(i); + if (a.name().equals(token.getValue())) { + return new AuraReferenceSymbol(environment, token.getValue()); + } + } + } - return null; - } + return null; + } - private class AuraReferenceSymbol implements IZenSymbol { - private final IEnvironmentGlobal environment; - private final String name; + private class AuraReferenceSymbol implements IZenSymbol { - public AuraReferenceSymbol(IEnvironmentGlobal environment, String name) { - this.environment = environment; - this.name = name; - } + private final IEnvironmentGlobal environment; + private final String name; - @Override - public IPartialExpression instance(ZenPosition position) { - return new ExpressionCallStatic(position, environment, method, new ExpressionString(position, name)); - } - } -} \ No newline at end of file + public AuraReferenceSymbol(IEnvironmentGlobal environment, String name) { + this.environment = environment; + this.name = name; + } + + @Override + public IPartialExpression instance(ZenPosition position) { + return new ExpressionCallStatic(position, environment, method, new ExpressionString(position, name)); + } + } +} diff --git a/src/main/java/modtweaker2/mods/auracascade/aura/IAuraDefinition.java b/src/main/java/modtweaker2/mods/auracascade/aura/IAuraDefinition.java index 9a4fc83..5554f99 100644 --- a/src/main/java/modtweaker2/mods/auracascade/aura/IAuraDefinition.java +++ b/src/main/java/modtweaker2/mods/auracascade/aura/IAuraDefinition.java @@ -7,7 +7,7 @@ import stanhebben.zenscript.annotations.ZenOperator; @ZenClass("modtweaker.auraCascade.IAuraDefinition") public interface IAuraDefinition { - + @ZenOperator(OperatorType.MUL) public IAuraStack asAura(int amount); @@ -16,4 +16,4 @@ public interface IAuraDefinition { @ZenGetter("displayName") public String getDisplayName(); -} \ No newline at end of file +} diff --git a/src/main/java/modtweaker2/mods/auracascade/aura/IAuraStack.java b/src/main/java/modtweaker2/mods/auracascade/aura/IAuraStack.java index 66fa51e..22fc216 100644 --- a/src/main/java/modtweaker2/mods/auracascade/aura/IAuraStack.java +++ b/src/main/java/modtweaker2/mods/auracascade/aura/IAuraStack.java @@ -8,6 +8,7 @@ import stanhebben.zenscript.annotations.ZenOperator; @ZenClass("modtweaker.auraCascade.IAuraStack") public interface IAuraStack { + @ZenGetter("definition") public IAuraDefinition getDefinition(); @@ -25,4 +26,4 @@ public interface IAuraStack { public IAuraStack withAmount(int amount); public Object getInternal(); -} \ No newline at end of file +} diff --git a/src/main/java/modtweaker2/mods/auracascade/aura/MCAuraDefinition.java b/src/main/java/modtweaker2/mods/auracascade/aura/MCAuraDefinition.java index 8bda113..8f58113 100644 --- a/src/main/java/modtweaker2/mods/auracascade/aura/MCAuraDefinition.java +++ b/src/main/java/modtweaker2/mods/auracascade/aura/MCAuraDefinition.java @@ -2,8 +2,8 @@ package modtweaker2.mods.auracascade.aura; import pixlepix.auracascade.data.AuraQuantity; - public class MCAuraDefinition implements IAuraDefinition { + private final AuraQuantity aura; public MCAuraDefinition(AuraQuantity aura) { @@ -20,8 +20,8 @@ public class MCAuraDefinition implements IAuraDefinition { return aura.getType().name; } - @Override - public IAuraStack asAura(int amount) { - return new MCAuraStack(new AuraQuantity(aura.getType(), aura.getNum())); - } -} \ No newline at end of file + @Override + public IAuraStack asAura(int amount) { + return new MCAuraStack(new AuraQuantity(aura.getType(), aura.getNum())); + } +} diff --git a/src/main/java/modtweaker2/mods/auracascade/aura/MCAuraStack.java b/src/main/java/modtweaker2/mods/auracascade/aura/MCAuraStack.java index b710d6b..f359dd3 100644 --- a/src/main/java/modtweaker2/mods/auracascade/aura/MCAuraStack.java +++ b/src/main/java/modtweaker2/mods/auracascade/aura/MCAuraStack.java @@ -2,8 +2,8 @@ package modtweaker2.mods.auracascade.aura; import pixlepix.auracascade.data.AuraQuantity; - public class MCAuraStack implements IAuraStack { + private final AuraQuantity aura; public MCAuraStack(AuraQuantity aura) { @@ -40,4 +40,4 @@ public class MCAuraStack implements IAuraStack { public Object getInternal() { return aura; } -} \ No newline at end of file +} diff --git a/src/main/java/modtweaker2/mods/auracascade/commands/AuraLogger.java b/src/main/java/modtweaker2/mods/auracascade/commands/AuraLogger.java index 24d5d1e..4107b03 100644 --- a/src/main/java/modtweaker2/mods/auracascade/commands/AuraLogger.java +++ b/src/main/java/modtweaker2/mods/auracascade/commands/AuraLogger.java @@ -9,20 +9,21 @@ import pixlepix.auracascade.data.EnumAura; public class AuraLogger implements ICommandFunction { - @Override - public void execute(String[] arguments, IPlayer player) { + @Override + public void execute(String[] arguments, IPlayer player) { - - System.out.println("Aura Types: " + EnumAura.values().length); - MineTweakerAPI.logCommand("Aura Types: " + EnumAura.values().length); - for (EnumAura aura : EnumAura.values()) { - ModTweaker2.logger.info("Aura Type: " + aura.name() + "."); - MineTweakerAPI.logCommand("Aura Type: " + aura.name() + "."); + System.out.println("Aura Types: " + EnumAura.values().length); + MineTweakerAPI.logCommand("Aura Types: " + EnumAura.values().length); + for (EnumAura aura : EnumAura.values()) { + ModTweaker2.logger.info("Aura Type: " + aura.name() + "."); + MineTweakerAPI.logCommand("Aura Type: " + aura.name() + "."); - } + } - if (player != null) { - player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir")); - } - } + if (player != null) { + player.sendChat( + MineTweakerImplementationAPI.platform + .getMessage("List generated; see minetweaker.log in your minecraft dir")); + } + } } diff --git a/src/main/java/modtweaker2/mods/auracascade/handlers/Pylon.java b/src/main/java/modtweaker2/mods/auracascade/handlers/Pylon.java index 6dc2544..f7a4e19 100644 --- a/src/main/java/modtweaker2/mods/auracascade/handlers/Pylon.java +++ b/src/main/java/modtweaker2/mods/auracascade/handlers/Pylon.java @@ -22,65 +22,74 @@ import stanhebben.zenscript.annotations.ZenMethod; @ZenClass("mods.auraCascade.Pylon") public class Pylon { - + protected static final String name = "Aura Cascade Pylon"; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - @ZenMethod - public static void addRecipe(IItemStack ouput, IAuraStack stack, IItemStack input) { - addRecipe(ouput, stack, input, stack, input, stack, input, stack, input); - } - @ZenMethod - public static void addRecipe(IItemStack ouput, IAuraStack aura1, IItemStack input1, IAuraStack aura2, IItemStack input2, IAuraStack aura3, IItemStack input3, IAuraStack aura4, IItemStack input4) { - List recipes = new LinkedList(); - - recipes.add(new PylonRecipe(toStack(ouput), new PylonRecipeComponent(AuraCascadeHelper.toAura(aura1), toStack(input1)), new PylonRecipeComponent(AuraCascadeHelper.toAura(aura2), toStack(input2)), new PylonRecipeComponent(AuraCascadeHelper.toAura(aura3), toStack(input3)), new PylonRecipeComponent(AuraCascadeHelper.toAura(aura1), toStack(input4)))); - - MineTweakerAPI.apply(new Add(recipes)); - } + @ZenMethod + public static void addRecipe(IItemStack ouput, IAuraStack stack, IItemStack input) { + addRecipe(ouput, stack, input, stack, input, stack, input, stack, input); + } - private static class Add extends BaseListAddition { + @ZenMethod + public static void addRecipe(IItemStack ouput, IAuraStack aura1, IItemStack input1, IAuraStack aura2, + IItemStack input2, IAuraStack aura3, IItemStack input3, IAuraStack aura4, IItemStack input4) { + List recipes = new LinkedList(); + + recipes.add( + new PylonRecipe( + toStack(ouput), + new PylonRecipeComponent(AuraCascadeHelper.toAura(aura1), toStack(input1)), + new PylonRecipeComponent(AuraCascadeHelper.toAura(aura2), toStack(input2)), + new PylonRecipeComponent(AuraCascadeHelper.toAura(aura3), toStack(input3)), + new PylonRecipeComponent(AuraCascadeHelper.toAura(aura1), toStack(input4)))); + + MineTweakerAPI.apply(new Add(recipes)); + } + + private static class Add extends BaseListAddition { + + public Add(List recipes) { + super(Pylon.name, PylonRecipeRegistry.recipes, recipes); + } - public Add(List recipes) { - super(Pylon.name, PylonRecipeRegistry.recipes, recipes); - } - @Override protected String getRecipeInfo(PylonRecipe recipe) { return LogHelper.getStackDescription(recipe.result); } - } - + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - @ZenMethod - public static void removeRecipe(IIngredient output) { + @ZenMethod + public static void removeRecipe(IIngredient output) { List recipes = new LinkedList(); - + for (PylonRecipe r : PylonRecipeRegistry.recipes) { if (output.matches(toIItemStack(r.result))) { recipes.add(r); } } - + // Check if we found the recipes and apply the action - if(!recipes.isEmpty()) { + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new Remove(recipes)); } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Pylon.name, output.toString())); + LogHelper.logWarning( + String.format("No %s Recipe found for %s. Command ignored!", Pylon.name, output.toString())); } - } + } - private static class Remove extends BaseListRemoval { - public Remove(List recipes) { - super(Pylon.name, PylonRecipeRegistry.recipes, recipes); - } + private static class Remove extends BaseListRemoval { + + public Remove(List recipes) { + super(Pylon.name, PylonRecipeRegistry.recipes, recipes); + } @Override protected String getRecipeInfo(PylonRecipe recipe) { return LogHelper.getStackDescription(recipe.result); } - } + } } diff --git a/src/main/java/modtweaker2/mods/botania/Botania.java b/src/main/java/modtweaker2/mods/botania/Botania.java index 0797b23..b04f920 100644 --- a/src/main/java/modtweaker2/mods/botania/Botania.java +++ b/src/main/java/modtweaker2/mods/botania/Botania.java @@ -9,10 +9,13 @@ import modtweaker2.mods.botania.handlers.ManaInfusion; import modtweaker2.mods.botania.handlers.Orechid; import modtweaker2.mods.botania.handlers.PureDaisy; import modtweaker2.mods.botania.handlers.RuneAltar; + import net.minecraft.item.ItemStack; + import vazkii.botania.common.item.block.ItemBlockSpecialFlower; public class Botania { + public Botania() { MineTweakerAPI.registerClass(Apothecary.class); MineTweakerAPI.registerClass(Brew.class); diff --git a/src/main/java/modtweaker2/mods/botania/BotaniaHelper.java b/src/main/java/modtweaker2/mods/botania/BotaniaHelper.java index 124a523..e9e5159 100644 --- a/src/main/java/modtweaker2/mods/botania/BotaniaHelper.java +++ b/src/main/java/modtweaker2/mods/botania/BotaniaHelper.java @@ -8,32 +8,25 @@ import vazkii.botania.api.lexicon.LexiconCategory; import vazkii.botania.api.lexicon.LexiconEntry; public class BotaniaHelper { - public static LexiconCategory findCatagory(String name) - { - List catagories=BotaniaAPI.getAllCategories(); - for(int i=0;i entries=BotaniaAPI.getAllEntries(); - for(int i=0;i catagories = BotaniaAPI.getAllCategories(); + for (int i = 0; i < catagories.size(); i++) { + if (catagories.get(i).getUnlocalizedName().equalsIgnoreCase(name)) return catagories.get(i); + } + return null; + } - public static KnowledgeType findKnowledgeType(String name) - { - if(BotaniaAPI.knowledgeTypes.containsKey(name)) - return BotaniaAPI.knowledgeTypes.get(name); - return null; - } + public static LexiconEntry findEntry(String name) { + List entries = BotaniaAPI.getAllEntries(); + for (int i = 0; i < entries.size(); i++) { + if (entries.get(i).getUnlocalizedName().equalsIgnoreCase(name)) return entries.get(i); + } + return null; + } + + public static KnowledgeType findKnowledgeType(String name) { + if (BotaniaAPI.knowledgeTypes.containsKey(name)) return BotaniaAPI.knowledgeTypes.get(name); + return null; + } } diff --git a/src/main/java/modtweaker2/mods/botania/commands/BotaniaBrewLogger.java b/src/main/java/modtweaker2/mods/botania/commands/BotaniaBrewLogger.java index 43806ec..0d19f21 100644 --- a/src/main/java/modtweaker2/mods/botania/commands/BotaniaBrewLogger.java +++ b/src/main/java/modtweaker2/mods/botania/commands/BotaniaBrewLogger.java @@ -8,11 +8,11 @@ import minetweaker.api.player.IPlayer; import minetweaker.api.server.ICommandFunction; import vazkii.botania.api.BotaniaAPI; -public class BotaniaBrewLogger implements ICommandFunction{ +public class BotaniaBrewLogger implements ICommandFunction { @Override public void execute(String[] arguments, IPlayer player) { - Set brew_keys=BotaniaAPI.brewMap.keySet(); + Set brew_keys = BotaniaAPI.brewMap.keySet(); System.out.println("Brews: " + brew_keys.size()); for (String key : brew_keys) { System.out.println("Brew " + key); @@ -20,7 +20,9 @@ public class BotaniaBrewLogger implements ICommandFunction{ } if (player != null) { - player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir")); + player.sendChat( + MineTweakerImplementationAPI.platform + .getMessage("List generated; see minetweaker.log in your minecraft dir")); } } } diff --git a/src/main/java/modtweaker2/mods/botania/commands/BotaniaLogger.java b/src/main/java/modtweaker2/mods/botania/commands/BotaniaLogger.java index 39fae4f..c2338a1 100644 --- a/src/main/java/modtweaker2/mods/botania/commands/BotaniaLogger.java +++ b/src/main/java/modtweaker2/mods/botania/commands/BotaniaLogger.java @@ -10,7 +10,9 @@ import minetweaker.api.player.IPlayer; import minetweaker.api.server.ICommandFunction; import modtweaker2.helpers.LogHelper; import modtweaker2.helpers.StringHelper; + import net.minecraft.item.ItemStack; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.RecipeBrew; import vazkii.botania.api.recipe.RecipeElvenTrade; @@ -20,9 +22,9 @@ import vazkii.botania.api.recipe.RecipePureDaisy; import vazkii.botania.api.recipe.RecipeRuneAltar; public class BotaniaLogger implements ICommandFunction { - + private static final List validArguments = new LinkedList(); - + static { validArguments.add("Apothecary"); validArguments.add("Brew"); @@ -35,69 +37,86 @@ public class BotaniaLogger implements ICommandFunction { @Override public void execute(String[] arguments, IPlayer player) { List args = StringHelper.toLowerCase(Arrays.asList(arguments)); - - if(!validArguments.containsAll(args)) { - if(player != null) { - player.sendChat(MineTweakerImplementationAPI.platform.getMessage("Invalid arguments for command. Valid arguments: " + StringHelper.join(validArguments, ", "))); + + if (!validArguments.containsAll(args)) { + if (player != null) { + player.sendChat( + MineTweakerImplementationAPI.platform.getMessage( + "Invalid arguments for command. Valid arguments: " + + StringHelper.join(validArguments, ", "))); } } else { - if(args.isEmpty() || args.contains("Apothecary")) { - for(RecipePetals recipe : BotaniaAPI.petalRecipes) { - MineTweakerAPI.logCommand(String.format("mods.botania.Apothecary.addRecipe(%s, %s);", - LogHelper.getStackDescription(recipe.getOutput()), - LogHelper.getListDescription(recipe.getInputs()) // Need to resolve "petalXXX" to an item + if (args.isEmpty() || args.contains("Apothecary")) { + for (RecipePetals recipe : BotaniaAPI.petalRecipes) { + MineTweakerAPI.logCommand( + String.format( + "mods.botania.Apothecary.addRecipe(%s, %s);", + LogHelper.getStackDescription(recipe.getOutput()), + LogHelper.getListDescription(recipe.getInputs()) // Need to resolve "petalXXX" to an + // item )); } } - - if(args.isEmpty() || args.contains("Brew")) { - for(RecipeBrew recipe : BotaniaAPI.brewRecipes) { - MineTweakerAPI.logCommand(String.format("mods.botania.Brew.addRecipe(%s, \"%s\");", - LogHelper.getListDescription(recipe.getInputs()), - recipe.getBrew().getKey())); + + if (args.isEmpty() || args.contains("Brew")) { + for (RecipeBrew recipe : BotaniaAPI.brewRecipes) { + MineTweakerAPI.logCommand( + String.format( + "mods.botania.Brew.addRecipe(%s, \"%s\");", + LogHelper.getListDescription(recipe.getInputs()), + recipe.getBrew().getKey())); } } - - if(args.isEmpty() || args.contains("ElvenTrade")) { - for(RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes) { - MineTweakerAPI.logCommand(String.format("mods.botania.ElvenTrade.addRecipe(%s, %s);", - LogHelper.getStackDescription(recipe.getOutput()), - LogHelper.getListDescription(recipe.getInputs() - ))); + + if (args.isEmpty() || args.contains("ElvenTrade")) { + for (RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes) { + MineTweakerAPI.logCommand( + String.format( + "mods.botania.ElvenTrade.addRecipe(%s, %s);", + LogHelper.getStackDescription(recipe.getOutput()), + LogHelper.getListDescription(recipe.getInputs()))); } } - - if(args.isEmpty() || args.contains("ManaInfusion")) { - for(RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) { - MineTweakerAPI.logCommand(String.format("mods.botania.ManaInfusion.add%s(%s, %s, %d);", - recipe.isAlchemy() ? "Alchemy" : recipe.isConjuration() ? "Conjuration" : "Infusion", - LogHelper.getStackDescription(recipe.getOutput()), - LogHelper.getStackDescription(recipe.getInput()), - recipe.getManaToConsume() - )); + + if (args.isEmpty() || args.contains("ManaInfusion")) { + for (RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) { + MineTweakerAPI.logCommand( + String.format( + "mods.botania.ManaInfusion.add%s(%s, %s, %d);", + recipe.isAlchemy() ? "Alchemy" + : recipe.isConjuration() ? "Conjuration" : "Infusion", + LogHelper.getStackDescription(recipe.getOutput()), + LogHelper.getStackDescription(recipe.getInput()), + recipe.getManaToConsume())); } } - - if(args.isEmpty() || args.contains("PureDaisy")) { - for(RecipePureDaisy recipe : BotaniaAPI.pureDaisyRecipes) { - MineTweakerAPI.logCommand(String.format("mods.botania.PureDaisy.addRecipe(%s, %s);", - LogHelper.getStackDescription(recipe.getInput()), - LogHelper.getStackDescription(new ItemStack(recipe.getOutput(), 1, recipe.getOutputMeta())))); + + if (args.isEmpty() || args.contains("PureDaisy")) { + for (RecipePureDaisy recipe : BotaniaAPI.pureDaisyRecipes) { + MineTweakerAPI.logCommand( + String.format( + "mods.botania.PureDaisy.addRecipe(%s, %s);", + LogHelper.getStackDescription(recipe.getInput()), + LogHelper.getStackDescription( + new ItemStack(recipe.getOutput(), 1, recipe.getOutputMeta())))); } } - - if(args.isEmpty() || args.contains("RuneAltar")) { - for(RecipeRuneAltar recipe : BotaniaAPI.runeAltarRecipes) { - MineTweakerAPI.logCommand(String.format("mods.botania.RuneAltar.addRecipe(%s, %s, %d);", - LogHelper.getStackDescription(recipe.getOutput()), - LogHelper.getListDescription(recipe.getInputs()), - recipe.getManaUsage() - )); + + if (args.isEmpty() || args.contains("RuneAltar")) { + for (RecipeRuneAltar recipe : BotaniaAPI.runeAltarRecipes) { + MineTweakerAPI.logCommand( + String.format( + "mods.botania.RuneAltar.addRecipe(%s, %s, %d);", + LogHelper.getStackDescription(recipe.getOutput()), + LogHelper.getListDescription(recipe.getInputs()), + recipe.getManaUsage())); } } - + if (player != null) { - player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir")); + player.sendChat( + MineTweakerImplementationAPI.platform + .getMessage("List generated; see minetweaker.log in your minecraft dir")); } } } diff --git a/src/main/java/modtweaker2/mods/botania/commands/BotaniaOrechidLogger.java b/src/main/java/modtweaker2/mods/botania/commands/BotaniaOrechidLogger.java index 402dd3a..cf0663e 100644 --- a/src/main/java/modtweaker2/mods/botania/commands/BotaniaOrechidLogger.java +++ b/src/main/java/modtweaker2/mods/botania/commands/BotaniaOrechidLogger.java @@ -10,18 +10,20 @@ import vazkii.botania.api.BotaniaAPI; public class BotaniaOrechidLogger implements ICommandFunction { - @Override - public void execute(String[] arguments, IPlayer player) { + @Override + public void execute(String[] arguments, IPlayer player) { - Set keys = BotaniaAPI.oreWeights.keySet(); - System.out.println("Orechid Keys: " + keys.size()); - for (String str : BotaniaAPI.oreWeights.keySet()) { - System.out.println("Orechid Key: " + str); - MineTweakerAPI.logCommand(str + ": " + BotaniaAPI.oreWeights.get(str) + "\n"); - } + Set keys = BotaniaAPI.oreWeights.keySet(); + System.out.println("Orechid Keys: " + keys.size()); + for (String str : BotaniaAPI.oreWeights.keySet()) { + System.out.println("Orechid Key: " + str); + MineTweakerAPI.logCommand(str + ": " + BotaniaAPI.oreWeights.get(str) + "\n"); + } - if (player != null) { - player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir")); - } - } + if (player != null) { + player.sendChat( + MineTweakerImplementationAPI.platform + .getMessage("List generated; see minetweaker.log in your minecraft dir")); + } + } } diff --git a/src/main/java/modtweaker2/mods/botania/handlers/Apothecary.java b/src/main/java/modtweaker2/mods/botania/handlers/Apothecary.java index d61b4ae..0e7b2cc 100644 --- a/src/main/java/modtweaker2/mods/botania/handlers/Apothecary.java +++ b/src/main/java/modtweaker2/mods/botania/handlers/Apothecary.java @@ -22,9 +22,9 @@ import vazkii.botania.common.item.block.ItemBlockSpecialFlower; @ZenClass("mods.botania.Apothecary") public class Apothecary { - + protected static final String name = "Botania Petal"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @ZenMethod @@ -38,6 +38,7 @@ public class Apothecary { } private static class Add extends BaseListAddition { + public Add(RecipePetals recipe) { super("Botania Petal", BotaniaAPI.petalRecipes); recipes.add(recipe); @@ -55,18 +56,19 @@ public class Apothecary { public static void removeRecipe(IIngredient output) { // Get list of existing recipes, matching with parameter LinkedList result = new LinkedList(); - - for(RecipePetals entry : BotaniaAPI.petalRecipes) { - if(entry != null && entry.getOutput() != null && matches(output, toIItemStack(entry.getOutput()))) { + + for (RecipePetals entry : BotaniaAPI.petalRecipes) { + if (entry != null && entry.getOutput() != null && matches(output, toIItemStack(entry.getOutput()))) { result.add(entry); } } - + // Check if we found the recipes and apply the action - if(!result.isEmpty()) { + if (!result.isEmpty()) { MineTweakerAPI.apply(new Remove(result)); } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Apothecary.name, output.toString())); + LogHelper.logWarning( + String.format("No %s Recipe found for %s. Command ignored!", Apothecary.name, output.toString())); } } @@ -76,6 +78,7 @@ public class Apothecary { } private static class Remove extends BaseListRemoval { + public Remove(List recipes) { super(Apothecary.name, BotaniaAPI.petalRecipes, recipes); } diff --git a/src/main/java/modtweaker2/mods/botania/handlers/Brew.java b/src/main/java/modtweaker2/mods/botania/handlers/Brew.java index e325dda..cb5d3d3 100644 --- a/src/main/java/modtweaker2/mods/botania/handlers/Brew.java +++ b/src/main/java/modtweaker2/mods/botania/handlers/Brew.java @@ -19,27 +19,27 @@ import vazkii.botania.api.recipe.RecipeBrew; @ZenClass("mods.botania.Brew") public class Brew { - + public static final String name = "Botania Brew"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @ZenMethod public static void addRecipe(IIngredient[] inputItems, String brewName) { - if(inputItems == null || inputItems.length == 0 || brewName == null || brewName.length() == 0) { + if (inputItems == null || inputItems.length == 0 || brewName == null || brewName.length() == 0) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - - if(!BotaniaAPI.brewMap.containsKey(brewName)) { + + if (!BotaniaAPI.brewMap.containsKey(brewName)) { LogHelper.logError(String.format("Unknown brew name \"%s\" for %s recipe.", brewName, name)); } - + RecipeBrew recipe = new RecipeBrew(BotaniaAPI.brewMap.get(brewName), InputHelper.toObjects(inputItems)); - + MineTweakerAPI.apply(new Add(recipe)); } - + private static class Add extends BaseListAddition { protected Add(RecipeBrew recipe) { @@ -50,36 +50,36 @@ public class Brew { @Override protected String getRecipeInfo(RecipeBrew recipe) { return recipe.getBrew().getKey(); - } + } } - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @ZenMethod public static void removeRecipe(String brewName) { List recipes = new LinkedList(); Matcher matcher = Pattern.compile(StringHelper.wildcardToRegex(brewName)).matcher(""); - - for(RecipeBrew recipe : BotaniaAPI.brewRecipes) { + + for (RecipeBrew recipe : BotaniaAPI.brewRecipes) { matcher.reset(recipe.getBrew().getKey()); - if(matcher.matches()) { + if (matcher.matches()) { recipes.add(recipe); } } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new Remove(recipes)); } else { LogHelper.logWarning(String.format("No %s recipe found for %s. Command ignored!", name, brewName)); } } - + public static class Remove extends BaseListRemoval { - + protected Remove(List recipes) { super(Brew.name, BotaniaAPI.brewRecipes, recipes); } - + @Override protected String getRecipeInfo(RecipeBrew recipe) { return recipe.getBrew().getKey(); diff --git a/src/main/java/modtweaker2/mods/botania/handlers/ElvenTrade.java b/src/main/java/modtweaker2/mods/botania/handlers/ElvenTrade.java index 78cfcde..1da3a1d 100644 --- a/src/main/java/modtweaker2/mods/botania/handlers/ElvenTrade.java +++ b/src/main/java/modtweaker2/mods/botania/handlers/ElvenTrade.java @@ -21,17 +21,18 @@ import vazkii.botania.api.recipe.RecipeElvenTrade; @ZenClass("mods.botania.ElvenTrade") public class ElvenTrade { - + protected static final String name = "Botania Eleven Trade"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @ZenMethod public static void addRecipe(IItemStack output, IIngredient[] input) { MineTweakerAPI.apply(new Add(new RecipeElvenTrade(toStack(output), toObjects(input)))); } private static class Add extends BaseListAddition { + public Add(RecipeElvenTrade recipe) { super(ElvenTrade.name, BotaniaAPI.elvenTradeRecipes); recipes.add(recipe); @@ -49,22 +50,24 @@ public class ElvenTrade { public static void removeRecipe(IIngredient output) { // Get list of existing recipes, matching with parameter LinkedList recipes = new LinkedList(); - - for(RecipeElvenTrade entry : BotaniaAPI.elvenTradeRecipes) { - if(entry != null && entry.getOutput() != null && matches(output, toIItemStack(entry.getOutput()))) { + + for (RecipeElvenTrade entry : BotaniaAPI.elvenTradeRecipes) { + if (entry != null && entry.getOutput() != null && matches(output, toIItemStack(entry.getOutput()))) { recipes.add(entry); } } - + // Check if we found the recipes and apply the action - if(!recipes.isEmpty()) { + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new Remove(recipes)); } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", ElvenTrade.name, output.toString())); + LogHelper.logWarning( + String.format("No %s Recipe found for %s. Command ignored!", ElvenTrade.name, output.toString())); } } private static class Remove extends BaseListRemoval { + public Remove(List recipes) { super(ElvenTrade.name, BotaniaAPI.elvenTradeRecipes, recipes); } diff --git a/src/main/java/modtweaker2/mods/botania/handlers/Lexicon.java b/src/main/java/modtweaker2/mods/botania/handlers/Lexicon.java index b0b910e..1a2c9f0 100644 --- a/src/main/java/modtweaker2/mods/botania/handlers/Lexicon.java +++ b/src/main/java/modtweaker2/mods/botania/handlers/Lexicon.java @@ -7,8 +7,6 @@ import static modtweaker2.helpers.InputHelper.toStack; import java.util.ArrayList; import java.util.List; -import net.minecraft.item.ItemStack; -import net.minecraft.init.Blocks; import minetweaker.MineTweakerAPI; import minetweaker.api.item.IIngredient; import minetweaker.api.item.IItemStack; @@ -26,8 +24,10 @@ import modtweaker2.mods.botania.lexicon.RemoveRecipeMapping; import modtweaker2.mods.botania.lexicon.SetCategoryIcon; import modtweaker2.mods.botania.lexicon.SetCategoryPriority; import modtweaker2.mods.botania.lexicon.SetEntryKnowledgeType; + import net.minecraft.entity.EntityList; import net.minecraft.item.crafting.IRecipe; + import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; import vazkii.botania.api.BotaniaAPI; @@ -56,417 +56,379 @@ import vazkii.botania.common.lexicon.page.PageText; public class Lexicon { @ZenMethod - public static void addBrewPage(String name, String entry, int page_number, String brew, IIngredient[] recipe, String bottomText) { - LexiconEntry lexiconEntry=BotaniaHelper.findEntry(entry); - if(lexiconEntry==null) - { - MineTweakerAPI.getLogger().logError("Cannot find lexicon entry "+entry); - return; - } - if(page_number>lexiconEntry.pages.size()) - { - MineTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for "+entry); - return; - } - if(BotaniaAPI.getBrewFromKey(brew)==null) - { - MineTweakerAPI.getLogger().logError("Cannot find brew "+brew); - return; - } - RecipeBrew page_recipe=new RecipeBrew(BotaniaAPI.getBrewFromKey(brew),toObjects(recipe)); - LexiconPage page=new PageBrew(page_recipe,name,bottomText); - MineTweakerAPI.apply(new AddPage(name,lexiconEntry,page,page_number)); + public static void addBrewPage(String name, String entry, int page_number, String brew, IIngredient[] recipe, + String bottomText) { + LexiconEntry lexiconEntry = BotaniaHelper.findEntry(entry); + if (lexiconEntry == null) { + MineTweakerAPI.getLogger().logError("Cannot find lexicon entry " + entry); + return; + } + if (page_number > lexiconEntry.pages.size()) { + MineTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for " + entry); + return; + } + if (BotaniaAPI.getBrewFromKey(brew) == null) { + MineTweakerAPI.getLogger().logError("Cannot find brew " + brew); + return; + } + RecipeBrew page_recipe = new RecipeBrew(BotaniaAPI.getBrewFromKey(brew), toObjects(recipe)); + LexiconPage page = new PageBrew(page_recipe, name, bottomText); + MineTweakerAPI.apply(new AddPage(name, lexiconEntry, page, page_number)); } @ZenMethod - public static void addCraftingPage(String name, String entry, int page_number, IItemStack[] outputs, IIngredient[][][] inputs) { - LexiconEntry lexiconEntry=BotaniaHelper.findEntry(entry); - if(lexiconEntry==null) - { - MineTweakerAPI.getLogger().logError("Cannot find lexicon entry "+entry); - return; - } - if(page_number>lexiconEntry.pages.size()) - { - MineTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for "+entry); - return; - } - if(outputs.length!=inputs.length) - { - MineTweakerAPI.getLogger().logError("Length of input and output must match"); - return; - } - List recipes=new ArrayList(); - for(int i=0;i lexiconEntry.pages.size()) { + MineTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for " + entry); + return; + } + if (outputs.length != inputs.length) { + MineTweakerAPI.getLogger().logError("Length of input and output must match"); + return; + } + List recipes = new ArrayList(); + for (int i = 0; i < outputs.length; i++) { + recipes.add(RecipeConverter.convert(new ShapedRecipe(outputs[i], inputs[i], null, false))); + } + LexiconPage page = new PageCraftingRecipe(name, recipes); + MineTweakerAPI.apply(new AddPage(name, lexiconEntry, page, page_number)); } - + @ZenMethod - public static void addElvenPage(String name, String entry, int page_number, IItemStack[] outputs, IIngredient[][] inputs) { - LexiconEntry lexiconEntry=BotaniaHelper.findEntry(entry); - if(lexiconEntry==null) - { - MineTweakerAPI.getLogger().logError("Cannot find lexicon entry "+entry); - return; - } - if(page_number>lexiconEntry.pages.size()) - { - MineTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for "+entry); - return; - } - if(outputs.length!=inputs.length) - { - MineTweakerAPI.getLogger().logError("Length of input and output must match"); - return; - } - List recipes=new ArrayList(); - for(int i=0;i lexiconEntry.pages.size()) { + MineTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for " + entry); + return; + } + if (outputs.length != inputs.length) { + MineTweakerAPI.getLogger().logError("Length of input and output must match"); + return; + } + List recipes = new ArrayList(); + for (int i = 0; i < outputs.length; i++) { + recipes.add(new RecipeElvenTrade(toStack(outputs[i]), toObjects(inputs[i]))); + } + LexiconPage page = new PageElvenRecipe(name, recipes); + MineTweakerAPI.apply(new AddPage(name, lexiconEntry, page, page_number)); } - + @ZenMethod public static void addEntityPage(String name, String entry, int page_number, String entity, int size) { - LexiconEntry lexiconEntry=BotaniaHelper.findEntry(entry); - if(lexiconEntry==null) - { - MineTweakerAPI.getLogger().logError("Cannot find lexicon entry "+entry); - return; - } - if(page_number>lexiconEntry.pages.size()) - { - MineTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for "+entry); - return; - } - if(!EntityList.stringToClassMapping.containsKey(entity)) - { - MineTweakerAPI.getLogger().logError("No such entity "+entity); - return; - } - LexiconPage page=new PageEntity(entity, entity, size); - MineTweakerAPI.apply(new AddPage(name,lexiconEntry,page,page_number)); + LexiconEntry lexiconEntry = BotaniaHelper.findEntry(entry); + if (lexiconEntry == null) { + MineTweakerAPI.getLogger().logError("Cannot find lexicon entry " + entry); + return; + } + if (page_number > lexiconEntry.pages.size()) { + MineTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for " + entry); + return; + } + if (!EntityList.stringToClassMapping.containsKey(entity)) { + MineTweakerAPI.getLogger().logError("No such entity " + entity); + return; + } + LexiconPage page = new PageEntity(entity, entity, size); + MineTweakerAPI.apply(new AddPage(name, lexiconEntry, page, page_number)); } - + @ZenMethod public static void addImagePage(String name, String entry, int page_number, String resource) { - LexiconEntry lexiconEntry=BotaniaHelper.findEntry(entry); - if(lexiconEntry==null) - { - MineTweakerAPI.getLogger().logError("Cannot find lexicon entry "+entry); - return; - } - if(page_number>lexiconEntry.pages.size()) - { - MineTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for "+entry); - return; - } - LexiconPage page=new PageImage(name, resource); - MineTweakerAPI.apply(new AddPage(name,lexiconEntry,page,page_number)); + LexiconEntry lexiconEntry = BotaniaHelper.findEntry(entry); + if (lexiconEntry == null) { + MineTweakerAPI.getLogger().logError("Cannot find lexicon entry " + entry); + return; + } + if (page_number > lexiconEntry.pages.size()) { + MineTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for " + entry); + return; + } + LexiconPage page = new PageImage(name, resource); + MineTweakerAPI.apply(new AddPage(name, lexiconEntry, page, page_number)); } - + @ZenMethod public static void addLorePage(String name, String entry, int page_number) { - LexiconEntry lexiconEntry=BotaniaHelper.findEntry(entry); - if(lexiconEntry==null) - { - MineTweakerAPI.getLogger().logError("Cannot find lexicon entry "+entry); - return; - } - if(page_number>lexiconEntry.pages.size()) - { - MineTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for "+entry); - return; - } - LexiconPage page=new PageLoreText(name); - MineTweakerAPI.apply(new AddPage(name,lexiconEntry,page,page_number)); + LexiconEntry lexiconEntry = BotaniaHelper.findEntry(entry); + if (lexiconEntry == null) { + MineTweakerAPI.getLogger().logError("Cannot find lexicon entry " + entry); + return; + } + if (page_number > lexiconEntry.pages.size()) { + MineTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for " + entry); + return; + } + LexiconPage page = new PageLoreText(name); + MineTweakerAPI.apply(new AddPage(name, lexiconEntry, page, page_number)); } @ZenMethod - public static void addInfusionPage(String name, String entry, int page_number, IItemStack[] outputs, IIngredient[] inputs, int[] mana) { - LexiconEntry lexiconEntry=BotaniaHelper.findEntry(entry); - if(lexiconEntry==null) - { - MineTweakerAPI.getLogger().logError("Cannot find lexicon entry "+entry); - return; - } - if(page_number>lexiconEntry.pages.size()) - { - MineTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for "+entry); - return; - } - if(outputs.length!=inputs.length || outputs.length!=mana.length) - { - MineTweakerAPI.getLogger().logError("Length of input and output must match"); - return; - } - List recipes=new ArrayList(); - for(int i=0;i lexiconEntry.pages.size()) { + MineTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for " + entry); + return; + } + if (outputs.length != inputs.length || outputs.length != mana.length) { + MineTweakerAPI.getLogger().logError("Length of input and output must match"); + return; + } + List recipes = new ArrayList(); + for (int i = 0; i < outputs.length; i++) { + recipes.add(new RecipeManaInfusion(toStack(outputs[i]), toObject(inputs[i]), mana[i])); + } + LexiconPage page = new PageManaInfusionRecipe(name, recipes); + MineTweakerAPI.apply(new AddPage(name, lexiconEntry, page, page_number)); } @ZenMethod - public static void addAlchemyPage(String name, String entry, int page_number, IItemStack[] outputs, IIngredient[] inputs, int[] mana) { - LexiconEntry lexiconEntry=BotaniaHelper.findEntry(entry); - if(lexiconEntry==null) - { - MineTweakerAPI.getLogger().logError("Cannot find lexicon entry "+entry); - return; - } - if(page_number>lexiconEntry.pages.size()) - { - MineTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for "+entry); - return; - } - if(outputs.length!=inputs.length || outputs.length!=mana.length) - { - MineTweakerAPI.getLogger().logError("Length of input and output must match"); - return; - } - List recipes=new ArrayList(); - for(int i=0;i lexiconEntry.pages.size()) { + MineTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for " + entry); + return; + } + if (outputs.length != inputs.length || outputs.length != mana.length) { + MineTweakerAPI.getLogger().logError("Length of input and output must match"); + return; + } + List recipes = new ArrayList(); + for (int i = 0; i < outputs.length; i++) { + RecipeManaInfusion current_recipe = new RecipeManaInfusion( + toStack(outputs[i]), + toObject(inputs[i]), + mana[i]); + current_recipe.setAlchemy(true); + recipes.add(current_recipe); + } + LexiconPage page = new PageManaInfusionRecipe(name, recipes); + MineTweakerAPI.apply(new AddPage(name, lexiconEntry, page, page_number)); } @ZenMethod - public static void addConjurationPage(String name, String entry, int page_number, IItemStack[] outputs, IIngredient[] inputs, int[] mana) { - LexiconEntry lexiconEntry=BotaniaHelper.findEntry(entry); - if(lexiconEntry==null) - { - MineTweakerAPI.getLogger().logError("Cannot find lexicon entry "+entry); - return; - } - if(page_number>lexiconEntry.pages.size()) - { - MineTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for "+entry); - return; - } - if(outputs.length!=inputs.length || outputs.length!=mana.length) - { - MineTweakerAPI.getLogger().logError("Length of input and output must match"); - return; - } - List recipes=new ArrayList(); - for(int i=0;i lexiconEntry.pages.size()) { + MineTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for " + entry); + return; + } + if (outputs.length != inputs.length || outputs.length != mana.length) { + MineTweakerAPI.getLogger().logError("Length of input and output must match"); + return; + } + List recipes = new ArrayList(); + for (int i = 0; i < outputs.length; i++) { + RecipeManaInfusion current_recipe = new RecipeManaInfusion( + toStack(outputs[i]), + toObject(inputs[i]), + mana[i]); + current_recipe.setConjuration(true); + recipes.add(current_recipe); + } + LexiconPage page = new PageManaInfusionRecipe(name, recipes); + MineTweakerAPI.apply(new AddPage(name, lexiconEntry, page, page_number)); } @ZenMethod - public static void addPetalPage(String name, String entry, int page_number, IItemStack[] outputs, IIngredient[][] inputs) { - LexiconEntry lexiconEntry=BotaniaHelper.findEntry(entry); - if(lexiconEntry==null) - { - MineTweakerAPI.getLogger().logError("Cannot find lexicon entry "+entry); - return; - } - if(page_number>lexiconEntry.pages.size()) - { - MineTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for "+entry); - return; - } - if(outputs.length!=inputs.length) - { - MineTweakerAPI.getLogger().logError("Length of input and output must match"); - return; - } - List recipes=new ArrayList(); - for(int i=0;i lexiconEntry.pages.size()) { + MineTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for " + entry); + return; + } + if (outputs.length != inputs.length) { + MineTweakerAPI.getLogger().logError("Length of input and output must match"); + return; + } + List recipes = new ArrayList(); + for (int i = 0; i < outputs.length; i++) { + recipes.add(new RecipePetals(toStack(outputs[i]), toObjects(inputs[i]))); + } + LexiconPage page = new PagePetalRecipe(name, recipes); + MineTweakerAPI.apply(new AddPage(name, lexiconEntry, page, page_number)); } @ZenMethod - public static void addRunePage(String name, String entry, int page_number, IItemStack[] outputs, IIngredient[][] inputs, int[] mana) { - LexiconEntry lexiconEntry=BotaniaHelper.findEntry(entry); - if(lexiconEntry==null) - { - MineTweakerAPI.getLogger().logError("Cannot find lexicon entry "+entry); - return; - } - if(page_number>lexiconEntry.pages.size()) - { - MineTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for "+entry); - return; - } - if(outputs.length!=inputs.length || outputs.length!=mana.length) - { - MineTweakerAPI.getLogger().logError("Length of input and output must match"); - return; - } - List recipes=new ArrayList(); - for(int i=0;i lexiconEntry.pages.size()) { + MineTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for " + entry); + return; + } + if (outputs.length != inputs.length || outputs.length != mana.length) { + MineTweakerAPI.getLogger().logError("Length of input and output must match"); + return; + } + List recipes = new ArrayList(); + for (int i = 0; i < outputs.length; i++) { + recipes.add(new RecipeRuneAltar(toStack(outputs[i]), mana[i], toObjects(inputs[i]))); + } + LexiconPage page = new PageRuneRecipe(name, recipes); + MineTweakerAPI.apply(new AddPage(name, lexiconEntry, page, page_number)); } @ZenMethod public static void addTextPage(String name, String entry, int page_number) { - LexiconEntry lexiconEntry=BotaniaHelper.findEntry(entry); - if(lexiconEntry==null) - { - MineTweakerAPI.getLogger().logError("Cannot find lexicon entry "+entry); - return; - } - if(page_number>lexiconEntry.pages.size()) - { - MineTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for "+entry); - return; - } - LexiconPage page=new PageText(name); - MineTweakerAPI.apply(new AddPage(name,lexiconEntry,page,page_number)); + LexiconEntry lexiconEntry = BotaniaHelper.findEntry(entry); + if (lexiconEntry == null) { + MineTweakerAPI.getLogger().logError("Cannot find lexicon entry " + entry); + return; + } + if (page_number > lexiconEntry.pages.size()) { + MineTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for " + entry); + return; + } + LexiconPage page = new PageText(name); + MineTweakerAPI.apply(new AddPage(name, lexiconEntry, page, page_number)); } @ZenMethod public static void removePage(String entry, int page_number) { - LexiconEntry lexiconEntry=BotaniaHelper.findEntry(entry); - if(lexiconEntry==null) - { - MineTweakerAPI.getLogger().logError("Cannot find lexicon entry "+entry); - return; - } - if(page_number>=lexiconEntry.pages.size()) - { - MineTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for "+entry); - return; - } - MineTweakerAPI.apply(new RemovePage(lexiconEntry,page_number)); + LexiconEntry lexiconEntry = BotaniaHelper.findEntry(entry); + if (lexiconEntry == null) { + MineTweakerAPI.getLogger().logError("Cannot find lexicon entry " + entry); + return; + } + if (page_number >= lexiconEntry.pages.size()) { + MineTweakerAPI.getLogger().logError("Page Number " + page_number + " out of bounds for " + entry); + return; + } + MineTweakerAPI.apply(new RemovePage(lexiconEntry, page_number)); } @ZenMethod public static void addEntry(String entry, String catagory, IItemStack stack) { - LexiconCategory lexiconCategory=BotaniaHelper.findCatagory(catagory); - if(lexiconCategory==null) - { - MineTweakerAPI.getLogger().logError("Cannot find lexicon category "+catagory); - return; - } - LexiconEntry lexiconEntry=new LexiconEntry(entry,lexiconCategory); - lexiconEntry.setIcon(toStack(stack)); + LexiconCategory lexiconCategory = BotaniaHelper.findCatagory(catagory); + if (lexiconCategory == null) { + MineTweakerAPI.getLogger().logError("Cannot find lexicon category " + catagory); + return; + } + LexiconEntry lexiconEntry = new LexiconEntry(entry, lexiconCategory); + lexiconEntry.setIcon(toStack(stack)); MineTweakerAPI.apply(new AddEntry(lexiconEntry)); } + @ZenMethod public static void removeEntry(String entry) { - LexiconEntry lexiconEntry=BotaniaHelper.findEntry(entry); - if(lexiconEntry==null) - { - MineTweakerAPI.getLogger().logError("Cannot find lexicon entry "+entry); - return; - } + LexiconEntry lexiconEntry = BotaniaHelper.findEntry(entry); + if (lexiconEntry == null) { + MineTweakerAPI.getLogger().logError("Cannot find lexicon entry " + entry); + return; + } MineTweakerAPI.apply(new RemoveEntry(lexiconEntry)); } - + @ZenMethod public static void setEntryKnowledgeType(String entry, String knowledgeType) { - LexiconEntry lexiconEntry=BotaniaHelper.findEntry(entry); - KnowledgeType type=BotaniaHelper.findKnowledgeType(knowledgeType); - if(lexiconEntry==null) - { - MineTweakerAPI.getLogger().logError("Cannot find lexicon entry "+entry); - return; - } - if(type==null) - { - MineTweakerAPI.getLogger().logError("Cannot find knowledge type "+knowledgeType); - return; - } - MineTweakerAPI.apply(new SetEntryKnowledgeType(lexiconEntry,type)); + LexiconEntry lexiconEntry = BotaniaHelper.findEntry(entry); + KnowledgeType type = BotaniaHelper.findKnowledgeType(knowledgeType); + if (lexiconEntry == null) { + MineTweakerAPI.getLogger().logError("Cannot find lexicon entry " + entry); + return; + } + if (type == null) { + MineTweakerAPI.getLogger().logError("Cannot find knowledge type " + knowledgeType); + return; + } + MineTweakerAPI.apply(new SetEntryKnowledgeType(lexiconEntry, type)); } - + @ZenMethod public static void addCategory(String name) { - LexiconCategory lexiconCategory=new LexiconCategory(name); + LexiconCategory lexiconCategory = new LexiconCategory(name); MineTweakerAPI.apply(new AddCategory(lexiconCategory)); } - + @ZenMethod public static void removeCategory(String name) { - LexiconCategory lexiconCategory=BotaniaHelper.findCatagory(name); - if(lexiconCategory==null) - { - MineTweakerAPI.getLogger().logError("Cannot find lexicon category "+name); - return; - } + LexiconCategory lexiconCategory = BotaniaHelper.findCatagory(name); + if (lexiconCategory == null) { + MineTweakerAPI.getLogger().logError("Cannot find lexicon category " + name); + return; + } MineTweakerAPI.apply(new RemoveCategory(lexiconCategory)); } @ZenMethod public static void setCategoryPriority(String name, int priority) { - LexiconCategory lexiconCategory=BotaniaHelper.findCatagory(name); - if(lexiconCategory==null) - { - MineTweakerAPI.getLogger().logError("Cannot find lexicon category "+name); - return; - } - MineTweakerAPI.apply(new SetCategoryPriority(lexiconCategory,priority)); + LexiconCategory lexiconCategory = BotaniaHelper.findCatagory(name); + if (lexiconCategory == null) { + MineTweakerAPI.getLogger().logError("Cannot find lexicon category " + name); + return; + } + MineTweakerAPI.apply(new SetCategoryPriority(lexiconCategory, priority)); } - + @ZenMethod public static void setCategoryIcon(String name, String icon) { - LexiconCategory lexiconCategory=BotaniaHelper.findCatagory(name); - if(lexiconCategory==null) - { - MineTweakerAPI.getLogger().logError("Cannot find lexicon category "+name); - return; - } - MineTweakerAPI.apply(new SetCategoryIcon(lexiconCategory,icon)); + LexiconCategory lexiconCategory = BotaniaHelper.findCatagory(name); + if (lexiconCategory == null) { + MineTweakerAPI.getLogger().logError("Cannot find lexicon category " + name); + return; + } + MineTweakerAPI.apply(new SetCategoryIcon(lexiconCategory, icon)); } @ZenMethod public static void addRecipeMapping(IItemStack stack, String Entry, int page) { - LexiconEntry lexiconEntry=BotaniaHelper.findEntry(Entry); - if(LexiconRecipeMappings.getDataForStack(toStack(stack))!=null) - { - MineTweakerAPI.getLogger().logError("There is already a recipe mapping for "+stack); - return; - } - if(lexiconEntry==null) - { - MineTweakerAPI.getLogger().logError("Cannot find lexicon entry "+Entry); - return; - } - if(lexiconEntry.pages.size() { + public Add(RecipeManaInfusion recipe) { super(ManaInfusion.name, BotaniaAPI.manaInfusionRecipes); recipes.add(recipe); @@ -62,22 +62,24 @@ public class ManaInfusion { public static void removeRecipe(IIngredient output) { // Get list of existing recipes, matching with parameter List recipes = new LinkedList(); - + for (RecipeManaInfusion r : BotaniaAPI.manaInfusionRecipes) { if (r.getOutput() != null && matches(output, toIItemStack(r.getOutput()))) { recipes.add(r); } } - + // Check if we found the recipes and apply the action - if(!recipes.isEmpty()) { + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new Remove(recipes)); } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", ManaInfusion.name, output.toString())); + LogHelper.logWarning( + String.format("No %s Recipe found for %s. Command ignored!", ManaInfusion.name, output.toString())); } } private static class Remove extends BaseListRemoval { + public Remove(List recipes) { super(ManaInfusion.name, BotaniaAPI.manaInfusionRecipes, recipes); } diff --git a/src/main/java/modtweaker2/mods/botania/handlers/Orechid.java b/src/main/java/modtweaker2/mods/botania/handlers/Orechid.java index fa83f86..4946df3 100644 --- a/src/main/java/modtweaker2/mods/botania/handlers/Orechid.java +++ b/src/main/java/modtweaker2/mods/botania/handlers/Orechid.java @@ -9,6 +9,7 @@ import vazkii.botania.api.BotaniaAPI; @ZenClass("mods.botania.Orechid") public class Orechid { + @ZenMethod public static void addOre(IOreDictEntry oreDict, int weight) { MineTweakerAPI.apply(new Add(oreDict.getName(), weight)); @@ -20,6 +21,7 @@ public class Orechid { } private static class Add implements IUndoableAction { + String oreDict; int weight; @@ -72,6 +74,7 @@ public class Orechid { } private static class Remove implements IUndoableAction { + String oreDict; int weight; diff --git a/src/main/java/modtweaker2/mods/botania/handlers/PureDaisy.java b/src/main/java/modtweaker2/mods/botania/handlers/PureDaisy.java index 2c4fdd6..7d4046a 100644 --- a/src/main/java/modtweaker2/mods/botania/handlers/PureDaisy.java +++ b/src/main/java/modtweaker2/mods/botania/handlers/PureDaisy.java @@ -11,8 +11,10 @@ import modtweaker2.helpers.LogHelper; import modtweaker2.helpers.StackHelper; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; + import net.minecraft.block.Block; import net.minecraft.item.ItemStack; + import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; import vazkii.botania.api.BotaniaAPI; @@ -20,71 +22,76 @@ import vazkii.botania.api.recipe.RecipePureDaisy; @ZenClass("mods.botania.PureDaisy") public class PureDaisy { - + public static final String name = "Botania PureDaisy"; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @ZenMethod public static void addRecipe(IIngredient blockInput, IItemStack blockOutput) { - if(blockInput == null || blockOutput == null) { + if (blockInput == null || blockOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - + Object input = InputHelper.toObject(blockInput); - - if(input == null || (input instanceof ItemStack && !InputHelper.isABlock((ItemStack)input))) { + + if (input == null || (input instanceof ItemStack && !InputHelper.isABlock((ItemStack) input))) { LogHelper.logError(String.format("Input must be a block or an oredict entry.")); return; } - - if(input instanceof ItemStack) input = Block.getBlockFromItem(((ItemStack)input).getItem()); + + if (input instanceof ItemStack) input = Block.getBlockFromItem(((ItemStack) input).getItem()); ItemStack output = InputHelper.toStack(blockOutput); - - RecipePureDaisy recipe = new RecipePureDaisy(input, Block.getBlockFromItem(output.getItem()), output.getItemDamage()); - + + RecipePureDaisy recipe = new RecipePureDaisy( + input, + Block.getBlockFromItem(output.getItem()), + output.getItemDamage()); + MineTweakerAPI.apply(new Add(recipe)); } - + private static class Add extends BaseListAddition { + public Add(RecipePureDaisy recipe) { super(PureDaisy.name, BotaniaAPI.pureDaisyRecipes); recipes.add(recipe); } - + @Override protected String getRecipeInfo(RecipePureDaisy recipe) { return LogHelper.getStackDescription(new ItemStack(recipe.getOutput(), 1, recipe.getOutputMeta())); } } - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @ZenMethod public static void removeRecipe(IIngredient output) { List recipes = new LinkedList(); - - for(RecipePureDaisy recipe : BotaniaAPI.pureDaisyRecipes) { + + for (RecipePureDaisy recipe : BotaniaAPI.pureDaisyRecipes) { IItemStack out = InputHelper.toIItemStack(new ItemStack(recipe.getOutput(), 1, recipe.getOutputMeta())); - - if(StackHelper.matches(output, out)) { + + if (StackHelper.matches(output, out)) { recipes.add(recipe); } } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new Remove(recipes)); } else { - + } } - + private static class Remove extends BaseListRemoval { + public Remove(List recipes) { super(PureDaisy.name, BotaniaAPI.pureDaisyRecipes, recipes); } - + @Override protected String getRecipeInfo(RecipePureDaisy recipe) { return LogHelper.getStackDescription(new ItemStack(recipe.getOutput(), 1, recipe.getOutputMeta())); diff --git a/src/main/java/modtweaker2/mods/botania/handlers/RuneAltar.java b/src/main/java/modtweaker2/mods/botania/handlers/RuneAltar.java index 51bf2eb..9cde322 100644 --- a/src/main/java/modtweaker2/mods/botania/handlers/RuneAltar.java +++ b/src/main/java/modtweaker2/mods/botania/handlers/RuneAltar.java @@ -21,20 +21,21 @@ import vazkii.botania.api.recipe.RecipeRuneAltar; @ZenClass("mods.botania.RuneAltar") public class RuneAltar { - + protected static final String name = "Botania Rune Altar"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @ZenMethod public static void addRecipe(IItemStack output, IIngredient[] input, int mana) { MineTweakerAPI.apply(new Add(new RecipeRuneAltar(toStack(output), mana, toObjects(input)))); } private static class Add extends BaseListAddition { + public Add(RecipeRuneAltar recipe) { super(RuneAltar.name, BotaniaAPI.runeAltarRecipes); - + recipes.add(recipe); } @@ -50,22 +51,24 @@ public class RuneAltar { public static void removeRecipe(IIngredient output) { // Get list of existing recipes, matching with parameter List recipes = new LinkedList(); - + for (RecipeRuneAltar r : BotaniaAPI.runeAltarRecipes) { if (r != null && r.getOutput() != null && matches(output, toIItemStack(r.getOutput()))) { recipes.add(r); } } - + // Check if we found the recipes and apply the action - if(!recipes.isEmpty()) { + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new Remove(recipes)); } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", ElvenTrade.name, output.toString())); + LogHelper.logWarning( + String.format("No %s Recipe found for %s. Command ignored!", ElvenTrade.name, output.toString())); } } private static class Remove extends BaseListRemoval { + public Remove(List recipes) { super(RuneAltar.name, BotaniaAPI.runeAltarRecipes, recipes); } diff --git a/src/main/java/modtweaker2/mods/botania/lexicon/AddCategory.java b/src/main/java/modtweaker2/mods/botania/lexicon/AddCategory.java index 9747066..6a31f66 100644 --- a/src/main/java/modtweaker2/mods/botania/lexicon/AddCategory.java +++ b/src/main/java/modtweaker2/mods/botania/lexicon/AddCategory.java @@ -5,40 +5,40 @@ import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.lexicon.LexiconCategory; public class AddCategory implements IUndoableAction { - - LexiconCategory category; + + LexiconCategory category; public AddCategory(LexiconCategory category) { - this.category=category; + this.category = category; } @Override - public void apply() { - BotaniaAPI.addCategory(category); - } + public void apply() { + BotaniaAPI.addCategory(category); + } - @Override - public boolean canUndo() { + @Override + public boolean canUndo() { return category != null; - } - - @Override - public String describe() { + } + + @Override + public String describe() { return "Adding Lexicon Category: " + category.getUnlocalizedName(); - } - - @Override - public String describeUndo() { + } + + @Override + public String describeUndo() { return "Removing Lexicon Category: " + category.getUnlocalizedName(); - } - - @Override - public void undo() { - BotaniaAPI.getAllCategories().remove(category); - } - - @Override - public Object getOverrideKey() { - return null; - } + } + + @Override + public void undo() { + BotaniaAPI.getAllCategories().remove(category); + } + + @Override + public Object getOverrideKey() { + return null; + } } diff --git a/src/main/java/modtweaker2/mods/botania/lexicon/AddEntry.java b/src/main/java/modtweaker2/mods/botania/lexicon/AddEntry.java index b3c4068..b746aca 100644 --- a/src/main/java/modtweaker2/mods/botania/lexicon/AddEntry.java +++ b/src/main/java/modtweaker2/mods/botania/lexicon/AddEntry.java @@ -5,41 +5,41 @@ import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.lexicon.LexiconEntry; public class AddEntry implements IUndoableAction { - - LexiconEntry Entry; + + LexiconEntry Entry; public AddEntry(LexiconEntry Entry) { - this.Entry=Entry; + this.Entry = Entry; } @Override - public void apply() { - BotaniaAPI.addEntry(Entry, Entry.category); - } + public void apply() { + BotaniaAPI.addEntry(Entry, Entry.category); + } - @Override - public boolean canUndo() { + @Override + public boolean canUndo() { return Entry != null; - } - - @Override - public String describe() { + } + + @Override + public String describe() { return "Adding Lexicon Entry: " + Entry.getUnlocalizedName(); - } - - @Override - public String describeUndo() { + } + + @Override + public String describeUndo() { return "Removing Lexicon Entry: " + Entry.getUnlocalizedName(); - } - - @Override - public void undo() { - Entry.category.entries.remove(Entry); - BotaniaAPI.getAllEntries().remove(Entry); - } - - @Override - public Object getOverrideKey() { - return null; - } + } + + @Override + public void undo() { + Entry.category.entries.remove(Entry); + BotaniaAPI.getAllEntries().remove(Entry); + } + + @Override + public Object getOverrideKey() { + return null; + } } diff --git a/src/main/java/modtweaker2/mods/botania/lexicon/AddPage.java b/src/main/java/modtweaker2/mods/botania/lexicon/AddPage.java index af5f0cf..c3d9225 100644 --- a/src/main/java/modtweaker2/mods/botania/lexicon/AddPage.java +++ b/src/main/java/modtweaker2/mods/botania/lexicon/AddPage.java @@ -5,46 +5,46 @@ import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.lexicon.LexiconPage; public class AddPage implements IUndoableAction { - - String Name; - int page_number; - LexiconEntry Entry; - LexiconPage page; + + String Name; + int page_number; + LexiconEntry Entry; + LexiconPage page; public AddPage(String Name, LexiconEntry Entry, LexiconPage page, int page_number) { - this.Name=Name; - this.Entry=Entry; - this.page=page; - this.page_number=page_number; + this.Name = Name; + this.Entry = Entry; + this.page = page; + this.page_number = page_number; } @Override - public void apply() { - Entry.pages.add(page_number, page); - } + public void apply() { + Entry.pages.add(page_number, page); + } - @Override - public boolean canUndo() { + @Override + public boolean canUndo() { return Name != null && Entry != null && page != null; - } - - @Override - public String describe() { + } + + @Override + public String describe() { return "Adding Lexicon Page: " + Name; - } - - @Override - public String describeUndo() { + } + + @Override + public String describeUndo() { return "Removing Lexicon Page: " + Name; - } - - @Override - public void undo() { - Entry.pages.remove(page_number); - } - - @Override - public Object getOverrideKey() { - return null; - } + } + + @Override + public void undo() { + Entry.pages.remove(page_number); + } + + @Override + public Object getOverrideKey() { + return null; + } } diff --git a/src/main/java/modtweaker2/mods/botania/lexicon/AddRecipeMapping.java b/src/main/java/modtweaker2/mods/botania/lexicon/AddRecipeMapping.java index 90b3f67..65eacdf 100644 --- a/src/main/java/modtweaker2/mods/botania/lexicon/AddRecipeMapping.java +++ b/src/main/java/modtweaker2/mods/botania/lexicon/AddRecipeMapping.java @@ -1,49 +1,51 @@ package modtweaker2.mods.botania.lexicon; import minetweaker.IUndoableAction; + import net.minecraft.item.ItemStack; + import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.lexicon.LexiconRecipeMappings; public class AddRecipeMapping implements IUndoableAction { - - ItemStack stack; - LexiconEntry entry; - int page; + + ItemStack stack; + LexiconEntry entry; + int page; public AddRecipeMapping(ItemStack stack, LexiconEntry entry, int page) { - this.stack =stack; - this.entry=entry; - this.page=page; + this.stack = stack; + this.entry = entry; + this.page = page; } @Override - public void apply() { - LexiconRecipeMappings.map(stack, entry, page); - } + public void apply() { + LexiconRecipeMappings.map(stack, entry, page); + } - @Override - public boolean canUndo() { + @Override + public boolean canUndo() { return true; - } - - @Override - public String describe() { + } + + @Override + public String describe() { return "Adding Lexicon Recipe Lookup: " + stack.getUnlocalizedName(); - } - - @Override - public String describeUndo() { + } + + @Override + public String describeUndo() { return "Removing Lexicon Recipe Lookup: " + stack.getUnlocalizedName(); - } - - @Override - public void undo() { - LexiconRecipeMappings.remove(stack); - } - - @Override - public Object getOverrideKey() { - return null; - } + } + + @Override + public void undo() { + LexiconRecipeMappings.remove(stack); + } + + @Override + public Object getOverrideKey() { + return null; + } } diff --git a/src/main/java/modtweaker2/mods/botania/lexicon/RemoveCategory.java b/src/main/java/modtweaker2/mods/botania/lexicon/RemoveCategory.java index edbea43..6af4279 100644 --- a/src/main/java/modtweaker2/mods/botania/lexicon/RemoveCategory.java +++ b/src/main/java/modtweaker2/mods/botania/lexicon/RemoveCategory.java @@ -5,40 +5,40 @@ import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.lexicon.LexiconCategory; public class RemoveCategory implements IUndoableAction { - - LexiconCategory category; + + LexiconCategory category; public RemoveCategory(LexiconCategory category) { - this.category=category; + this.category = category; } @Override - public void apply() { - BotaniaAPI.getAllCategories().remove(category); - } + public void apply() { + BotaniaAPI.getAllCategories().remove(category); + } - @Override - public boolean canUndo() { + @Override + public boolean canUndo() { return category != null; - } - - @Override - public String describe() { + } + + @Override + public String describe() { return "Removing Lexicon Category: " + category.getUnlocalizedName(); - } - - @Override - public String describeUndo() { + } + + @Override + public String describeUndo() { return "Adding Lexicon Category: " + category.getUnlocalizedName(); - } - - @Override - public void undo() { - BotaniaAPI.addCategory(category); - } - - @Override - public Object getOverrideKey() { - return null; - } + } + + @Override + public void undo() { + BotaniaAPI.addCategory(category); + } + + @Override + public Object getOverrideKey() { + return null; + } } diff --git a/src/main/java/modtweaker2/mods/botania/lexicon/RemoveEntry.java b/src/main/java/modtweaker2/mods/botania/lexicon/RemoveEntry.java index 4c6cf13..9714cb3 100644 --- a/src/main/java/modtweaker2/mods/botania/lexicon/RemoveEntry.java +++ b/src/main/java/modtweaker2/mods/botania/lexicon/RemoveEntry.java @@ -5,41 +5,41 @@ import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.lexicon.LexiconEntry; public class RemoveEntry implements IUndoableAction { - - LexiconEntry Entry; + + LexiconEntry Entry; public RemoveEntry(LexiconEntry Entry) { - this.Entry=Entry; + this.Entry = Entry; } @Override - public void apply() { - Entry.category.entries.remove(Entry); - BotaniaAPI.getAllEntries().remove(Entry); - } + public void apply() { + Entry.category.entries.remove(Entry); + BotaniaAPI.getAllEntries().remove(Entry); + } - @Override - public boolean canUndo() { + @Override + public boolean canUndo() { return Entry != null; - } - - @Override - public String describe() { + } + + @Override + public String describe() { return "Removing Lexicon Entry: " + Entry.getUnlocalizedName(); - } - - @Override - public String describeUndo() { + } + + @Override + public String describeUndo() { return "Adding Lexicon Entry: " + Entry.getUnlocalizedName(); - } - - @Override - public void undo() { - BotaniaAPI.addEntry(Entry, Entry.category); - } - - @Override - public Object getOverrideKey() { - return null; - } + } + + @Override + public void undo() { + BotaniaAPI.addEntry(Entry, Entry.category); + } + + @Override + public Object getOverrideKey() { + return null; + } } diff --git a/src/main/java/modtweaker2/mods/botania/lexicon/RemovePage.java b/src/main/java/modtweaker2/mods/botania/lexicon/RemovePage.java index a971984..c234612 100644 --- a/src/main/java/modtweaker2/mods/botania/lexicon/RemovePage.java +++ b/src/main/java/modtweaker2/mods/botania/lexicon/RemovePage.java @@ -5,44 +5,44 @@ import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.lexicon.LexiconPage; public class RemovePage implements IUndoableAction { - - int page_number; - LexiconEntry Entry; - LexiconPage page; + + int page_number; + LexiconEntry Entry; + LexiconPage page; public RemovePage(LexiconEntry Entry, int page_number) { - this.Entry=Entry; - this.page_number=page_number; + this.Entry = Entry; + this.page_number = page_number; } @Override - public void apply() { - this.page=Entry.pages.get(page_number); - Entry.pages.remove(page); - } + public void apply() { + this.page = Entry.pages.get(page_number); + Entry.pages.remove(page); + } - @Override - public boolean canUndo() { + @Override + public boolean canUndo() { return Entry != null && page != null; - } - - @Override - public String describe() { + } + + @Override + public String describe() { return "Removing Lexicon Page: " + Entry.pages.get(page_number).getUnlocalizedName(); - } - - @Override - public String describeUndo() { + } + + @Override + public String describeUndo() { return "Adding Lexicon Page: " + page.getUnlocalizedName(); - } - - @Override - public void undo() { - Entry.pages.add(page_number,page); - } - - @Override - public Object getOverrideKey() { - return null; - } + } + + @Override + public void undo() { + Entry.pages.add(page_number, page); + } + + @Override + public Object getOverrideKey() { + return null; + } } diff --git a/src/main/java/modtweaker2/mods/botania/lexicon/RemoveRecipeMapping.java b/src/main/java/modtweaker2/mods/botania/lexicon/RemoveRecipeMapping.java index e1b7e2a..9d17ab0 100644 --- a/src/main/java/modtweaker2/mods/botania/lexicon/RemoveRecipeMapping.java +++ b/src/main/java/modtweaker2/mods/botania/lexicon/RemoveRecipeMapping.java @@ -1,51 +1,53 @@ package modtweaker2.mods.botania.lexicon; import minetweaker.IUndoableAction; + import net.minecraft.item.ItemStack; + import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.lexicon.LexiconRecipeMappings; import vazkii.botania.api.lexicon.LexiconRecipeMappings.EntryData; public class RemoveRecipeMapping implements IUndoableAction { - - ItemStack stack; - LexiconEntry entry; - int page; + + ItemStack stack; + LexiconEntry entry; + int page; public RemoveRecipeMapping(ItemStack stack) { - this.stack =stack; + this.stack = stack; } @Override - public void apply() { - EntryData data=LexiconRecipeMappings.getDataForStack(stack); - this.entry=data.entry; - this.page=data.page; - LexiconRecipeMappings.remove(stack); - } + public void apply() { + EntryData data = LexiconRecipeMappings.getDataForStack(stack); + this.entry = data.entry; + this.page = data.page; + LexiconRecipeMappings.remove(stack); + } - @Override - public boolean canUndo() { + @Override + public boolean canUndo() { return true; - } - - @Override - public String describe() { + } + + @Override + public String describe() { return "Removing Lexicon Recipe Lookup: " + stack.getUnlocalizedName(); - } - - @Override - public String describeUndo() { + } + + @Override + public String describeUndo() { return "Adding Lexicon Recipe Lookup: " + stack.getUnlocalizedName(); - } - - @Override - public void undo() { - LexiconRecipeMappings.map(stack,entry,page); - } - - @Override - public Object getOverrideKey() { - return null; - } + } + + @Override + public void undo() { + LexiconRecipeMappings.map(stack, entry, page); + } + + @Override + public Object getOverrideKey() { + return null; + } } diff --git a/src/main/java/modtweaker2/mods/botania/lexicon/SetCategoryIcon.java b/src/main/java/modtweaker2/mods/botania/lexicon/SetCategoryIcon.java index 491d1af..bfdcc0d 100644 --- a/src/main/java/modtweaker2/mods/botania/lexicon/SetCategoryIcon.java +++ b/src/main/java/modtweaker2/mods/botania/lexicon/SetCategoryIcon.java @@ -1,48 +1,50 @@ package modtweaker2.mods.botania.lexicon; import minetweaker.IUndoableAction; + import net.minecraft.util.ResourceLocation; + import vazkii.botania.api.lexicon.LexiconCategory; public class SetCategoryIcon implements IUndoableAction { - - LexiconCategory category; - ResourceLocation oldIcon; - ResourceLocation newIcon; + + LexiconCategory category; + ResourceLocation oldIcon; + ResourceLocation newIcon; public SetCategoryIcon(LexiconCategory category, String icon) { - this.category=category; - this.newIcon=new ResourceLocation(icon); + this.category = category; + this.newIcon = new ResourceLocation(icon); } @Override - public void apply() { - oldIcon=category.getIcon(); - category.setIcon(newIcon); - } + public void apply() { + oldIcon = category.getIcon(); + category.setIcon(newIcon); + } - @Override - public boolean canUndo() { + @Override + public boolean canUndo() { return category != null; - } - - @Override - public String describe() { + } + + @Override + public String describe() { return "Setting Lexicon Category priority: " + category.getUnlocalizedName(); - } - - @Override - public String describeUndo() { + } + + @Override + public String describeUndo() { return "Unsetting Lexicon Category priority: " + category.getUnlocalizedName(); - } - - @Override - public void undo() { - category.setIcon(oldIcon); - } - - @Override - public Object getOverrideKey() { - return null; - } + } + + @Override + public void undo() { + category.setIcon(oldIcon); + } + + @Override + public Object getOverrideKey() { + return null; + } } diff --git a/src/main/java/modtweaker2/mods/botania/lexicon/SetCategoryPriority.java b/src/main/java/modtweaker2/mods/botania/lexicon/SetCategoryPriority.java index 2c049c3..3130763 100644 --- a/src/main/java/modtweaker2/mods/botania/lexicon/SetCategoryPriority.java +++ b/src/main/java/modtweaker2/mods/botania/lexicon/SetCategoryPriority.java @@ -4,44 +4,44 @@ import minetweaker.IUndoableAction; import vazkii.botania.api.lexicon.LexiconCategory; public class SetCategoryPriority implements IUndoableAction { - - LexiconCategory category; - int oldPriority; - int newPriority; + + LexiconCategory category; + int oldPriority; + int newPriority; public SetCategoryPriority(LexiconCategory category, int priority) { - this.category=category; - this.newPriority=priority; + this.category = category; + this.newPriority = priority; } @Override - public void apply() { - oldPriority=category.getSortingPriority(); - category.setPriority(newPriority); - } + public void apply() { + oldPriority = category.getSortingPriority(); + category.setPriority(newPriority); + } - @Override - public boolean canUndo() { + @Override + public boolean canUndo() { return category != null; - } - - @Override - public String describe() { + } + + @Override + public String describe() { return "Setting Lexicon Category priority: " + category.getUnlocalizedName(); - } - - @Override - public String describeUndo() { + } + + @Override + public String describeUndo() { return "Unsetting Lexicon Category priority: " + category.getUnlocalizedName(); - } - - @Override - public void undo() { - category.setPriority(oldPriority); - } - - @Override - public Object getOverrideKey() { - return null; - } + } + + @Override + public void undo() { + category.setPriority(oldPriority); + } + + @Override + public Object getOverrideKey() { + return null; + } } diff --git a/src/main/java/modtweaker2/mods/botania/lexicon/SetEntryKnowledgeType.java b/src/main/java/modtweaker2/mods/botania/lexicon/SetEntryKnowledgeType.java index aa438c5..1808c13 100644 --- a/src/main/java/modtweaker2/mods/botania/lexicon/SetEntryKnowledgeType.java +++ b/src/main/java/modtweaker2/mods/botania/lexicon/SetEntryKnowledgeType.java @@ -5,44 +5,44 @@ import vazkii.botania.api.lexicon.KnowledgeType; import vazkii.botania.api.lexicon.LexiconEntry; public class SetEntryKnowledgeType implements IUndoableAction { - - LexiconEntry Entry; - KnowledgeType newType; - KnowledgeType oldType; + + LexiconEntry Entry; + KnowledgeType newType; + KnowledgeType oldType; public SetEntryKnowledgeType(LexiconEntry Entry, KnowledgeType type) { - this.Entry=Entry; - this.newType=type; + this.Entry = Entry; + this.newType = type; } @Override - public void apply() { - oldType=Entry.getKnowledgeType(); - Entry.setKnowledgeType(newType); - } + public void apply() { + oldType = Entry.getKnowledgeType(); + Entry.setKnowledgeType(newType); + } - @Override - public boolean canUndo() { + @Override + public boolean canUndo() { return Entry != null && oldType != null; - } - - @Override - public String describe() { + } + + @Override + public String describe() { return "Setting Knowledge type for: " + Entry.getUnlocalizedName(); - } - - @Override - public String describeUndo() { + } + + @Override + public String describeUndo() { return "Unsetting Knowledge type for: " + Entry.getUnlocalizedName(); - } - - @Override - public void undo() { - Entry.setKnowledgeType(oldType); - } - - @Override - public Object getOverrideKey() { - return null; - } + } + + @Override + public void undo() { + Entry.setKnowledgeType(oldType); + } + + @Override + public Object getOverrideKey() { + return null; + } } diff --git a/src/main/java/modtweaker2/mods/botania/lexicon/commands/LexiconCategoryLogger.java b/src/main/java/modtweaker2/mods/botania/lexicon/commands/LexiconCategoryLogger.java index 64a502d..b393a29 100644 --- a/src/main/java/modtweaker2/mods/botania/lexicon/commands/LexiconCategoryLogger.java +++ b/src/main/java/modtweaker2/mods/botania/lexicon/commands/LexiconCategoryLogger.java @@ -9,11 +9,11 @@ import minetweaker.api.server.ICommandFunction; import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.lexicon.LexiconCategory; -public class LexiconCategoryLogger implements ICommandFunction{ +public class LexiconCategoryLogger implements ICommandFunction { @Override public void execute(String[] arguments, IPlayer player) { - List categories=BotaniaAPI.getAllCategories(); + List categories = BotaniaAPI.getAllCategories(); System.out.println("Categories: " + categories.size()); for (LexiconCategory category : categories) { System.out.println("Category " + category.getUnlocalizedName()); @@ -21,7 +21,9 @@ public class LexiconCategoryLogger implements ICommandFunction{ } if (player != null) { - player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir")); + player.sendChat( + MineTweakerImplementationAPI.platform + .getMessage("List generated; see minetweaker.log in your minecraft dir")); } } } diff --git a/src/main/java/modtweaker2/mods/botania/lexicon/commands/LexiconEntryLogger.java b/src/main/java/modtweaker2/mods/botania/lexicon/commands/LexiconEntryLogger.java index 4eb4534..507db99 100644 --- a/src/main/java/modtweaker2/mods/botania/lexicon/commands/LexiconEntryLogger.java +++ b/src/main/java/modtweaker2/mods/botania/lexicon/commands/LexiconEntryLogger.java @@ -11,32 +11,31 @@ import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.lexicon.LexiconCategory; import vazkii.botania.api.lexicon.LexiconEntry; -public class LexiconEntryLogger implements ICommandFunction{ +public class LexiconEntryLogger implements ICommandFunction { @Override public void execute(String[] arguments, IPlayer player) { - LexiconCategory category=null; - if(arguments.length>0) - { - category=BotaniaHelper.findCatagory(arguments[0]); - if(category==null) - { - MineTweakerAPI.getLogger().logError("Category not found (" + arguments[0]+")"); - return; - } - } - List entries=BotaniaAPI.getAllEntries(); + LexiconCategory category = null; + if (arguments.length > 0) { + category = BotaniaHelper.findCatagory(arguments[0]); + if (category == null) { + MineTweakerAPI.getLogger().logError("Category not found (" + arguments[0] + ")"); + return; + } + } + List entries = BotaniaAPI.getAllEntries(); System.out.println("Entries: " + entries.size()); for (LexiconEntry entry : entries) { - if(category==null || entry.category==category) - { - System.out.println("Entry " + entry.getUnlocalizedName()); - MineTweakerAPI.logCommand(entry.getUnlocalizedName()); - } + if (category == null || entry.category == category) { + System.out.println("Entry " + entry.getUnlocalizedName()); + MineTweakerAPI.logCommand(entry.getUnlocalizedName()); + } } if (player != null) { - player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir")); + player.sendChat( + MineTweakerImplementationAPI.platform + .getMessage("List generated; see minetweaker.log in your minecraft dir")); } } } diff --git a/src/main/java/modtweaker2/mods/botania/lexicon/commands/LexiconKnowledgeTypesLogger.java b/src/main/java/modtweaker2/mods/botania/lexicon/commands/LexiconKnowledgeTypesLogger.java index 60b67c0..26f78e0 100644 --- a/src/main/java/modtweaker2/mods/botania/lexicon/commands/LexiconKnowledgeTypesLogger.java +++ b/src/main/java/modtweaker2/mods/botania/lexicon/commands/LexiconKnowledgeTypesLogger.java @@ -8,11 +8,11 @@ import minetweaker.api.player.IPlayer; import minetweaker.api.server.ICommandFunction; import vazkii.botania.api.BotaniaAPI; -public class LexiconKnowledgeTypesLogger implements ICommandFunction{ +public class LexiconKnowledgeTypesLogger implements ICommandFunction { @Override public void execute(String[] arguments, IPlayer player) { - Set types=BotaniaAPI.knowledgeTypes.keySet(); + Set types = BotaniaAPI.knowledgeTypes.keySet(); System.out.println("Knowledge Types: " + types.size()); for (String key : types) { System.out.println("Knowledge Type " + key); @@ -20,7 +20,9 @@ public class LexiconKnowledgeTypesLogger implements ICommandFunction{ } if (player != null) { - player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir")); + player.sendChat( + MineTweakerImplementationAPI.platform + .getMessage("List generated; see minetweaker.log in your minecraft dir")); } } } diff --git a/src/main/java/modtweaker2/mods/botania/lexicon/commands/LexiconPageLogger.java b/src/main/java/modtweaker2/mods/botania/lexicon/commands/LexiconPageLogger.java index 870ca9a..13fff34 100644 --- a/src/main/java/modtweaker2/mods/botania/lexicon/commands/LexiconPageLogger.java +++ b/src/main/java/modtweaker2/mods/botania/lexicon/commands/LexiconPageLogger.java @@ -12,36 +12,33 @@ import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.lexicon.LexiconPage; -public class LexiconPageLogger implements ICommandFunction{ +public class LexiconPageLogger implements ICommandFunction { @Override public void execute(String[] arguments, IPlayer player) { - LexiconEntry entry=null; - if(arguments.length>0) - { - entry=BotaniaHelper.findEntry(arguments[0]); - if(entry==null) - { - MineTweakerAPI.getLogger().logError("Entry not found (" + arguments[0]+")"); - return; - } - } - List entries; - List pages=new ArrayList(); - if(entry!=null) - pages.addAll(entry.pages); - else - for (LexiconEntry current_Entry : BotaniaAPI.getAllEntries()) - pages.addAll(current_Entry.pages); + LexiconEntry entry = null; + if (arguments.length > 0) { + entry = BotaniaHelper.findEntry(arguments[0]); + if (entry == null) { + MineTweakerAPI.getLogger().logError("Entry not found (" + arguments[0] + ")"); + return; + } + } + List entries; + List pages = new ArrayList(); + if (entry != null) pages.addAll(entry.pages); + else for (LexiconEntry current_Entry : BotaniaAPI.getAllEntries()) pages.addAll(current_Entry.pages); System.out.println("Pages: " + pages.size()); - + for (LexiconPage page : pages) { - System.out.println("Page " + page.getUnlocalizedName() + " (" + page.getClass() + ")"); - MineTweakerAPI.logCommand(page.getUnlocalizedName() + " (" + page.getClass() + ")"); + System.out.println("Page " + page.getUnlocalizedName() + " (" + page.getClass() + ")"); + MineTweakerAPI.logCommand(page.getUnlocalizedName() + " (" + page.getClass() + ")"); } if (player != null) { - player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir")); + player.sendChat( + MineTweakerImplementationAPI.platform + .getMessage("List generated; see minetweaker.log in your minecraft dir")); } } } diff --git a/src/main/java/modtweaker2/mods/botanicaladdons/BotanicalAddons.java b/src/main/java/modtweaker2/mods/botanicaladdons/BotanicalAddons.java index 2ec79cd..228f169 100644 --- a/src/main/java/modtweaker2/mods/botanicaladdons/BotanicalAddons.java +++ b/src/main/java/modtweaker2/mods/botanicaladdons/BotanicalAddons.java @@ -5,6 +5,7 @@ import modtweaker2.mods.botanicaladdons.handlers.DendricSuffuser; import modtweaker2.mods.botanicaladdons.handlers.IridescentTree; public class BotanicalAddons { + public BotanicalAddons() { MineTweakerAPI.registerClass(DendricSuffuser.class); MineTweakerAPI.registerClass(IridescentTree.class); diff --git a/src/main/java/modtweaker2/mods/botanicaladdons/commands/BotanicalAddonsDendricLogger.java b/src/main/java/modtweaker2/mods/botanicaladdons/commands/BotanicalAddonsDendricLogger.java index bda7833..6f5fd2e 100644 --- a/src/main/java/modtweaker2/mods/botanicaladdons/commands/BotanicalAddonsDendricLogger.java +++ b/src/main/java/modtweaker2/mods/botanicaladdons/commands/BotanicalAddonsDendricLogger.java @@ -8,22 +8,25 @@ import modtweaker2.helpers.LogHelper; import ninja.shadowfox.shadowfox_botany.api.ShadowFoxAPI; import ninja.shadowfox.shadowfox_botany.api.recipe.RecipeTreeCrafting; -public class BotanicalAddonsDendricLogger implements ICommandFunction{ +public class BotanicalAddonsDendricLogger implements ICommandFunction { @Override public void execute(String[] arguments, IPlayer player) { System.out.println("Recipes: " + ShadowFoxAPI.treeRecipes.size()); for (RecipeTreeCrafting recipe : ShadowFoxAPI.treeRecipes) { - MineTweakerAPI.logCommand(String.format("mods.botanicaladdons.DendricSuffuser.addRecipe(%s, %s, %s, %s);", - LogHelper.getStackDescription(recipe.getOutput()), - recipe.getManaUsage(), - recipe.getThrottle(), - LogHelper.getListDescription(recipe.getInputs()) - )); + MineTweakerAPI.logCommand( + String.format( + "mods.botanicaladdons.DendricSuffuser.addRecipe(%s, %s, %s, %s);", + LogHelper.getStackDescription(recipe.getOutput()), + recipe.getManaUsage(), + recipe.getThrottle(), + LogHelper.getListDescription(recipe.getInputs()))); } if (player != null) { - player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir")); + player.sendChat( + MineTweakerImplementationAPI.platform + .getMessage("List generated; see minetweaker.log in your minecraft dir")); } } } diff --git a/src/main/java/modtweaker2/mods/botanicaladdons/handlers/DendricSuffuser.java b/src/main/java/modtweaker2/mods/botanicaladdons/handlers/DendricSuffuser.java index ca84650..543cb13 100644 --- a/src/main/java/modtweaker2/mods/botanicaladdons/handlers/DendricSuffuser.java +++ b/src/main/java/modtweaker2/mods/botanicaladdons/handlers/DendricSuffuser.java @@ -1,5 +1,11 @@ package modtweaker2.mods.botanicaladdons.handlers; +import static modtweaker2.helpers.InputHelper.toIItemStack; +import static modtweaker2.helpers.InputHelper.toObjects; +import static modtweaker2.helpers.StackHelper.matches; + +import java.util.LinkedList; +import java.util.List; import minetweaker.MineTweakerAPI; import minetweaker.api.item.IIngredient; @@ -8,20 +14,15 @@ import modtweaker2.helpers.InputHelper; import modtweaker2.helpers.LogHelper; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; + import net.minecraft.block.Block; import net.minecraft.item.ItemStack; + import ninja.shadowfox.shadowfox_botany.api.ShadowFoxAPI; import ninja.shadowfox.shadowfox_botany.api.recipe.RecipeTreeCrafting; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; -import java.util.LinkedList; -import java.util.List; - -import static modtweaker2.helpers.InputHelper.toIItemStack; -import static modtweaker2.helpers.InputHelper.toObjects; -import static modtweaker2.helpers.StackHelper.matches; - @ZenClass("mods.botanicaladdons.DendricSuffuser") public class DendricSuffuser { @@ -32,12 +33,18 @@ public class DendricSuffuser { @ZenMethod public static void addRecipe(IItemStack blockOutput, int mana, int throttle, IIngredient[] input) { Object output = InputHelper.toObject(blockOutput); - if(output == null || !(output instanceof ItemStack) || !InputHelper.isABlock((ItemStack)output)) { + if (output == null || !(output instanceof ItemStack) || !InputHelper.isABlock((ItemStack) output)) { LogHelper.logError("Output must be a block."); return; } - MineTweakerAPI.apply(new Add(new RecipeTreeCrafting(mana, Block.getBlockFromItem(((ItemStack)output).getItem()), - ((ItemStack)output).getItemDamage(), throttle, toObjects(input)))); + MineTweakerAPI.apply( + new Add( + new RecipeTreeCrafting( + mana, + Block.getBlockFromItem(((ItemStack) output).getItem()), + ((ItemStack) output).getItemDamage(), + throttle, + toObjects(input)))); } @ZenMethod @@ -46,6 +53,7 @@ public class DendricSuffuser { } private static class Add extends BaseListAddition { + public Add(RecipeTreeCrafting recipe) { super(DendricSuffuser.name, ShadowFoxAPI.treeRecipes); @@ -72,14 +80,19 @@ public class DendricSuffuser { } // Check if we found the recipes and apply the action - if(!recipes.isEmpty()) { + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new Remove(recipes)); } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", DendricSuffuser.name, output.toString())); + LogHelper.logWarning( + String.format( + "No %s Recipe found for %s. Command ignored!", + DendricSuffuser.name, + output.toString())); } } private static class Remove extends BaseListRemoval { + public Remove(List recipes) { super(DendricSuffuser.name, ShadowFoxAPI.treeRecipes, recipes); } @@ -90,4 +103,3 @@ public class DendricSuffuser { } } } - diff --git a/src/main/java/modtweaker2/mods/botanicaladdons/handlers/IridescentTree.java b/src/main/java/modtweaker2/mods/botanicaladdons/handlers/IridescentTree.java index 7c168d4..6b2a303 100644 --- a/src/main/java/modtweaker2/mods/botanicaladdons/handlers/IridescentTree.java +++ b/src/main/java/modtweaker2/mods/botanicaladdons/handlers/IridescentTree.java @@ -1,5 +1,7 @@ package modtweaker2.mods.botanicaladdons.handlers; +import java.util.LinkedList; +import java.util.List; import minetweaker.MineTweakerAPI; import minetweaker.api.item.IItemStack; @@ -7,17 +9,16 @@ import modtweaker2.helpers.InputHelper; import modtweaker2.helpers.LogHelper; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; + import net.minecraft.block.Block; import net.minecraft.item.ItemStack; + import ninja.shadowfox.shadowfox_botany.api.ShadowFoxAPI; import ninja.shadowfox.shadowfox_botany.api.trees.IIridescentSaplingVariant; import ninja.shadowfox.shadowfox_botany.api.trees.IridescentSaplingBaseVariant; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; -import java.util.LinkedList; -import java.util.List; - @ZenClass("mods.botanicaladdons.IridescentTree") public class IridescentTree { @@ -26,30 +27,38 @@ public class IridescentTree { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @ZenMethod - public static void addVariant(IItemStack blockSoil, IItemStack blockWood, IItemStack blockLeaves, int metaMin, int metaMax, int metaShift) { + public static void addVariant(IItemStack blockSoil, IItemStack blockWood, IItemStack blockLeaves, int metaMin, + int metaMax, int metaShift) { Object soil = InputHelper.toObject(blockSoil); Object wood = InputHelper.toObject(blockWood); Object leaves = InputHelper.toObject(blockLeaves); - if (soil == null || !(soil instanceof ItemStack) || !InputHelper.isABlock((ItemStack)soil)) { + if (soil == null || !(soil instanceof ItemStack) || !InputHelper.isABlock((ItemStack) soil)) { LogHelper.logError("Soil must be a block."); return; - } - else if (wood == null || !(wood instanceof ItemStack) || !InputHelper.isABlock((ItemStack)wood)) { + } else if (wood == null || !(wood instanceof ItemStack) || !InputHelper.isABlock((ItemStack) wood)) { LogHelper.logError("Wood must be a block."); return; - } - else if(leaves == null || !(leaves instanceof ItemStack) || !InputHelper.isABlock((ItemStack)leaves)) { + } else if (leaves == null || !(leaves instanceof ItemStack) || !InputHelper.isABlock((ItemStack) leaves)) { LogHelper.logError("Leaves must be a block."); return; } - Block soilBlock = Block.getBlockFromItem(((ItemStack)soil).getItem()); - Block woodBlock = Block.getBlockFromItem(((ItemStack)wood).getItem()); - Block leavesBlock = Block.getBlockFromItem(((ItemStack)leaves).getItem()); - MineTweakerAPI.apply(new Add(new IridescentSaplingBaseVariant(soilBlock, woodBlock, leavesBlock, metaMin, metaMax, metaShift))); + Block soilBlock = Block.getBlockFromItem(((ItemStack) soil).getItem()); + Block woodBlock = Block.getBlockFromItem(((ItemStack) wood).getItem()); + Block leavesBlock = Block.getBlockFromItem(((ItemStack) leaves).getItem()); + MineTweakerAPI.apply( + new Add( + new IridescentSaplingBaseVariant( + soilBlock, + woodBlock, + leavesBlock, + metaMin, + metaMax, + metaShift))); } @ZenMethod - public static void addVariant(IItemStack blockSoil, IItemStack blockWood, IItemStack blockLeaves, int metaMin, int metaMax) { + public static void addVariant(IItemStack blockSoil, IItemStack blockWood, IItemStack blockLeaves, int metaMin, + int metaMax) { addVariant(blockSoil, blockWood, blockLeaves, metaMin, metaMax, 0); } @@ -64,6 +73,7 @@ public class IridescentTree { } private static class Add extends BaseListAddition { + public Add(IIridescentSaplingVariant recipe) { super(IridescentTree.name, ShadowFoxAPI.treeVariants); @@ -83,11 +93,11 @@ public class IridescentTree { // Get list of existing recipes, matching with parameter Object soil = InputHelper.toObject(blockSoil); - if (soil == null || !(soil instanceof ItemStack) || !InputHelper.isABlock((ItemStack)soil)) { + if (soil == null || !(soil instanceof ItemStack) || !InputHelper.isABlock((ItemStack) soil)) { LogHelper.logError("Soil must be a block."); return; } - Block soilBlock = Block.getBlockFromItem(((ItemStack)soil).getItem()); + Block soilBlock = Block.getBlockFromItem(((ItemStack) soil).getItem()); List recipes = new LinkedList(); @@ -98,14 +108,19 @@ public class IridescentTree { } // Check if we found the recipes and apply the action - if(!recipes.isEmpty()) { + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new Remove(recipes)); } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", IridescentTree.name, soilBlock.toString())); + LogHelper.logWarning( + String.format( + "No %s Recipe found for %s. Command ignored!", + IridescentTree.name, + soilBlock.toString())); } } private static class Remove extends BaseListRemoval { + public Remove(List recipes) { super(IridescentTree.name, ShadowFoxAPI.treeVariants, recipes); } @@ -116,4 +131,3 @@ public class IridescentTree { } } } - diff --git a/src/main/java/modtweaker2/mods/chisel/Chisel.java b/src/main/java/modtweaker2/mods/chisel/Chisel.java index e113be5..23ea5a9 100644 --- a/src/main/java/modtweaker2/mods/chisel/Chisel.java +++ b/src/main/java/modtweaker2/mods/chisel/Chisel.java @@ -4,6 +4,7 @@ import minetweaker.MineTweakerAPI; import modtweaker2.mods.chisel.handlers.Groups; public class Chisel { + public Chisel() { MineTweakerAPI.registerClass(Groups.class); } diff --git a/src/main/java/modtweaker2/mods/chisel/ChiselHelper.java b/src/main/java/modtweaker2/mods/chisel/ChiselHelper.java index 90215c4..9a24f02 100644 --- a/src/main/java/modtweaker2/mods/chisel/ChiselHelper.java +++ b/src/main/java/modtweaker2/mods/chisel/ChiselHelper.java @@ -7,6 +7,7 @@ import java.util.Comparator; import java.util.List; import minetweaker.api.item.IItemStack; + import net.minecraft.block.Block; import com.cricketcraft.chisel.api.carving.CarvingUtils; @@ -16,143 +17,138 @@ import com.google.common.collect.Lists; public class ChiselHelper { - public static ICarvingGroup getGroup(String name) - { - return CarvingUtils.getChiselRegistry().getGroup(name); - } - - public static ICarvingGroup getGroup(IItemStack stack) - { - return CarvingUtils.getChiselRegistry().getGroup(Block.getBlockFromItem(toStack(stack).getItem()), stack.getDamage()); - } - - public static ICarvingVariation getVariation(IItemStack stack) - { - ICarvingGroup g = getGroup(stack); - if (g != null) { - for (ICarvingVariation v : g.getVariations()) { - if (v.getBlock() == Block.getBlockFromItem(toStack(stack).getItem()) && v.getBlockMeta() == stack.getDamage()) { - return v; - } - } - } - return null; - } + public static ICarvingGroup getGroup(String name) { + return CarvingUtils.getChiselRegistry().getGroup(name); + } - public static ICarvingVariation makeVariation(IItemStack stack) - { - return new CarvingVariation(Block.getBlockFromItem(toStack(stack).getItem()), stack.getDamage()); - } + public static ICarvingGroup getGroup(IItemStack stack) { + return CarvingUtils.getChiselRegistry() + .getGroup(Block.getBlockFromItem(toStack(stack).getItem()), stack.getDamage()); + } - public static ICarvingGroup makeGroup(String name) - { - return new CarvingGroup(name); - } - - public static boolean groupContainsVariation(ICarvingGroup group, ICarvingVariation variation) - { - for(ICarvingVariation otherVariation : group.getVariations()) - { - if(otherVariation.getBlock()==variation.getBlock() && otherVariation.getBlockMeta()==variation.getBlockMeta()) - return true; - } - return false; - } - - static class CarvingVariation implements ICarvingVariation - { - Block block; - int meta; - - public CarvingVariation(Block block, int meta) - { - this.block=block; - this.meta=meta; - } - - @Override - public Block getBlock() { - return block; - } + public static ICarvingVariation getVariation(IItemStack stack) { + ICarvingGroup g = getGroup(stack); + if (g != null) { + for (ICarvingVariation v : g.getVariations()) { + if (v.getBlock() == Block.getBlockFromItem(toStack(stack).getItem()) + && v.getBlockMeta() == stack.getDamage()) { + return v; + } + } + } + return null; + } - @Override - public int getBlockMeta() { - return meta; - } + public static ICarvingVariation makeVariation(IItemStack stack) { + return new CarvingVariation(Block.getBlockFromItem(toStack(stack).getItem()), stack.getDamage()); + } - @Override - public int getItemMeta() { - return meta; - } + public static ICarvingGroup makeGroup(String name) { + return new CarvingGroup(name); + } - @Override - public int getOrder() { - return 99; - } - } + public static boolean groupContainsVariation(ICarvingGroup group, ICarvingVariation variation) { + for (ICarvingVariation otherVariation : group.getVariations()) { + if (otherVariation.getBlock() == variation.getBlock() + && otherVariation.getBlockMeta() == variation.getBlockMeta()) + return true; + } + return false; + } - static class CarvingGroup implements ICarvingGroup - { - private String name; - private String sound; - private String oreName; + static class CarvingVariation implements ICarvingVariation { - private List variations = Lists.newArrayList(); + Block block; + int meta; - public CarvingGroup(String name) { - this.name = name; - } + public CarvingVariation(Block block, int meta) { + this.block = block; + this.meta = meta; + } - public List getVariations() { - return Lists.newArrayList(variations); - } + @Override + public Block getBlock() { + return block; + } - @Override - public void addVariation(ICarvingVariation variation) { - variations.add(variation); - Collections.sort(variations, new Comparator() { + @Override + public int getBlockMeta() { + return meta; + } - @Override - public int compare(ICarvingVariation o1, ICarvingVariation o2) { - return CarvingUtils.compare(o1, o2); - } - }); - } - - @Override - public boolean removeVariation(ICarvingVariation variation) { - ICarvingVariation toRemove = null; - for (ICarvingVariation v : variations) { - if (v.getBlock() == variation.getBlock() && v.getBlockMeta() == variation.getBlockMeta()) { - toRemove = v; - } - } - return toRemove == null ? false : variations.remove(toRemove); - } + @Override + public int getItemMeta() { + return meta; + } - @Override - public String getName() { - return name; - } + @Override + public int getOrder() { + return 99; + } + } - @Override - public String getSound() { - return sound; - } + static class CarvingGroup implements ICarvingGroup { - @Override - public void setSound(String sound) { - this.sound = sound; - } + private String name; + private String sound; + private String oreName; - @Override - public String getOreName() { - return oreName; - } + private List variations = Lists.newArrayList(); - @Override - public void setOreName(String oreName) { - this.oreName = oreName; - } - } + public CarvingGroup(String name) { + this.name = name; + } + + public List getVariations() { + return Lists.newArrayList(variations); + } + + @Override + public void addVariation(ICarvingVariation variation) { + variations.add(variation); + Collections.sort(variations, new Comparator() { + + @Override + public int compare(ICarvingVariation o1, ICarvingVariation o2) { + return CarvingUtils.compare(o1, o2); + } + }); + } + + @Override + public boolean removeVariation(ICarvingVariation variation) { + ICarvingVariation toRemove = null; + for (ICarvingVariation v : variations) { + if (v.getBlock() == variation.getBlock() && v.getBlockMeta() == variation.getBlockMeta()) { + toRemove = v; + } + } + return toRemove == null ? false : variations.remove(toRemove); + } + + @Override + public String getName() { + return name; + } + + @Override + public String getSound() { + return sound; + } + + @Override + public void setSound(String sound) { + this.sound = sound; + } + + @Override + public String getOreName() { + return oreName; + } + + @Override + public void setOreName(String oreName) { + this.oreName = oreName; + } + } } diff --git a/src/main/java/modtweaker2/mods/chisel/commands/ChiselGroupLogger.java b/src/main/java/modtweaker2/mods/chisel/commands/ChiselGroupLogger.java index 55dd684..175a0d2 100644 --- a/src/main/java/modtweaker2/mods/chisel/commands/ChiselGroupLogger.java +++ b/src/main/java/modtweaker2/mods/chisel/commands/ChiselGroupLogger.java @@ -9,11 +9,11 @@ import minetweaker.api.server.ICommandFunction; import com.cricketcraft.chisel.api.carving.CarvingUtils; -public class ChiselGroupLogger implements ICommandFunction{ +public class ChiselGroupLogger implements ICommandFunction { @Override public void execute(String[] arguments, IPlayer player) { - List keys=CarvingUtils.getChiselRegistry().getSortedGroupNames(); + List keys = CarvingUtils.getChiselRegistry().getSortedGroupNames(); System.out.println("Chisel Groups: " + keys.size()); for (String key : keys) { System.out.println("Chisel Group " + key); @@ -21,7 +21,9 @@ public class ChiselGroupLogger implements ICommandFunction{ } if (player != null) { - player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir")); + player.sendChat( + MineTweakerImplementationAPI.platform + .getMessage("List generated; see minetweaker.log in your minecraft dir")); } } } diff --git a/src/main/java/modtweaker2/mods/chisel/commands/ChiselVariationLogger.java b/src/main/java/modtweaker2/mods/chisel/commands/ChiselVariationLogger.java index 61817eb..4026563 100644 --- a/src/main/java/modtweaker2/mods/chisel/commands/ChiselVariationLogger.java +++ b/src/main/java/modtweaker2/mods/chisel/commands/ChiselVariationLogger.java @@ -10,48 +10,46 @@ import minetweaker.MineTweakerImplementationAPI; import minetweaker.api.player.IPlayer; import minetweaker.api.server.ICommandFunction; import modtweaker2.mods.chisel.ChiselHelper; + import net.minecraft.item.Item; import com.cricketcraft.chisel.api.carving.CarvingUtils; import com.cricketcraft.chisel.api.carving.ICarvingGroup; import com.cricketcraft.chisel.api.carving.ICarvingVariation; -public class ChiselVariationLogger implements ICommandFunction{ +public class ChiselVariationLogger implements ICommandFunction { @Override public void execute(String[] arguments, IPlayer player) { - Map variations=new HashMap(); - List keys=CarvingUtils.getChiselRegistry().getSortedGroupNames(); - if(arguments.length>0) - { - ICarvingGroup group=ChiselHelper.getGroup(arguments[0]); - if(group==null) - { - MineTweakerAPI.getLogger().logError("Group not found (" + arguments[0]+")"); - return; - } - else - { - keys.clear(); - keys.add(arguments[0]); - } - } - for (String key : keys) { - ICarvingGroup group=CarvingUtils.getChiselRegistry().getGroup(key); - for(ICarvingVariation variation : group.getVariations()) - variations.put(variation, group); - } + Map variations = new HashMap(); + List keys = CarvingUtils.getChiselRegistry().getSortedGroupNames(); + if (arguments.length > 0) { + ICarvingGroup group = ChiselHelper.getGroup(arguments[0]); + if (group == null) { + MineTweakerAPI.getLogger().logError("Group not found (" + arguments[0] + ")"); + return; + } else { + keys.clear(); + keys.add(arguments[0]); + } + } + for (String key : keys) { + ICarvingGroup group = CarvingUtils.getChiselRegistry().getGroup(key); + for (ICarvingVariation variation : group.getVariations()) variations.put(variation, group); + } System.out.println("Chisel Variations: " + variations.size()); - for (Entry entry: variations.entrySet()) { - String stringedVariation="<"+Item.itemRegistry.getNameForObject(Item.getItemFromBlock(entry.getKey().getBlock()))+":"+entry.getKey().getBlockMeta()+">"; - if(arguments.length==0) - stringedVariation+=" "+entry.getValue().getName(); + for (Entry entry : variations.entrySet()) { + String stringedVariation = "<" + Item.itemRegistry.getNameForObject( + Item.getItemFromBlock(entry.getKey().getBlock())) + ":" + entry.getKey().getBlockMeta() + ">"; + if (arguments.length == 0) stringedVariation += " " + entry.getValue().getName(); System.out.println("Chisel Variation " + stringedVariation); MineTweakerAPI.logCommand(stringedVariation); } if (player != null) { - player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir")); + player.sendChat( + MineTweakerImplementationAPI.platform + .getMessage("List generated; see minetweaker.log in your minecraft dir")); } } } diff --git a/src/main/java/modtweaker2/mods/chisel/handlers/Groups.java b/src/main/java/modtweaker2/mods/chisel/handlers/Groups.java index e59eb5c..8f0f3ee 100644 --- a/src/main/java/modtweaker2/mods/chisel/handlers/Groups.java +++ b/src/main/java/modtweaker2/mods/chisel/handlers/Groups.java @@ -13,221 +13,215 @@ import com.cricketcraft.chisel.api.carving.ICarvingVariation; @ZenClass("mods.chisel.Groups") public class Groups { + @ZenMethod public static void addVariation(String groupName, IItemStack stack) { - ICarvingGroup group=ChiselHelper.getGroup(groupName); - ICarvingVariation variation=ChiselHelper.makeVariation(stack); - if(group==null) - { - MineTweakerAPI.getLogger().logError("Cannot find group " + groupName); - return; - } - if(variation==null) - { - MineTweakerAPI.getLogger().logError("Can't create variation from " + stack); - return; - } - MineTweakerAPI.apply(new AddVariation(group,variation, stack.toString())); + ICarvingGroup group = ChiselHelper.getGroup(groupName); + ICarvingVariation variation = ChiselHelper.makeVariation(stack); + if (group == null) { + MineTweakerAPI.getLogger().logError("Cannot find group " + groupName); + return; + } + if (variation == null) { + MineTweakerAPI.getLogger().logError("Can't create variation from " + stack); + return; + } + MineTweakerAPI.apply(new AddVariation(group, variation, stack.toString())); } - - static class AddVariation implements IUndoableAction { - - ICarvingGroup group; - ICarvingVariation variation; - String variationName; - public AddVariation(ICarvingGroup group,ICarvingVariation variation, String variationName) { - this.group=group; - this.variation=variation; - this.variationName=variationName; + static class AddVariation implements IUndoableAction { + + ICarvingGroup group; + ICarvingVariation variation; + String variationName; + + public AddVariation(ICarvingGroup group, ICarvingVariation variation, String variationName) { + this.group = group; + this.variation = variation; + this.variationName = variationName; } @Override - public void apply() { - CarvingUtils.getChiselRegistry().addVariation(group.getName(),variation); - } + public void apply() { + CarvingUtils.getChiselRegistry().addVariation(group.getName(), variation); + } - @Override - public boolean canUndo() { + @Override + public boolean canUndo() { return group != null && variation != null; - } - - @Override - public String describe() { - return "Adding Variation: " + variationName; - } - - @Override - public String describeUndo() { - return "Removing Variation: " + variationName; - } - - @Override - public void undo() { - CarvingUtils.getChiselRegistry().removeVariation(variation.getBlock(),variation.getBlockMeta()); - } - - @Override - public Object getOverrideKey() { - return null; - } - } + } + @Override + public String describe() { + return "Adding Variation: " + variationName; + } + + @Override + public String describeUndo() { + return "Removing Variation: " + variationName; + } + + @Override + public void undo() { + CarvingUtils.getChiselRegistry().removeVariation(variation.getBlock(), variation.getBlockMeta()); + } + + @Override + public Object getOverrideKey() { + return null; + } + } @ZenMethod public static void removeVariation(IItemStack stack) { - ICarvingVariation variation=ChiselHelper.getVariation(stack); - if(variation==null) - { - MineTweakerAPI.getLogger().logError("Can't find variation from " + stack); - return; - } - MineTweakerAPI.apply(new RemoveVariation(variation, stack.toString())); + ICarvingVariation variation = ChiselHelper.getVariation(stack); + if (variation == null) { + MineTweakerAPI.getLogger().logError("Can't find variation from " + stack); + return; + } + MineTweakerAPI.apply(new RemoveVariation(variation, stack.toString())); } - - + static class RemoveVariation implements IUndoableAction { - - ICarvingVariation variation; - String variationName; - ICarvingGroup group; + + ICarvingVariation variation; + String variationName; + ICarvingGroup group; public RemoveVariation(ICarvingVariation variation, String variationName) { - this.variation=variation; - this.variationName=variationName; + this.variation = variation; + this.variationName = variationName; } @Override - public void apply() { - group=CarvingUtils.getChiselRegistry().getGroup(variation.getBlock(),variation.getBlockMeta()); - CarvingUtils.getChiselRegistry().removeVariation(variation.getBlock(),variation.getBlockMeta()); - } + public void apply() { + group = CarvingUtils.getChiselRegistry().getGroup(variation.getBlock(), variation.getBlockMeta()); + CarvingUtils.getChiselRegistry().removeVariation(variation.getBlock(), variation.getBlockMeta()); + } - @Override - public boolean canUndo() { - return group!= null && variation != null; - } - - @Override - public String describe() { + @Override + public boolean canUndo() { + return group != null && variation != null; + } + + @Override + public String describe() { return "Removing Variation: " + variationName; - } - - @Override - public String describeUndo() { + } + + @Override + public String describeUndo() { return "Adding Variation: " + variationName; - } - - @Override - public void undo() { - CarvingUtils.getChiselRegistry().addVariation(group.getName(),variation); - } - - @Override - public Object getOverrideKey() { - return null; - } + } + + @Override + public void undo() { + CarvingUtils.getChiselRegistry().addVariation(group.getName(), variation); + } + + @Override + public Object getOverrideKey() { + return null; + } } @ZenMethod public static void addGroup(String groupName) { - ICarvingGroup group=ChiselHelper.getGroup(groupName); - if(group!=null) - { - MineTweakerAPI.getLogger().logError("Group already exists " + groupName); - return; - } - group=ChiselHelper.makeGroup(groupName); - MineTweakerAPI.apply(new AddGroup(group)); + ICarvingGroup group = ChiselHelper.getGroup(groupName); + if (group != null) { + MineTweakerAPI.getLogger().logError("Group already exists " + groupName); + return; + } + group = ChiselHelper.makeGroup(groupName); + MineTweakerAPI.apply(new AddGroup(group)); } - + static class AddGroup implements IUndoableAction { - - ICarvingGroup group; + + ICarvingGroup group; public AddGroup(ICarvingGroup group) { - this.group=group; + this.group = group; } @Override - public void apply() { - CarvingUtils.getChiselRegistry().addGroup(group); - } + public void apply() { + CarvingUtils.getChiselRegistry().addGroup(group); + } - @Override - public boolean canUndo() { + @Override + public boolean canUndo() { return group != null; - } - - @Override - public String describe() { + } + + @Override + public String describe() { return "Adding Group: " + group.getName(); - } - - @Override - public String describeUndo() { + } + + @Override + public String describeUndo() { return "Removing Group: " + group.getName(); - } - - @Override - public void undo() { - CarvingUtils.getChiselRegistry().removeGroup(group.getName()); - } - - @Override - public Object getOverrideKey() { - return null; - } + } + + @Override + public void undo() { + CarvingUtils.getChiselRegistry().removeGroup(group.getName()); + } + + @Override + public Object getOverrideKey() { + return null; + } } - + @ZenMethod public static void removeGroup(String groupName) { - ICarvingGroup group=ChiselHelper.getGroup(groupName); - if(group==null) - { - MineTweakerAPI.getLogger().logError("Could not find group " + groupName); - return; - } - MineTweakerAPI.apply(new RemoveGroup(group)); + ICarvingGroup group = ChiselHelper.getGroup(groupName); + if (group == null) { + MineTweakerAPI.getLogger().logError("Could not find group " + groupName); + return; + } + MineTweakerAPI.apply(new RemoveGroup(group)); } - + static class RemoveGroup implements IUndoableAction { - - ICarvingGroup group; + + ICarvingGroup group; public RemoveGroup(ICarvingGroup group) { - this.group=group; + this.group = group; } @Override - public void apply() { - CarvingUtils.getChiselRegistry().removeGroup(group.getName()); - } + public void apply() { + CarvingUtils.getChiselRegistry().removeGroup(group.getName()); + } - @Override - public boolean canUndo() { + @Override + public boolean canUndo() { return group != null; - } - - @Override - public String describe() { + } + + @Override + public String describe() { return "Removing Group: " + group.getName(); - } - - @Override - public String describeUndo() { + } + + @Override + public String describeUndo() { return "Adding Group: " + group.getName(); - } - - @Override - public void undo() { - CarvingUtils.getChiselRegistry().addGroup(group); - } - - @Override - public Object getOverrideKey() { - return null; - } + } + + @Override + public void undo() { + CarvingUtils.getChiselRegistry().addGroup(group); + } + + @Override + public Object getOverrideKey() { + return null; + } } - + } diff --git a/src/main/java/modtweaker2/mods/exnihilo/ExNihilo.java b/src/main/java/modtweaker2/mods/exnihilo/ExNihilo.java index 62991ed..69a7940 100644 --- a/src/main/java/modtweaker2/mods/exnihilo/ExNihilo.java +++ b/src/main/java/modtweaker2/mods/exnihilo/ExNihilo.java @@ -7,6 +7,7 @@ import modtweaker2.mods.exnihilo.handlers.Hammer; import modtweaker2.mods.exnihilo.handlers.Sieve; public class ExNihilo { + public ExNihilo() { MineTweakerAPI.registerClass(Compost.class); MineTweakerAPI.registerClass(Crucible.class); diff --git a/src/main/java/modtweaker2/mods/exnihilo/ExNihiloHelper.java b/src/main/java/modtweaker2/mods/exnihilo/ExNihiloHelper.java index d4eca5b..e1d1cb2 100644 --- a/src/main/java/modtweaker2/mods/exnihilo/ExNihiloHelper.java +++ b/src/main/java/modtweaker2/mods/exnihilo/ExNihiloHelper.java @@ -7,6 +7,7 @@ import exnihilo.registries.HeatRegistry; import exnihilo.utils.ItemInfo; public class ExNihiloHelper { + public static Map getHeatMap() { return ReflectionHelper.>getStaticObject(HeatRegistry.class, "heatmap"); } diff --git a/src/main/java/modtweaker2/mods/exnihilo/commands/ExNihiloLogger.java b/src/main/java/modtweaker2/mods/exnihilo/commands/ExNihiloLogger.java index fe9c06c..39736c9 100644 --- a/src/main/java/modtweaker2/mods/exnihilo/commands/ExNihiloLogger.java +++ b/src/main/java/modtweaker2/mods/exnihilo/commands/ExNihiloLogger.java @@ -13,8 +13,10 @@ import minetweaker.api.server.ICommandFunction; import modtweaker2.helpers.LogHelper; import modtweaker2.helpers.StringHelper; import modtweaker2.mods.exnihilo.ExNihiloHelper; + import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; + import exnihilo.registries.CompostRegistry; import exnihilo.registries.CrucibleRegistry; import exnihilo.registries.HammerRegistry; @@ -28,71 +30,87 @@ import exnihilo.utils.ItemInfo; public class ExNihiloLogger implements ICommandFunction { private static final List validArguments = new LinkedList(); - + static { validArguments.add("Composting"); validArguments.add("Crucible"); validArguments.add("Hammer"); validArguments.add("Sieve"); } - + @Override public void execute(String[] arguments, IPlayer player) { List args = StringHelper.toLowerCase(Arrays.asList(arguments)); - - if(!validArguments.containsAll(args)) { - if(player != null) { - player.sendChat(MineTweakerImplementationAPI.platform.getMessage("Invalid arguments for command. Valid arguments: " + StringHelper.join(validArguments, ", "))); + + if (!validArguments.containsAll(args)) { + if (player != null) { + player.sendChat( + MineTweakerImplementationAPI.platform.getMessage( + "Invalid arguments for command. Valid arguments: " + + StringHelper.join(validArguments, ", "))); } } else { - if(args.isEmpty() || args.contains("Composting")) { - for(Entry recipe : CompostRegistry.entries.entrySet()) { - MineTweakerAPI.logCommand(String.format("mods.exnihilo.Composting.addRecipe(%s, %s, \"%s\");", - LogHelper.getStackDescription(recipe.getKey().getStack()), - recipe.getValue().value, - Integer.toHexString(recipe.getValue().color.toInt()).substring(2))); + if (args.isEmpty() || args.contains("Composting")) { + for (Entry recipe : CompostRegistry.entries.entrySet()) { + MineTweakerAPI.logCommand( + String.format( + "mods.exnihilo.Composting.addRecipe(%s, %s, \"%s\");", + LogHelper.getStackDescription(recipe.getKey().getStack()), + recipe.getValue().value, + Integer.toHexString(recipe.getValue().color.toInt()).substring(2))); } } - - if(args.isEmpty() || args.contains("Crucible")) { - for(Meltable recipe : CrucibleRegistry.entries.values()) { - MineTweakerAPI.logCommand(String.format("mods.exnihilo.Crucible.addRecipe(%s, %s);", - LogHelper.getStackDescription(new ItemStack(recipe.block, 1, recipe.meta)), - LogHelper.getStackDescription(new FluidStack(recipe.fluid, (int)recipe.fluidVolume)))); + + if (args.isEmpty() || args.contains("Crucible")) { + for (Meltable recipe : CrucibleRegistry.entries.values()) { + MineTweakerAPI.logCommand( + String.format( + "mods.exnihilo.Crucible.addRecipe(%s, %s);", + LogHelper.getStackDescription(new ItemStack(recipe.block, 1, recipe.meta)), + LogHelper.getStackDescription( + new FluidStack(recipe.fluid, (int) recipe.fluidVolume)))); } - - for(Entry recipe : ExNihiloHelper.getHeatMap().entrySet()) { - MineTweakerAPI.logCommand(String.format("mods.exnihilo.Crucible.addHeatSource(%s, %s);", - LogHelper.getStackDescription(recipe.getKey().getStack()), - recipe.getValue())); + + for (Entry recipe : ExNihiloHelper.getHeatMap().entrySet()) { + MineTweakerAPI.logCommand( + String.format( + "mods.exnihilo.Crucible.addHeatSource(%s, %s);", + LogHelper.getStackDescription(recipe.getKey().getStack()), + recipe.getValue())); } } - - if(args.isEmpty() || args.contains("Hammer")) { - for(Entry> entry : HammerRegistry.getRewards().entrySet()) { - for(Smashable recipe : entry.getValue()) { - MineTweakerAPI.logCommand(String.format("mods.exnihilo.Hammer.addRecipe(%s, %s, %s, %s);", - LogHelper.getStackDescription(entry.getKey().getStack()), - LogHelper.getStackDescription(new ItemStack(recipe.item, 1, recipe.meta)), - recipe.chance, - recipe.luckMultiplier)); + + if (args.isEmpty() || args.contains("Hammer")) { + for (Entry> entry : HammerRegistry.getRewards().entrySet()) { + for (Smashable recipe : entry.getValue()) { + MineTweakerAPI.logCommand( + String.format( + "mods.exnihilo.Hammer.addRecipe(%s, %s, %s, %s);", + LogHelper.getStackDescription(entry.getKey().getStack()), + LogHelper.getStackDescription(new ItemStack(recipe.item, 1, recipe.meta)), + recipe.chance, + recipe.luckMultiplier)); } } } - - if(args.isEmpty() || args.contains("Sieve")) { - for(Entry> entry : SieveRegistry.getSiftables().entrySet()) { - for(SiftingResult recipe : entry.getValue()) { - MineTweakerAPI.logCommand(String.format("mods.exnihilo.Sieve.addRecipe(%s, %s, %s);", - LogHelper.getStackDescription(entry.getKey().getStack()), - LogHelper.getStackDescription(new ItemStack(recipe.item, 1, recipe.meta)), - recipe.rarity)); + + if (args.isEmpty() || args.contains("Sieve")) { + for (Entry> entry : SieveRegistry.getSiftables().entrySet()) { + for (SiftingResult recipe : entry.getValue()) { + MineTweakerAPI.logCommand( + String.format( + "mods.exnihilo.Sieve.addRecipe(%s, %s, %s);", + LogHelper.getStackDescription(entry.getKey().getStack()), + LogHelper.getStackDescription(new ItemStack(recipe.item, 1, recipe.meta)), + recipe.rarity)); } } } - + if (player != null) { - player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir")); + player.sendChat( + MineTweakerImplementationAPI.platform + .getMessage("List generated; see minetweaker.log in your minecraft dir")); } } } diff --git a/src/main/java/modtweaker2/mods/exnihilo/handlers/Compost.java b/src/main/java/modtweaker2/mods/exnihilo/handlers/Compost.java index 04c4457..eaaf707 100644 --- a/src/main/java/modtweaker2/mods/exnihilo/handlers/Compost.java +++ b/src/main/java/modtweaker2/mods/exnihilo/handlers/Compost.java @@ -22,37 +22,35 @@ import exnihilo.registries.helpers.Color; import exnihilo.registries.helpers.Compostable; import exnihilo.utils.ItemInfo; - @ZenClass("mods.exnihilo.Composting") public class Compost { - + public static final String name = "ExNihilo Composting"; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @ZenMethod public static void addRecipe(IItemStack input, double value, @Optional String hex) { - if(input == null) { + if (input == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - + hex = (hex == null || hex.equals("")) ? "35A82A" : hex; - + Map recipes = new HashMap(); - - recipes.put( - new ItemInfo(toStack(input)), - new Compostable(Math.min(1.0F, (float)value), new Color(hex))); - + + recipes.put(new ItemInfo(toStack(input)), new Compostable(Math.min(1.0F, (float) value), new Color(hex))); + MineTweakerAPI.apply(new Add(recipes)); } - + private static class Add extends BaseMapAddition { + public Add(Map recipes) { super(Compost.name, CompostRegistry.entries, recipes); } - + @Override protected String getRecipeInfo(Entry recipe) { return LogHelper.getStackDescription(recipe.getKey().getStack()); @@ -64,26 +62,28 @@ public class Compost { @ZenMethod public static void removeRecipe(IIngredient input) { Map recipes = new HashMap(); - - for(Entry recipe : CompostRegistry.entries.entrySet()) { - if(matches(input, toIItemStack(recipe.getKey().getStack()))) { + + for (Entry recipe : CompostRegistry.entries.entrySet()) { + if (matches(input, toIItemStack(recipe.getKey().getStack()))) { recipes.put(recipe.getKey(), recipe.getValue()); } } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new Remove(recipes)); } else { - LogHelper.logWarning(String.format("No %s recipes found for %s. Command ignored!", Compost.name, input.toString())); + LogHelper.logWarning( + String.format("No %s recipes found for %s. Command ignored!", Compost.name, input.toString())); } - + } - + private static class Remove extends BaseMapRemoval { + public Remove(Map recipes) { super(Compost.name, CompostRegistry.entries, recipes); } - + @Override protected String getRecipeInfo(Entry recipe) { return LogHelper.getStackDescription(recipe.getKey().getStack()); diff --git a/src/main/java/modtweaker2/mods/exnihilo/handlers/Crucible.java b/src/main/java/modtweaker2/mods/exnihilo/handlers/Crucible.java index 851d76f..87841c2 100644 --- a/src/main/java/modtweaker2/mods/exnihilo/handlers/Crucible.java +++ b/src/main/java/modtweaker2/mods/exnihilo/handlers/Crucible.java @@ -19,9 +19,11 @@ import modtweaker2.helpers.LogHelper; import modtweaker2.mods.exnihilo.ExNihiloHelper; import modtweaker2.utils.BaseMapAddition; import modtweaker2.utils.BaseMapRemoval; + import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; + import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; import exnihilo.registries.CrucibleRegistry; @@ -33,27 +35,27 @@ public class Crucible { public static final String nameMelting = "ExNihilo Crucible (Melting)"; public static final String nameHeatSource = "ExNihilo Crucible (Heat source)"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /************************************************ Crucible Melting ************************************************/ - //Adding a Ex Nihilo Crucible recipe + // Adding a Ex Nihilo Crucible recipe @ZenMethod public static void addRecipe(IItemStack input, ILiquidStack fluid) { - if(input == null || fluid == null) { + if (input == null || fluid == null) { LogHelper.logError(String.format("Required parameters missing for %s recipe.", nameMelting)); return; } - - if(!isABlock(input)) { + + if (!isABlock(input)) { LogHelper.logError(String.format("Input item for %s recipe must be a block.", nameMelting)); return; } - + Map recipes = new HashMap(); Block theBlock = Block.getBlockFromItem(toStack(input).getItem()); int theMeta = toStack(input).getItemDamage(); - + recipes.put( theBlock + ":" + theMeta, new Meltable(theBlock, theMeta, 2000, toFluid(fluid).getFluid(), toFluid(fluid).amount, theBlock)); @@ -61,12 +63,13 @@ public class Crucible { MineTweakerAPI.apply(new AddRecipe(recipes)); } - //Passes the list to the map list implementation, and adds the recipe + // Passes the list to the map list implementation, and adds the recipe private static class AddRecipe extends BaseMapAddition { + public AddRecipe(Map recipes) { super(nameMelting, CrucibleRegistry.entries, recipes); } - + @Override protected String getRecipeInfo(Entry recipe) { return LogHelper.getStackDescription(new ItemStack(recipe.getValue().block, 1, recipe.getValue().meta)); @@ -75,27 +78,32 @@ public class Crucible { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //Removing a Ex Nihilo Crucible recipe + // Removing a Ex Nihilo Crucible recipe @ZenMethod public static void removeRecipe(IIngredient output) { Map recipes = new HashMap(); - - for(Entry entry : CrucibleRegistry.entries.entrySet()) { - FluidStack fluid = new FluidStack(entry.getValue().fluid, (int)entry.getValue().fluidVolume); - if(matches(output, toILiquidStack(fluid))) { + + for (Entry entry : CrucibleRegistry.entries.entrySet()) { + FluidStack fluid = new FluidStack(entry.getValue().fluid, (int) entry.getValue().fluidVolume); + if (matches(output, toILiquidStack(fluid))) { recipes.put(entry.getKey(), entry.getValue()); } } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new RemoveRecipe(recipes)); } else { - LogHelper.logWarning(String.format("No %s recipe found for %s. Command ignored!", Crucible.nameMelting, output.toString())); + LogHelper.logWarning( + String.format( + "No %s recipe found for %s. Command ignored!", + Crucible.nameMelting, + output.toString())); } } - //Removes a recipe, will always remove the key, so all should be good + // Removes a recipe, will always remove the key, so all should be good private static class RemoveRecipe extends BaseMapRemoval { + public RemoveRecipe(Map recipes) { super(nameMelting, CrucibleRegistry.entries, recipes); } @@ -106,71 +114,77 @@ public class Crucible { } } - /********************************************** Crucible Heat Sources **********************************************/ - //Adding a Ex Nihilo Crucible heat source + /********************************************** + * Crucible Heat Sources + **********************************************/ + // Adding a Ex Nihilo Crucible heat source @ZenMethod public static void addHeatSource(IItemStack input, double value) { - if(input == null) { + if (input == null) { LogHelper.logError(String.format("Required parameters missing for %s recipe.", nameMelting)); return; } - - if(!isABlock(input)) { + + if (!isABlock(input)) { LogHelper.logError(String.format("Input item for %s recipe must be a block.", nameMelting)); return; } - + Map recipes = new HashMap(); - recipes.put(new ItemInfo(toStack(input)), (float)value); - - if(!recipes.isEmpty()) { + recipes.put(new ItemInfo(toStack(input)), (float) value); + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new AddHeatSource(recipes)); } } - //Passes the list to the base map implementation, and adds the recipe - private static class AddHeatSource extends BaseMapAddition - { - public AddHeatSource(Map recipes) { - super(Crucible.nameHeatSource, ExNihiloHelper.getHeatMap(), recipes); - } + // Passes the list to the base map implementation, and adds the recipe + private static class AddHeatSource extends BaseMapAddition { - @Override - protected String getRecipeInfo(Entry recipe) { - return LogHelper.getStackDescription(recipe.getKey().getStack()); - } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - //Removing a Ex Nihilo Crucible heat source - @ZenMethod - public static void removeHeatSource(IIngredient output) { - Map recipes = new HashMap(); - - for(Entry entry : ExNihiloHelper.getHeatMap().entrySet()) { - if(matches(output, toIItemStack(entry.getKey().getStack()))) { - recipes.put(entry.getKey(), entry.getValue()); - } - } - - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new RemoveHeatSource(recipes)); - } else { - LogHelper.logWarning(String.format("No %s recipe found for %s. Command ignored!", Crucible.nameMelting, output.toString())); - } - } - - //Removes a recipe, will always remove the key, so all should be good - private static class RemoveHeatSource extends BaseMapRemoval - { - public RemoveHeatSource(Map recipes) { - super(Crucible.nameHeatSource, ExNihiloHelper.getHeatMap(), recipes); + public AddHeatSource(Map recipes) { + super(Crucible.nameHeatSource, ExNihiloHelper.getHeatMap(), recipes); } @Override protected String getRecipeInfo(Entry recipe) { return LogHelper.getStackDescription(recipe.getKey().getStack()); } - } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // Removing a Ex Nihilo Crucible heat source + @ZenMethod + public static void removeHeatSource(IIngredient output) { + Map recipes = new HashMap(); + + for (Entry entry : ExNihiloHelper.getHeatMap().entrySet()) { + if (matches(output, toIItemStack(entry.getKey().getStack()))) { + recipes.put(entry.getKey(), entry.getValue()); + } + } + + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new RemoveHeatSource(recipes)); + } else { + LogHelper.logWarning( + String.format( + "No %s recipe found for %s. Command ignored!", + Crucible.nameMelting, + output.toString())); + } + } + + // Removes a recipe, will always remove the key, so all should be good + private static class RemoveHeatSource extends BaseMapRemoval { + + public RemoveHeatSource(Map recipes) { + super(Crucible.nameHeatSource, ExNihiloHelper.getHeatMap(), recipes); + } + + @Override + protected String getRecipeInfo(Entry recipe) { + return LogHelper.getStackDescription(recipe.getKey().getStack()); + } + } } diff --git a/src/main/java/modtweaker2/mods/exnihilo/handlers/Hammer.java b/src/main/java/modtweaker2/mods/exnihilo/handlers/Hammer.java index 0986297..daaf0bb 100644 --- a/src/main/java/modtweaker2/mods/exnihilo/handlers/Hammer.java +++ b/src/main/java/modtweaker2/mods/exnihilo/handlers/Hammer.java @@ -18,8 +18,10 @@ import minetweaker.api.item.IngredientAny; import modtweaker2.helpers.LogHelper; import modtweaker2.utils.BaseMapAddition; import modtweaker2.utils.BaseMapRemoval; + import net.minecraft.block.Block; import net.minecraft.item.ItemStack; + import stanhebben.zenscript.annotations.Optional; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; @@ -29,221 +31,251 @@ import exnihilo.utils.ItemInfo; @ZenClass("mods.exnihilo.Hammer") public class Hammer { - + public static final String name = "ExNihilo Hammer"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - @ZenMethod - public static void addRecipe(IItemStack input, IItemStack output, double chance, double luck) { - if(input == null || output == null) { + @ZenMethod + public static void addRecipe(IItemStack input, IItemStack output, double chance, double luck) { + if (input == null || output == null) { LogHelper.logError(String.format("Required parameters missing for %s recipe.", name)); return; } - + addRecipe(input, new IItemStack[] { output }, new double[] { chance }, new double[] { luck }); - } - - @ZenMethod - public static void addRecipe(IItemStack input, IItemStack[] output, double[] chance, double[] luck) { - if(input == null || output == null || chance == null || luck == null) { + } + + @ZenMethod + public static void addRecipe(IItemStack input, IItemStack[] output, double[] chance, double[] luck) { + if (input == null || output == null || chance == null || luck == null) { LogHelper.logError(String.format("Required parameters missing for %s recipe.", name)); return; - } - - if(!isABlock(input)) { + } + + if (!isABlock(input)) { LogHelper.logError(String.format("Input item for %s recipe must be a block.", name)); return; } - - if(output.length == 0 || output.length != chance.length || output.length != luck.length) { - LogHelper.logError(String.format("Number of items in arrays are different or null (%d, %d, %d)", output.length, chance.length, luck.length)); - return; - } - - Map> recipes = new HashMap>(); - ArrayList list = new ArrayList(); - ItemInfo itemInfo = new ItemInfo(toStack(input)); - recipes.put(itemInfo, list); - - for(int i = 0; i < output.length; i++) { - ItemStack out = toStack(output[i]); - list.add(new Smashable(Block.getBlockFromItem(itemInfo.getItem()), itemInfo.getMeta(), out.getItem(), out.getItemDamage(), (float)chance[i], (float)luck[i])); - } - - MineTweakerAPI.apply(new Add(recipes)); - } - private static class Add extends BaseMapAddition> { - public Add(Map> recipes) { - super(Hammer.name, HammerRegistry.getRewards(), recipes); - } + if (output.length == 0 || output.length != chance.length || output.length != luck.length) { + LogHelper.logError( + String.format( + "Number of items in arrays are different or null (%d, %d, %d)", + output.length, + chance.length, + luck.length)); + return; + } - public void apply() { - for(Entry> entry : recipes.entrySet()) { - if(!map.containsKey(entry.getKey())) { - // no recipe for input available, add new entry - map.put(entry.getKey(), new ArrayList(entry.getValue())); - } else { - // recipes already available, add to present list - ArrayList list = map.get(entry.getKey()); - - // store old Smashable objects if present - ArrayList backup = new ArrayList(); - for(Smashable recipe : entry.getValue()) { - backup.addAll(removeFromList(list, recipe)); - } - - if(!backup.isEmpty()) { - LogHelper.logWarning(String.format("Overwritten %d %s recipe outputs for %s.", backup.size(), Hammer.name, LogHelper.getStackDescription(entry.getKey().getStack()))); - overwritten.put(entry.getKey(), backup); - } - - // add new Smashable objects - list.addAll(entry.getValue()); - } - - successful.put(entry.getKey(), entry.getValue()); - } - } + Map> recipes = new HashMap>(); + ArrayList list = new ArrayList(); + ItemInfo itemInfo = new ItemInfo(toStack(input)); + recipes.put(itemInfo, list); - public void undo() { - // remove all recipes - for(Entry> entry : successful.entrySet()) { - ArrayList list = map.get(entry.getKey()); - for(Smashable recipe : entry.getValue()) { - removeFromList(list, recipe); - } - } - - // re-add overwritten recipes - for(Entry> entry : overwritten.entrySet()) { - map.get(entry.getKey()).addAll(entry.getValue()); - } - - // remove empty entries - for(Iterator>> it = map.entrySet().iterator(); it.hasNext(); ) { - Entry> entry = it.next(); - if(entry.getValue().isEmpty()) { - it.remove(); - } - } - } - - @Override - protected String getRecipeInfo(Entry> recipe) { - return LogHelper.getStackDescription(recipe.getKey().getStack()) + " (" + recipe.getValue().size() + " entries)"; - } - } + for (int i = 0; i < output.length; i++) { + ItemStack out = toStack(output[i]); + list.add( + new Smashable( + Block.getBlockFromItem(itemInfo.getItem()), + itemInfo.getMeta(), + out.getItem(), + out.getItemDamage(), + (float) chance[i], + (float) luck[i])); + } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + MineTweakerAPI.apply(new Add(recipes)); + } - @Deprecated - @ZenMethod - public static void removeRecipe(IItemStack inputBlock, int inputBlockMeta, IItemStack outputItem, int outputItemMeta) { - removeRecipe(toIItemStack(new ItemStack(toStack(inputBlock).getItem(), 1, inputBlockMeta)), toIItemStack(new ItemStack(toStack(outputItem).getItem(), 1, outputItemMeta))); - } - - @ZenMethod - public static void removeRecipe(IIngredient input, @Optional IIngredient output) { - if(input == null) { + private static class Add extends BaseMapAddition> { + + public Add(Map> recipes) { + super(Hammer.name, HammerRegistry.getRewards(), recipes); + } + + public void apply() { + for (Entry> entry : recipes.entrySet()) { + if (!map.containsKey(entry.getKey())) { + // no recipe for input available, add new entry + map.put(entry.getKey(), new ArrayList(entry.getValue())); + } else { + // recipes already available, add to present list + ArrayList list = map.get(entry.getKey()); + + // store old Smashable objects if present + ArrayList backup = new ArrayList(); + for (Smashable recipe : entry.getValue()) { + backup.addAll(removeFromList(list, recipe)); + } + + if (!backup.isEmpty()) { + LogHelper.logWarning( + String.format( + "Overwritten %d %s recipe outputs for %s.", + backup.size(), + Hammer.name, + LogHelper.getStackDescription(entry.getKey().getStack()))); + overwritten.put(entry.getKey(), backup); + } + + // add new Smashable objects + list.addAll(entry.getValue()); + } + + successful.put(entry.getKey(), entry.getValue()); + } + } + + public void undo() { + // remove all recipes + for (Entry> entry : successful.entrySet()) { + ArrayList list = map.get(entry.getKey()); + for (Smashable recipe : entry.getValue()) { + removeFromList(list, recipe); + } + } + + // re-add overwritten recipes + for (Entry> entry : overwritten.entrySet()) { + map.get(entry.getKey()).addAll(entry.getValue()); + } + + // remove empty entries + for (Iterator>> it = map.entrySet().iterator(); it.hasNext();) { + Entry> entry = it.next(); + if (entry.getValue().isEmpty()) { + it.remove(); + } + } + } + + @Override + protected String getRecipeInfo(Entry> recipe) { + return LogHelper.getStackDescription(recipe.getKey().getStack()) + " (" + + recipe.getValue().size() + + " entries)"; + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + @Deprecated + @ZenMethod + public static void removeRecipe(IItemStack inputBlock, int inputBlockMeta, IItemStack outputItem, + int outputItemMeta) { + removeRecipe( + toIItemStack(new ItemStack(toStack(inputBlock).getItem(), 1, inputBlockMeta)), + toIItemStack(new ItemStack(toStack(outputItem).getItem(), 1, outputItemMeta))); + } + + @ZenMethod + public static void removeRecipe(IIngredient input, @Optional IIngredient output) { + if (input == null) { LogHelper.logError(String.format("Required parameters missing for %s recipe.", name)); return; } - - if(output == null) { + + if (output == null) { output = IngredientAny.INSTANCE; } - + Map> recipes = new HashMap>(); - - for(Entry> entry : HammerRegistry.getRewards().entrySet()) { - if(input.matches(toIItemStack(entry.getKey().getStack()))) { + + for (Entry> entry : HammerRegistry.getRewards().entrySet()) { + if (input.matches(toIItemStack(entry.getKey().getStack()))) { ArrayList list = entry.getValue(); ArrayList toRemove = new ArrayList(); - - for(Smashable recipe : list) { + + for (Smashable recipe : list) { ItemStack item = new ItemStack(recipe.item, 1, recipe.meta); - - if(matches(output, toIItemStack(item))) { + + if (matches(output, toIItemStack(item))) { toRemove.add(recipe); } } - - if(!toRemove.isEmpty()) { + + if (!toRemove.isEmpty()) { recipes.put(entry.getKey(), toRemove); } } } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new Remove(recipes)); } else { - LogHelper.logWarning(String.format("No %s recipes found for %s and %s. Command ignored!", name, input.toString(), output.toString())); + LogHelper.logWarning( + String.format( + "No %s recipes found for %s and %s. Command ignored!", + name, + input.toString(), + output.toString())); } - } + } - // Removes a recipe, apply is never the same for anything, so will always - // need to override it - private static class Remove extends BaseMapRemoval> { + // Removes a recipe, apply is never the same for anything, so will always + // need to override it + private static class Remove extends BaseMapRemoval> { - public Remove(Map> recipes) { - super(Hammer.name, HammerRegistry.getRewards(), recipes); - } + public Remove(Map> recipes) { + super(Hammer.name, HammerRegistry.getRewards(), recipes); + } + + @Override + public void apply() { + for (Entry> entry : recipes.entrySet()) { + ArrayList list = map.get(entry.getKey()); + + for (Smashable recipe : entry.getValue()) { + removeFromList(list, recipe); + } + + successful.put(entry.getKey(), entry.getValue()); + } - @Override - public void apply() { - for(Entry> entry : recipes.entrySet()) { - ArrayList list = map.get(entry.getKey()); - - for(Smashable recipe : entry.getValue()) { - removeFromList(list, recipe); - } - - successful.put(entry.getKey(), entry.getValue()); - } - // remove empty entries - for(Iterator>> it = map.entrySet().iterator(); it.hasNext(); ) { + for (Iterator>> it = map.entrySet().iterator(); it.hasNext();) { Entry> entry = it.next(); - if(entry.getValue().isEmpty()) { + if (entry.getValue().isEmpty()) { it.remove(); } } - } + } - @Override - public void undo() { - for(Entry> entry : successful.entrySet()) { - if(!map.containsKey(entry.getKey())) { + @Override + public void undo() { + for (Entry> entry : successful.entrySet()) { + if (!map.containsKey(entry.getKey())) { map.put(entry.getKey(), new ArrayList(entry.getValue())); } else { map.get(entry.getKey()).addAll(entry.getValue()); } - } - } - + } + } + @Override protected String getRecipeInfo(Entry> recipe) { - return LogHelper.getStackDescription(recipe.getKey().getStack()) + " (" + recipe.getValue().size() + " entries)"; + return LogHelper.getStackDescription(recipe.getKey().getStack()) + " (" + + recipe.getValue().size() + + " entries)"; } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + public static ArrayList removeFromList(ArrayList list, Smashable s) { ArrayList removed = new ArrayList(); ItemInfo toRemove = new ItemInfo(s.item, s.meta); - for(Iterator it = list.iterator(); it.hasNext(); ) { + for (Iterator it = list.iterator(); it.hasNext();) { Smashable itS = it.next(); ItemInfo item = new ItemInfo(itS.item, itS.meta); - - if(item.equals(toRemove)) { + + if (item.equals(toRemove)) { removed.add(itS); it.remove(); } } - + return removed; } } diff --git a/src/main/java/modtweaker2/mods/exnihilo/handlers/Sieve.java b/src/main/java/modtweaker2/mods/exnihilo/handlers/Sieve.java index 1d06552..d7c5477 100644 --- a/src/main/java/modtweaker2/mods/exnihilo/handlers/Sieve.java +++ b/src/main/java/modtweaker2/mods/exnihilo/handlers/Sieve.java @@ -18,7 +18,9 @@ import minetweaker.api.item.IngredientAny; import modtweaker2.helpers.LogHelper; import modtweaker2.utils.BaseMapAddition; import modtweaker2.utils.BaseMapRemoval; + import net.minecraft.item.ItemStack; + import stanhebben.zenscript.annotations.Optional; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; @@ -28,203 +30,216 @@ import exnihilo.utils.ItemInfo; @ZenClass("mods.exnihilo.Sieve") public class Sieve { - + public static final String name = "ExNihilo Sieve"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - // Adding a Ex Nihilo Sieve recipe - @ZenMethod - public static void addRecipe(IItemStack input, IItemStack output, int rarity) { - if(input == null || output == null) { + + // Adding a Ex Nihilo Sieve recipe + @ZenMethod + public static void addRecipe(IItemStack input, IItemStack output, int rarity) { + if (input == null || output == null) { LogHelper.logError(String.format("Required parameters missing for %s recipe.", name)); return; } - - addRecipe(input, new IItemStack[] { output }, new int[] { rarity }); - } + + addRecipe(input, new IItemStack[] { output }, new int[] { rarity }); + } @ZenMethod public static void addRecipe(IItemStack input, IItemStack[] output, int[] rarity) { - if(input == null || output == null || rarity == null) { + if (input == null || output == null || rarity == null) { LogHelper.logError(String.format("Required parameters missing for %s recipe.", name)); return; } - - if(!isABlock(input)) { + + if (!isABlock(input)) { LogHelper.logError(String.format("Input item for %s recipe must be a block.", name)); return; } - - if(output.length == 0 || output.length != rarity.length) { - LogHelper.logError(String.format("Number of items in arrays are different or null (%d, %d)", output.length, rarity.length)); + + if (output.length == 0 || output.length != rarity.length) { + LogHelper.logError( + String.format( + "Number of items in arrays are different or null (%d, %d)", + output.length, + rarity.length)); return; } - + Map> recipes = new HashMap>(); ArrayList list = new ArrayList(); ItemInfo itemInfo = new ItemInfo(toStack(input)); recipes.put(itemInfo, list); - - for(int i = 0; i < output.length; i++) { + + for (int i = 0; i < output.length; i++) { ItemStack out = toStack(output[i]); list.add(new SiftingResult(out.getItem(), out.getItemDamage(), rarity[i])); } - + MineTweakerAPI.apply(new Add(recipes)); - } + } - private static class Add extends BaseMapAddition> { + private static class Add extends BaseMapAddition> { - public Add(Map> recipes) { - super(Sieve.name, SieveRegistry.getSiftables(), recipes); - } - - @Override - public void apply() { - for(Entry> entry : recipes.entrySet()) { - if(!map.containsKey(entry.getKey())) { + public Add(Map> recipes) { + super(Sieve.name, SieveRegistry.getSiftables(), recipes); + } + + @Override + public void apply() { + for (Entry> entry : recipes.entrySet()) { + if (!map.containsKey(entry.getKey())) { // no recipe for input available, add new entry map.put(entry.getKey(), new ArrayList(entry.getValue())); } else { // recipes already available, add to present list ArrayList list = map.get(entry.getKey()); - + // store old SiftingResult objects if present ArrayList backup = new ArrayList(); - for(SiftingResult recipe : entry.getValue()) { + for (SiftingResult recipe : entry.getValue()) { backup.addAll(removeFromList(list, recipe)); } - - if(!backup.isEmpty()) { - LogHelper.logWarning(String.format("Overwritten %d %s recipe outputs for %s.", backup.size(), name, LogHelper.getStackDescription(entry.getKey().getStack()))); + + if (!backup.isEmpty()) { + LogHelper.logWarning( + String.format( + "Overwritten %d %s recipe outputs for %s.", + backup.size(), + name, + LogHelper.getStackDescription(entry.getKey().getStack()))); overwritten.put(entry.getKey(), backup); } - + // add new SiftingResult objects list.addAll(entry.getValue()); } - + successful.put(entry.getKey(), entry.getValue()); } - } - - @Override - public void undo() { + } + + @Override + public void undo() { // remove all recipes - for(Entry> entry : successful.entrySet()) { + for (Entry> entry : successful.entrySet()) { ArrayList list = map.get(entry.getKey()); - for(SiftingResult recipe : entry.getValue()) { + for (SiftingResult recipe : entry.getValue()) { removeFromList(list, recipe); } } - + // re-add overwritten recipes - for(Entry> entry : overwritten.entrySet()) { + for (Entry> entry : overwritten.entrySet()) { map.get(entry.getKey()).addAll(entry.getValue()); } - + // remove empty entries - for(Iterator>> it = map.entrySet().iterator(); it.hasNext(); ) { + for (Iterator>> it = map.entrySet().iterator(); it.hasNext();) { Entry> entry = it.next(); - if(entry.getValue().isEmpty()) { + if (entry.getValue().isEmpty()) { it.remove(); } } - } + } @Override protected String getRecipeInfo(Entry> recipe) { - return LogHelper.getStackDescription(recipe.getKey().getStack()) + " (" + recipe.getValue().size() + " entries)"; + return LogHelper.getStackDescription(recipe.getKey().getStack()) + " (" + + recipe.getValue().size() + + " entries)"; } - } + } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - @Deprecated - @ZenMethod - public static void removeRecipe(IItemStack input, IItemStack output) { - removeRecipe((IIngredient)input, (IIngredient)output); - } + @Deprecated + @ZenMethod + public static void removeRecipe(IItemStack input, IItemStack output) { + removeRecipe((IIngredient) input, (IIngredient) output); + } - @Deprecated - @ZenMethod - public static void removeRewardFromAllBlocks(IItemStack output) - { - removeRecipe(IngredientAny.INSTANCE, (IIngredient)output); - } + @Deprecated + @ZenMethod + public static void removeRewardFromAllBlocks(IItemStack output) { + removeRecipe(IngredientAny.INSTANCE, (IIngredient) output); + } - @Deprecated - @ZenMethod - public static void removeAllRewardsFromBlock(IItemStack output) - { - removeRecipe((IIngredient)output, IngredientAny.INSTANCE); - } - - @ZenMethod - public static void removeRecipe(IIngredient input, @Optional IIngredient output) { - if(input == null) { + @Deprecated + @ZenMethod + public static void removeAllRewardsFromBlock(IItemStack output) { + removeRecipe((IIngredient) output, IngredientAny.INSTANCE); + } + + @ZenMethod + public static void removeRecipe(IIngredient input, @Optional IIngredient output) { + if (input == null) { LogHelper.logError(String.format("Required parameters missing for %s recipe.", name)); return; } - - if(output == null) { + + if (output == null) { output = IngredientAny.INSTANCE; } - + Map> recipes = new HashMap>(); - - for(Entry> entry : SieveRegistry.getSiftables().entrySet()) { - if(input.matches(toIItemStack(entry.getKey().getStack()))) { + + for (Entry> entry : SieveRegistry.getSiftables().entrySet()) { + if (input.matches(toIItemStack(entry.getKey().getStack()))) { ArrayList list = entry.getValue(); ArrayList toRemove = new ArrayList(); - - for(SiftingResult recipe : list) { + + for (SiftingResult recipe : list) { ItemStack item = new ItemStack(recipe.item, 1, recipe.meta); - - if(matches(output, toIItemStack(item))) { + + if (matches(output, toIItemStack(item))) { toRemove.add(recipe); } } - - if(!toRemove.isEmpty()) { + + if (!toRemove.isEmpty()) { recipes.put(entry.getKey(), toRemove); } } } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new Remove(recipes)); } else { - LogHelper.logWarning(String.format("No %s recipes found for %s and %s. Command ignored!", name, input.toString(), output.toString())); + LogHelper.logWarning( + String.format( + "No %s recipes found for %s and %s. Command ignored!", + name, + input.toString(), + output.toString())); } - } + } + // Removes a recipe, apply is never the same for anything, so will always + // need to override it + private static class Remove extends BaseMapRemoval> { + public Remove(Map> recipes) { + super(Sieve.name, SieveRegistry.getSiftables(), recipes); + } - // Removes a recipe, apply is never the same for anything, so will always - // need to override it - private static class Remove extends BaseMapRemoval> { - public Remove(Map> recipes) { - super(Sieve.name, SieveRegistry.getSiftables(), recipes); - } - @Override public void apply() { - for(Entry> entry : recipes.entrySet()) { + for (Entry> entry : recipes.entrySet()) { ArrayList list = map.get(entry.getKey()); - - for(SiftingResult recipe : entry.getValue()) { + + for (SiftingResult recipe : entry.getValue()) { removeFromList(list, recipe); } - + successful.put(entry.getKey(), entry.getValue()); } - + // remove empty entries - for(Iterator>> it = map.entrySet().iterator(); it.hasNext(); ) { + for (Iterator>> it = map.entrySet().iterator(); it.hasNext();) { Entry> entry = it.next(); - if(entry.getValue().isEmpty()) { + if (entry.getValue().isEmpty()) { it.remove(); } } @@ -232,36 +247,38 @@ public class Sieve { @Override public void undo() { - for(Entry> entry : successful.entrySet()) { - if(!map.containsKey(entry.getKey())) { + for (Entry> entry : successful.entrySet()) { + if (!map.containsKey(entry.getKey())) { map.put(entry.getKey(), new ArrayList(entry.getValue())); } else { map.get(entry.getKey()).addAll(entry.getValue()); } } } - + @Override protected String getRecipeInfo(Entry> recipe) { - return LogHelper.getStackDescription(recipe.getKey().getStack()) + " (" + recipe.getValue().size() + " entries)"; + return LogHelper.getStackDescription(recipe.getKey().getStack()) + " (" + + recipe.getValue().size() + + " entries)"; } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + public static ArrayList removeFromList(ArrayList list, SiftingResult s) { ArrayList removed = new ArrayList(); ItemInfo toRemove = new ItemInfo(s.item, s.meta); - for(Iterator it = list.iterator(); it.hasNext(); ) { + for (Iterator it = list.iterator(); it.hasNext();) { SiftingResult itS = it.next(); ItemInfo item = new ItemInfo(itS.item, itS.meta); - - if(item.equals(toRemove)) { + + if (item.equals(toRemove)) { removed.add(itS); it.remove(); } } - + return removed; } } diff --git a/src/main/java/modtweaker2/mods/extendedworkbench/ExtendedWorkbench.java b/src/main/java/modtweaker2/mods/extendedworkbench/ExtendedWorkbench.java index 0e23edf..cd061d0 100644 --- a/src/main/java/modtweaker2/mods/extendedworkbench/ExtendedWorkbench.java +++ b/src/main/java/modtweaker2/mods/extendedworkbench/ExtendedWorkbench.java @@ -4,6 +4,7 @@ import minetweaker.MineTweakerAPI; import modtweaker2.mods.extendedworkbench.handlers.ExtendedCrafting; public class ExtendedWorkbench { + public ExtendedWorkbench() { MineTweakerAPI.registerClass(ExtendedCrafting.class); } diff --git a/src/main/java/modtweaker2/mods/extendedworkbench/handlers/ExtendedCrafting.java b/src/main/java/modtweaker2/mods/extendedworkbench/handlers/ExtendedCrafting.java index 7db7b57..0fd10bb 100644 --- a/src/main/java/modtweaker2/mods/extendedworkbench/handlers/ExtendedCrafting.java +++ b/src/main/java/modtweaker2/mods/extendedworkbench/handlers/ExtendedCrafting.java @@ -16,16 +16,18 @@ import naruto1310.extendedWorkbench.crafting.ExtendedCraftingManager; import naruto1310.extendedWorkbench.crafting.ExtendedShapedRecipes; import naruto1310.extendedWorkbench.crafting.ExtendedShapelessRecipes; import naruto1310.extendedWorkbench.crafting.IExtendedRecipe; + import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; + import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; @ZenClass("mods.extendedworkbench") public class ExtendedCrafting { - + public static final String name = "Extended Workbench"; - + @ZenMethod public static void addShaped(IItemStack output, IItemStack[][] ingredients) { MineTweakerAPI.apply(new Add(getShapedRecipe(output, ingredients))); @@ -33,10 +35,12 @@ public class ExtendedCrafting { @ZenMethod public static void addShapeless(IItemStack output, IItemStack[] ingredients) { - MineTweakerAPI.apply(new Add(new ExtendedShapelessRecipes(toStack(output), Arrays.asList(toStacks(ingredients))))); + MineTweakerAPI + .apply(new Add(new ExtendedShapelessRecipes(toStack(output), Arrays.asList(toStacks(ingredients))))); } private static class Add extends BaseCraftingAddition { + public Add(IExtendedRecipe recipe) { super(ExtendedCrafting.name, ExtendedCraftingManager.getInstance().getRecipeList()); recipes.add(recipe); @@ -71,12 +75,18 @@ public class ExtendedCrafting { @ZenMethod public static void removeRecipe(IIngredient output) { - List recipes = BaseCraftingRemoval.getRecipes(ExtendedCraftingManager.getInstance().getRecipeList(), output); - - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new BaseCraftingRemoval(ExtendedCrafting.name, ExtendedCraftingManager.getInstance().getRecipeList(), recipes)); + List recipes = BaseCraftingRemoval + .getRecipes(ExtendedCraftingManager.getInstance().getRecipeList(), output); + + if (!recipes.isEmpty()) { + MineTweakerAPI.apply( + new BaseCraftingRemoval( + ExtendedCrafting.name, + ExtendedCraftingManager.getInstance().getRecipeList(), + recipes)); } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", ExtendedCrafting.name, output)); + LogHelper.logWarning( + String.format("No %s Recipe found for %s. Command ignored!", ExtendedCrafting.name, output)); } } } diff --git a/src/main/java/modtweaker2/mods/extraUtils/ExtraUtils.java b/src/main/java/modtweaker2/mods/extraUtils/ExtraUtils.java index 3f2febf..2191167 100644 --- a/src/main/java/modtweaker2/mods/extraUtils/ExtraUtils.java +++ b/src/main/java/modtweaker2/mods/extraUtils/ExtraUtils.java @@ -1,12 +1,11 @@ package modtweaker2.mods.extraUtils; import minetweaker.MineTweakerAPI; -import modtweaker2.mods.appeng.handlers.Grind; import modtweaker2.mods.extraUtils.handlers.QED; public class ExtraUtils { - public ExtraUtils() { - MineTweakerAPI.registerClass(QED.class); - } + public ExtraUtils() { + MineTweakerAPI.registerClass(QED.class); + } } diff --git a/src/main/java/modtweaker2/mods/extraUtils/handlers/QED.java b/src/main/java/modtweaker2/mods/extraUtils/handlers/QED.java index 2321e73..33bcc0c 100644 --- a/src/main/java/modtweaker2/mods/extraUtils/handlers/QED.java +++ b/src/main/java/modtweaker2/mods/extraUtils/handlers/QED.java @@ -1,5 +1,8 @@ package modtweaker2.mods.extraUtils.handlers; +import static modtweaker2.helpers.InputHelper.toIItemStack; +import static modtweaker2.helpers.StackHelper.matches; + import java.util.LinkedList; import minetweaker.MineTweakerAPI; @@ -9,66 +12,71 @@ import modtweaker2.helpers.InputHelper; import modtweaker2.helpers.LogHelper; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; + import net.minecraft.item.crafting.IRecipe; import net.minecraftforge.oredict.ShapedOreRecipe; + import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; import com.rwtema.extrautils.tileentity.enderconstructor.EnderConstructorRecipesHandler; -import static modtweaker2.helpers.InputHelper.toIItemStack; -import static modtweaker2.helpers.StackHelper.matches; - @ZenClass("mods.extraUtils.QED") public class QED { - public static final String name = "ExtraUtilities Q.E.D."; + public static final String name = "ExtraUtilities Q.E.D."; - @ZenMethod - public static void addShapedRecipe(IItemStack output, IIngredient[][] recipe) { - MineTweakerAPI.apply(new Add(new ShapedOreRecipe(InputHelper.toStack(output), InputHelper.toShapedObjects(recipe)))); - } - - private static class Add extends BaseListAddition { + @ZenMethod + public static void addShapedRecipe(IItemStack output, IIngredient[][] recipe) { + MineTweakerAPI + .apply(new Add(new ShapedOreRecipe(InputHelper.toStack(output), InputHelper.toShapedObjects(recipe)))); + } - public Add(IRecipe recipe) { - super("QED", EnderConstructorRecipesHandler.recipes); - recipes.add(recipe); - } + private static class Add extends BaseListAddition { - @Override - protected String getRecipeInfo(IRecipe recipe) { - return recipe.toString(); - } - } + public Add(IRecipe recipe) { + super("QED", EnderConstructorRecipesHandler.recipes); + recipes.add(recipe); + } - @ZenMethod - public static void removeRecipe(IIngredient output) { - LinkedList recipes = new LinkedList(); + @Override + protected String getRecipeInfo(IRecipe recipe) { + return recipe.toString(); + } + } - for (IRecipe recipe : EnderConstructorRecipesHandler.recipes) { - if (recipe != null && recipe.getRecipeOutput() != null && matches(output, toIItemStack(recipe.getRecipeOutput()))) { - recipes.add(recipe); - } - } + @ZenMethod + public static void removeRecipe(IIngredient output) { + LinkedList recipes = new LinkedList(); - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new Remove(recipes)); - } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", QED.name, LogHelper.getStackDescription(output))); - } - } + for (IRecipe recipe : EnderConstructorRecipesHandler.recipes) { + if (recipe != null && recipe.getRecipeOutput() != null + && matches(output, toIItemStack(recipe.getRecipeOutput()))) { + recipes.add(recipe); + } + } - public static class Remove extends BaseListRemoval { + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new Remove(recipes)); + } else { + LogHelper.logWarning( + String.format( + "No %s Recipe found for %s. Command ignored!", + QED.name, + LogHelper.getStackDescription(output))); + } + } - protected Remove(LinkedList stacks) { - super("QED", EnderConstructorRecipesHandler.recipes, stacks); - } + public static class Remove extends BaseListRemoval { - @Override - protected String getRecipeInfo(IRecipe recipe) { - return recipe.toString(); - } - } + protected Remove(LinkedList stacks) { + super("QED", EnderConstructorRecipesHandler.recipes, stacks); + } + + @Override + protected String getRecipeInfo(IRecipe recipe) { + return recipe.toString(); + } + } } diff --git a/src/main/java/modtweaker2/mods/factorization/Factorization.java b/src/main/java/modtweaker2/mods/factorization/Factorization.java index 34af896..e32cb1d 100644 --- a/src/main/java/modtweaker2/mods/factorization/Factorization.java +++ b/src/main/java/modtweaker2/mods/factorization/Factorization.java @@ -6,6 +6,7 @@ import modtweaker2.mods.factorization.handlers.Lacerator; import modtweaker2.mods.factorization.handlers.SlagFurnace; public class Factorization { + public Factorization() { MineTweakerAPI.registerClass(Crystallizer.class); MineTweakerAPI.registerClass(Lacerator.class); diff --git a/src/main/java/modtweaker2/mods/factorization/FactorizationHelper.java b/src/main/java/modtweaker2/mods/factorization/FactorizationHelper.java index 0a576bb..c528498 100644 --- a/src/main/java/modtweaker2/mods/factorization/FactorizationHelper.java +++ b/src/main/java/modtweaker2/mods/factorization/FactorizationHelper.java @@ -5,35 +5,54 @@ import static modtweaker2.helpers.ReflectionHelper.getStaticObject; import java.util.List; import modtweaker2.helpers.ReflectionHelper; + import net.minecraft.item.ItemStack; public class FactorizationHelper { + @SuppressWarnings("rawtypes") public static List lacerator = null; @SuppressWarnings("rawtypes") public static List slag = null; @SuppressWarnings("rawtypes") public static List crystallizer = null; - + static { try { - lacerator = getStaticObject(Class.forName("factorization.oreprocessing.TileEntityGrinder"), "recipes"); - slag = ReflectionHelper.getObject(getStaticObject(Class.forName("factorization.oreprocessing.TileEntitySlagFurnace"), "recipes"), "list"); - crystallizer = ReflectionHelper.getObject(getStaticObject(Class.forName("factorization.oreprocessing.TileEntityCrystallizer"), "recipes"), "list"); + lacerator = getStaticObject(Class.forName("factorization.oreprocessing.TileEntityGrinder"), "recipes"); + slag = ReflectionHelper.getObject( + getStaticObject(Class.forName("factorization.oreprocessing.TileEntitySlagFurnace"), "recipes"), + "list"); + crystallizer = ReflectionHelper.getObject( + getStaticObject(Class.forName("factorization.oreprocessing.TileEntityCrystallizer"), "recipes"), + "list"); } catch (Exception e) {} } private FactorizationHelper() {} public static Object getLaceratorRecipe(Object input, ItemStack output, float probability) { - return ReflectionHelper.getInstance(ReflectionHelper.getConstructor("factorization.oreprocessing.TileEntityGrinder$GrinderRecipe", Object.class, ItemStack.class, float.class), + return ReflectionHelper.getInstance( + ReflectionHelper.getConstructor( + "factorization.oreprocessing.TileEntityGrinder$GrinderRecipe", + Object.class, + ItemStack.class, + float.class), input, output, probability); } - public static Object getSlagFurnaceRecipe(ItemStack input, float chance1, ItemStack output1, float chance2, ItemStack output2) { - return ReflectionHelper.getInstance(ReflectionHelper.getConstructor("factorization.oreprocessing.TileEntitySlagFurnace$SmeltingResult", ItemStack.class, float.class, ItemStack.class, float.class, ItemStack.class), + public static Object getSlagFurnaceRecipe(ItemStack input, float chance1, ItemStack output1, float chance2, + ItemStack output2) { + return ReflectionHelper.getInstance( + ReflectionHelper.getConstructor( + "factorization.oreprocessing.TileEntitySlagFurnace$SmeltingResult", + ItemStack.class, + float.class, + ItemStack.class, + float.class, + ItemStack.class), input, chance1, output1, @@ -41,11 +60,18 @@ public class FactorizationHelper { output2); } - public static Object getCrystallizerRecipe(ItemStack input, ItemStack output, ItemStack solution, float output_count) { - return ReflectionHelper.getInstance(ReflectionHelper.getConstructor("factorization.oreprocessing.TileEntityCrystallizer$CrystalRecipe", ItemStack.class, ItemStack.class, float.class, ItemStack.class), + public static Object getCrystallizerRecipe(ItemStack input, ItemStack output, ItemStack solution, + float output_count) { + return ReflectionHelper.getInstance( + ReflectionHelper.getConstructor( + "factorization.oreprocessing.TileEntityCrystallizer$CrystalRecipe", + ItemStack.class, + ItemStack.class, + float.class, + ItemStack.class), input, output, output_count, solution); } -} \ No newline at end of file +} diff --git a/src/main/java/modtweaker2/mods/factorization/commands/FactorizationLogger.java b/src/main/java/modtweaker2/mods/factorization/commands/FactorizationLogger.java index ba06923..5413ebf 100644 --- a/src/main/java/modtweaker2/mods/factorization/commands/FactorizationLogger.java +++ b/src/main/java/modtweaker2/mods/factorization/commands/FactorizationLogger.java @@ -12,62 +12,83 @@ import modtweaker2.helpers.LogHelper; import modtweaker2.helpers.ReflectionHelper; import modtweaker2.helpers.StringHelper; import modtweaker2.mods.factorization.FactorizationHelper; + import net.minecraft.item.ItemStack; public class FactorizationLogger implements ICommandFunction { private static final List validArguments = new LinkedList(); - + static { validArguments.add("Crystallizer"); validArguments.add("Lacerator"); validArguments.add("SlagFurnace"); } - + @Override public void execute(String[] arguments, IPlayer player) { List args = StringHelper.toLowerCase(Arrays.asList(arguments)); - - if(!validArguments.containsAll(args)) { - if(player != null) { - player.sendChat(MineTweakerImplementationAPI.platform.getMessage("Invalid arguments for command. Valid arguments: " + StringHelper.join(validArguments, ", "))); + + if (!validArguments.containsAll(args)) { + if (player != null) { + player.sendChat( + MineTweakerImplementationAPI.platform.getMessage( + "Invalid arguments for command. Valid arguments: " + + StringHelper.join(validArguments, ", "))); } } else { - if(args.isEmpty() || args.contains("Crystallizer")) { - for(Object recipe : FactorizationHelper.crystallizer) { - MineTweakerAPI.logCommand(String.format("mods.factorization.Crystallizer.addRecipe(%s, %s, %s, %s);", - LogHelper.getStackDescription(ReflectionHelper.getObject(recipe, "input")), - LogHelper.getStackDescription(ReflectionHelper.getObject(recipe, "output")), - LogHelper.getStackDescription(ReflectionHelper.getObject(recipe, "solution")), - ReflectionHelper.getObject(recipe, "output_count"))); + if (args.isEmpty() || args.contains("Crystallizer")) { + for (Object recipe : FactorizationHelper.crystallizer) { + MineTweakerAPI.logCommand( + String.format( + "mods.factorization.Crystallizer.addRecipe(%s, %s, %s, %s);", + LogHelper.getStackDescription( + ReflectionHelper.getObject(recipe, "input")), + LogHelper.getStackDescription( + ReflectionHelper.getObject(recipe, "output")), + LogHelper.getStackDescription( + ReflectionHelper.getObject(recipe, "solution")), + ReflectionHelper.getObject(recipe, "output_count"))); } } - - if(args.isEmpty() || args.contains("Lacerator")) { - for(Object recipe : FactorizationHelper.lacerator) { - MineTweakerAPI.logCommand(String.format("mods.factorization.Lacerator.addRecipe(%s, %s, %s);", - ReflectionHelper.getObject(recipe, "oreName") != null ? - LogHelper.getStackDescription(ReflectionHelper.getObject(recipe, "oreName")) : - LogHelper.getStackDescription(ReflectionHelper.getObject(recipe, "itemstack")), - LogHelper.getStackDescription(ReflectionHelper.getObject(recipe, "output")), - ReflectionHelper.getObject(recipe, "probability"))); + + if (args.isEmpty() || args.contains("Lacerator")) { + for (Object recipe : FactorizationHelper.lacerator) { + MineTweakerAPI.logCommand( + String.format( + "mods.factorization.Lacerator.addRecipe(%s, %s, %s);", + ReflectionHelper.getObject(recipe, "oreName") != null + ? LogHelper.getStackDescription( + ReflectionHelper.getObject(recipe, "oreName")) + : LogHelper.getStackDescription( + ReflectionHelper.getObject(recipe, "itemstack")), + LogHelper.getStackDescription( + ReflectionHelper.getObject(recipe, "output")), + ReflectionHelper.getObject(recipe, "probability"))); } } - - if(args.isEmpty() || args.contains("SlagFurnace")) { - for(Object recipe : FactorizationHelper.slag) { - MineTweakerAPI.logCommand(String.format("mods.factorization.SlagFurnace.addRecipe(%s, %s, %s, %s, %s);", - LogHelper.getStackDescription(ReflectionHelper.getObject(recipe, "input")), - LogHelper.getStackDescription(ReflectionHelper.getObject(recipe, "output2")), - ReflectionHelper.getObject(recipe, "prob2"), - LogHelper.getStackDescription(ReflectionHelper.getObject(recipe, "output1")), - ReflectionHelper.getObject(recipe, "prob1"))); + + if (args.isEmpty() || args.contains("SlagFurnace")) { + for (Object recipe : FactorizationHelper.slag) { + MineTweakerAPI.logCommand( + String.format( + "mods.factorization.SlagFurnace.addRecipe(%s, %s, %s, %s, %s);", + LogHelper.getStackDescription( + ReflectionHelper.getObject(recipe, "input")), + LogHelper.getStackDescription( + ReflectionHelper.getObject(recipe, "output2")), + ReflectionHelper.getObject(recipe, "prob2"), + LogHelper.getStackDescription( + ReflectionHelper.getObject(recipe, "output1")), + ReflectionHelper.getObject(recipe, "prob1"))); } } - + if (player != null) { - player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir")); + player.sendChat( + MineTweakerImplementationAPI.platform + .getMessage("List generated; see minetweaker.log in your minecraft dir")); } } } -} \ No newline at end of file +} diff --git a/src/main/java/modtweaker2/mods/factorization/handlers/Crystallizer.java b/src/main/java/modtweaker2/mods/factorization/handlers/Crystallizer.java index 39e8166..6e00348 100644 --- a/src/main/java/modtweaker2/mods/factorization/handlers/Crystallizer.java +++ b/src/main/java/modtweaker2/mods/factorization/handlers/Crystallizer.java @@ -15,25 +15,28 @@ import modtweaker2.helpers.ReflectionHelper; import modtweaker2.mods.factorization.FactorizationHelper; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; + import net.minecraft.item.ItemStack; + import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; - @ZenClass("mods.factorization.Crystallizer") public class Crystallizer { - + public static final String name = "Factorization Crystallizer"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @ZenMethod public static void addRecipe(IItemStack input, IItemStack output, IItemStack solution, double output_count) { - Object recipe = FactorizationHelper.getCrystallizerRecipe(toStack(input), toStack(output), toStack(solution), (float) output_count); + Object recipe = FactorizationHelper + .getCrystallizerRecipe(toStack(input), toStack(output), toStack(solution), (float) output_count); MineTweakerAPI.apply(new Add(recipe)); } private static class Add extends BaseListAddition { + @SuppressWarnings("unchecked") public Add(Object recipe) { super(Crystallizer.name, FactorizationHelper.crystallizer); @@ -42,7 +45,7 @@ public class Crystallizer { @Override public String getRecipeInfo(Object recipe) { - return LogHelper.getStackDescription((ItemStack)ReflectionHelper.getObject(recipe, "output")); + return LogHelper.getStackDescription((ItemStack) ReflectionHelper.getObject(recipe, "output")); } } @@ -51,7 +54,7 @@ public class Crystallizer { @ZenMethod public static void removeRecipe(IIngredient output) { List recipes = new LinkedList(); - + for (Object r : FactorizationHelper.crystallizer) { if (r != null) { ItemStack out = (ItemStack) ReflectionHelper.getObject(r, "output");; @@ -60,15 +63,17 @@ public class Crystallizer { } } } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new Remove(recipes)); } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Crystallizer.name, output.toString())); + LogHelper.logWarning( + String.format("No %s Recipe found for %s. Command ignored!", Crystallizer.name, output.toString())); } } private static class Remove extends BaseListRemoval { + @SuppressWarnings("unchecked") public Remove(List recipes) { super(Crystallizer.name, FactorizationHelper.crystallizer, recipes); @@ -76,7 +81,7 @@ public class Crystallizer { @Override public String getRecipeInfo(Object recipe) { - return LogHelper.getStackDescription((ItemStack)ReflectionHelper.getObject(recipe, "output")); + return LogHelper.getStackDescription((ItemStack) ReflectionHelper.getObject(recipe, "output")); } } } diff --git a/src/main/java/modtweaker2/mods/factorization/handlers/Lacerator.java b/src/main/java/modtweaker2/mods/factorization/handlers/Lacerator.java index c19e906..166d790 100644 --- a/src/main/java/modtweaker2/mods/factorization/handlers/Lacerator.java +++ b/src/main/java/modtweaker2/mods/factorization/handlers/Lacerator.java @@ -16,17 +16,19 @@ import modtweaker2.helpers.ReflectionHelper; import modtweaker2.mods.factorization.FactorizationHelper; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; + import net.minecraft.item.ItemStack; + import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; @ZenClass("mods.factorization.Lacerator") public class Lacerator { - + public static final String name = "Factorization Lacerator"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @ZenMethod public static void addRecipe(IIngredient input, IItemStack output, double probability) { Object recipe = FactorizationHelper.getLaceratorRecipe(toObject(input), toStack(output), (float) probability); @@ -34,6 +36,7 @@ public class Lacerator { } private static class Add extends BaseListAddition { + @SuppressWarnings("unchecked") public Add(Object recipe) { super(Lacerator.name, FactorizationHelper.lacerator); @@ -52,22 +55,24 @@ public class Lacerator { public static void removeRecipe(IIngredient output) { List recipes = new LinkedList(); for (Object r : FactorizationHelper.lacerator) { - if(r != null) { + if (r != null) { ItemStack out = (ItemStack) ReflectionHelper.getObject(r, "output"); if (output != null && matches(output, toIItemStack(out))) { recipes.add(r); } } } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new Remove(recipes)); } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored", Lacerator.name, output.toString())); + LogHelper.logWarning( + String.format("No %s Recipe found for %s. Command ignored", Lacerator.name, output.toString())); } } private static class Remove extends BaseListRemoval { + @SuppressWarnings("unchecked") public Remove(List recipes) { super(Lacerator.name, FactorizationHelper.lacerator, recipes); diff --git a/src/main/java/modtweaker2/mods/factorization/handlers/SlagFurnace.java b/src/main/java/modtweaker2/mods/factorization/handlers/SlagFurnace.java index 9675b69..b7cac00 100644 --- a/src/main/java/modtweaker2/mods/factorization/handlers/SlagFurnace.java +++ b/src/main/java/modtweaker2/mods/factorization/handlers/SlagFurnace.java @@ -15,68 +15,78 @@ import modtweaker2.helpers.ReflectionHelper; import modtweaker2.mods.factorization.FactorizationHelper; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; + import net.minecraft.item.ItemStack; + import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; @ZenClass("mods.factorization.SlagFurnace") public class SlagFurnace { - + public static final String name = "Factorization Slag Furnace"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - @ZenMethod - public static void addRecipe(IItemStack input, IItemStack output1, double chance1, IItemStack output2, double chance2) { - Object recipe = FactorizationHelper.getSlagFurnaceRecipe(toStack(input), (float) chance1, toStack(output1), (float) chance2, toStack(output2)); - MineTweakerAPI.apply(new Add(toStack(input), recipe)); - } - private static class Add extends BaseListAddition { - @SuppressWarnings("unchecked") - public Add(ItemStack input, Object recipe) { - super(SlagFurnace.name, FactorizationHelper.slag); - recipes.add(recipe); - } + @ZenMethod + public static void addRecipe(IItemStack input, IItemStack output1, double chance1, IItemStack output2, + double chance2) { + Object recipe = FactorizationHelper.getSlagFurnaceRecipe( + toStack(input), + (float) chance1, + toStack(output1), + (float) chance2, + toStack(output2)); + MineTweakerAPI.apply(new Add(toStack(input), recipe)); + } - @Override - public String getRecipeInfo(Object recipe) { - return LogHelper.getStackDescription((ItemStack) ReflectionHelper.getObject(recipe, "input")); - } - } + private static class Add extends BaseListAddition { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - @ZenMethod - public static void removeRecipe(IIngredient input) { - List recipes = new LinkedList(); - - for(Object r : FactorizationHelper.slag) { - if(r != null) { - ItemStack in = (ItemStack) ReflectionHelper.getObject(r, "input"); - - if(matches(input, toIItemStack(in))) { - recipes.add(r); - } - } - } - - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new Remove(recipes)); - } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", SlagFurnace.name, input)); - } - } - - private static class Remove extends BaseListRemoval { - @SuppressWarnings("unchecked") - public Remove(List recipes) { - super(SlagFurnace.name, FactorizationHelper.slag, recipes); - } + @SuppressWarnings("unchecked") + public Add(ItemStack input, Object recipe) { + super(SlagFurnace.name, FactorizationHelper.slag); + recipes.add(recipe); + } @Override public String getRecipeInfo(Object recipe) { return LogHelper.getStackDescription((ItemStack) ReflectionHelper.getObject(recipe, "input")); } - } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + @ZenMethod + public static void removeRecipe(IIngredient input) { + List recipes = new LinkedList(); + + for (Object r : FactorizationHelper.slag) { + if (r != null) { + ItemStack in = (ItemStack) ReflectionHelper.getObject(r, "input"); + + if (matches(input, toIItemStack(in))) { + recipes.add(r); + } + } + } + + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new Remove(recipes)); + } else { + LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", SlagFurnace.name, input)); + } + } + + private static class Remove extends BaseListRemoval { + + @SuppressWarnings("unchecked") + public Remove(List recipes) { + super(SlagFurnace.name, FactorizationHelper.slag, recipes); + } + + @Override + public String getRecipeInfo(Object recipe) { + return LogHelper.getStackDescription((ItemStack) ReflectionHelper.getObject(recipe, "input")); + } + } } diff --git a/src/main/java/modtweaker2/mods/forestry/Forestry.java b/src/main/java/modtweaker2/mods/forestry/Forestry.java index 6ff297b..c6ce35e 100644 --- a/src/main/java/modtweaker2/mods/forestry/Forestry.java +++ b/src/main/java/modtweaker2/mods/forestry/Forestry.java @@ -10,13 +10,14 @@ import modtweaker2.mods.forestry.handlers.Still; import modtweaker2.mods.forestry.handlers.ThermionicFabricator; public class Forestry { - public Forestry() { - MineTweakerAPI.registerClass(Fermenter.class); - MineTweakerAPI.registerClass(Still.class); - MineTweakerAPI.registerClass(Moistener.class); - MineTweakerAPI.registerClass(Carpenter.class); - MineTweakerAPI.registerClass(Squeezer.class); - MineTweakerAPI.registerClass(Centrifuge.class); - MineTweakerAPI.registerClass(ThermionicFabricator.class); - } + + public Forestry() { + MineTweakerAPI.registerClass(Fermenter.class); + MineTweakerAPI.registerClass(Still.class); + MineTweakerAPI.registerClass(Moistener.class); + MineTweakerAPI.registerClass(Carpenter.class); + MineTweakerAPI.registerClass(Squeezer.class); + MineTweakerAPI.registerClass(Centrifuge.class); + MineTweakerAPI.registerClass(ThermionicFabricator.class); + } } diff --git a/src/main/java/modtweaker2/mods/forestry/ForestryListAddition.java b/src/main/java/modtweaker2/mods/forestry/ForestryListAddition.java index b16e17c..25a26c9 100644 --- a/src/main/java/modtweaker2/mods/forestry/ForestryListAddition.java +++ b/src/main/java/modtweaker2/mods/forestry/ForestryListAddition.java @@ -1,55 +1,57 @@ -package modtweaker2.mods.forestry; - -import java.util.ArrayList; -import java.util.List; - -import forestry.api.recipes.ICraftingProvider; -import forestry.api.recipes.IForestryRecipe; - -import modtweaker2.helpers.LogHelper; -import modtweaker2.utils.BaseListAddition; - -public abstract class ForestryListAddition> extends BaseListAddition { - private final C craftingProvider; - - protected ForestryListAddition(String name, C craftingProvider) { - super(name, new ArrayList(craftingProvider.recipes())); - this.craftingProvider = craftingProvider; - } - - protected ForestryListAddition(String name, C craftingProvider, List recipes) { - super(name, new ArrayList(craftingProvider.recipes()), recipes); - this.craftingProvider = craftingProvider; - } - - @Override - protected abstract String getRecipeInfo(T recipe); - - @Override - public final void apply() { - for (T recipe : recipes) { - if (recipe != null) { - if (craftingProvider.addRecipe(recipe)) { - successful.add(recipe); - } else { - LogHelper.logError(String.format("Error adding %s Recipe for %s", name, getRecipeInfo(recipe))); - } - } else { - LogHelper.logError(String.format("Error removing %s Recipe: null object", name)); - } - } - } - - @Override - public final void undo() { - for (T recipe : successful) { - if (recipe != null) { - if (!craftingProvider.removeRecipe(recipe)) { - LogHelper.logError(String.format("Error removing %s Recipe for %s", name, this.getRecipeInfo(recipe))); - } - } else { - LogHelper.logError(String.format("Error removing %s Recipe: null object", name)); - } - } - } -} +package modtweaker2.mods.forestry; + +import java.util.ArrayList; +import java.util.List; + +import modtweaker2.helpers.LogHelper; +import modtweaker2.utils.BaseListAddition; +import forestry.api.recipes.ICraftingProvider; +import forestry.api.recipes.IForestryRecipe; + +public abstract class ForestryListAddition> + extends BaseListAddition { + + private final C craftingProvider; + + protected ForestryListAddition(String name, C craftingProvider) { + super(name, new ArrayList(craftingProvider.recipes())); + this.craftingProvider = craftingProvider; + } + + protected ForestryListAddition(String name, C craftingProvider, List recipes) { + super(name, new ArrayList(craftingProvider.recipes()), recipes); + this.craftingProvider = craftingProvider; + } + + @Override + protected abstract String getRecipeInfo(T recipe); + + @Override + public final void apply() { + for (T recipe : recipes) { + if (recipe != null) { + if (craftingProvider.addRecipe(recipe)) { + successful.add(recipe); + } else { + LogHelper.logError(String.format("Error adding %s Recipe for %s", name, getRecipeInfo(recipe))); + } + } else { + LogHelper.logError(String.format("Error removing %s Recipe: null object", name)); + } + } + } + + @Override + public final void undo() { + for (T recipe : successful) { + if (recipe != null) { + if (!craftingProvider.removeRecipe(recipe)) { + LogHelper.logError( + String.format("Error removing %s Recipe for %s", name, this.getRecipeInfo(recipe))); + } + } else { + LogHelper.logError(String.format("Error removing %s Recipe: null object", name)); + } + } + } +} diff --git a/src/main/java/modtweaker2/mods/forestry/ForestryListRemoval.java b/src/main/java/modtweaker2/mods/forestry/ForestryListRemoval.java index 5681b92..9794ff2 100644 --- a/src/main/java/modtweaker2/mods/forestry/ForestryListRemoval.java +++ b/src/main/java/modtweaker2/mods/forestry/ForestryListRemoval.java @@ -1,50 +1,51 @@ -package modtweaker2.mods.forestry; - -import java.util.ArrayList; -import java.util.List; - -import forestry.api.recipes.ICraftingProvider; -import forestry.api.recipes.IForestryRecipe; - -import modtweaker2.helpers.LogHelper; -import modtweaker2.utils.BaseListRemoval; - -public abstract class ForestryListRemoval> extends BaseListRemoval { - private final C craftingProvider; - - public ForestryListRemoval(String name, C craftingProvider, List recipes) { - super(name, new ArrayList(craftingProvider.recipes()), recipes); - this.craftingProvider = craftingProvider; - } - - @Override - protected abstract String getRecipeInfo(T recipe); - - @Override - public final void apply() { - for (T recipe : recipes) { - if (recipe != null) { - if (craftingProvider.removeRecipe(recipe)) { - successful.add(recipe); - } else { - LogHelper.logError(String.format("Error removing %s Recipe for %s", name, getRecipeInfo(recipe))); - } - } else { - LogHelper.logError(String.format("Error removing %s Recipe: null object", name)); - } - } - } - - @Override - public final void undo() { - for (T recipe : successful) { - if (recipe != null) { - if (!craftingProvider.addRecipe(recipe)) { - LogHelper.logError(String.format("Error restoring %s Recipe for %s", name, getRecipeInfo(recipe))); - } - } else { - LogHelper.logError(String.format("Error restoring %s Recipe: null object", name)); - } - } - } -} +package modtweaker2.mods.forestry; + +import java.util.ArrayList; +import java.util.List; + +import modtweaker2.helpers.LogHelper; +import modtweaker2.utils.BaseListRemoval; +import forestry.api.recipes.ICraftingProvider; +import forestry.api.recipes.IForestryRecipe; + +public abstract class ForestryListRemoval> + extends BaseListRemoval { + + private final C craftingProvider; + + public ForestryListRemoval(String name, C craftingProvider, List recipes) { + super(name, new ArrayList(craftingProvider.recipes()), recipes); + this.craftingProvider = craftingProvider; + } + + @Override + protected abstract String getRecipeInfo(T recipe); + + @Override + public final void apply() { + for (T recipe : recipes) { + if (recipe != null) { + if (craftingProvider.removeRecipe(recipe)) { + successful.add(recipe); + } else { + LogHelper.logError(String.format("Error removing %s Recipe for %s", name, getRecipeInfo(recipe))); + } + } else { + LogHelper.logError(String.format("Error removing %s Recipe: null object", name)); + } + } + } + + @Override + public final void undo() { + for (T recipe : successful) { + if (recipe != null) { + if (!craftingProvider.addRecipe(recipe)) { + LogHelper.logError(String.format("Error restoring %s Recipe for %s", name, getRecipeInfo(recipe))); + } + } else { + LogHelper.logError(String.format("Error restoring %s Recipe: null object", name)); + } + } + } +} diff --git a/src/main/java/modtweaker2/mods/forestry/handlers/Carpenter.java b/src/main/java/modtweaker2/mods/forestry/handlers/Carpenter.java index ad42de8..71f92c8 100644 --- a/src/main/java/modtweaker2/mods/forestry/handlers/Carpenter.java +++ b/src/main/java/modtweaker2/mods/forestry/handlers/Carpenter.java @@ -3,9 +3,8 @@ package modtweaker2.mods.forestry.handlers; import static modtweaker2.helpers.InputHelper.toFluid; import static modtweaker2.helpers.InputHelper.toIItemStack; import static modtweaker2.helpers.InputHelper.toILiquidStack; -import static modtweaker2.helpers.InputHelper.toStack; -import static modtweaker2.helpers.InputHelper.toStacks; import static modtweaker2.helpers.InputHelper.toShapedObjects; +import static modtweaker2.helpers.InputHelper.toStack; import static modtweaker2.helpers.StackHelper.matches; import java.util.LinkedList; @@ -19,13 +18,13 @@ import modtweaker2.helpers.LogHelper; import modtweaker2.mods.forestry.ForestryListAddition; import modtweaker2.mods.forestry.ForestryListRemoval; import modtweaker2.mods.forestry.recipes.CarpenterRecipe; +import modtweaker2.mods.forestry.recipes.DescriptiveRecipe; + import net.minecraft.item.ItemStack; -import modtweaker2.mods.forestry.recipes.DescriptiveRecipe; import stanhebben.zenscript.annotations.Optional; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; - import forestry.api.recipes.ICarpenterManager; import forestry.api.recipes.ICarpenterRecipe; import forestry.api.recipes.IDescriptiveRecipe; @@ -33,114 +32,134 @@ import forestry.api.recipes.RecipeManagers; @ZenClass("mods.forestry.Carpenter") public class Carpenter { - - public static final String name = "Forestry Carpenter"; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + public static final String name = "Forestry Carpenter"; - /** - * Adds a shaped recipe for the Carpenter - * - * @param output recipe output - * @param ingredients recipe ingredients - * @param packagingTime time per crafting operation - * @optionalParam box recipes casting item (optional) - */ - @ZenMethod - public static void addRecipe(IItemStack output, IIngredient[][] ingredients, int packagingTime, @Optional IItemStack box) { - IDescriptiveRecipe craftRecipe = new DescriptiveRecipe(3, 3, toShapedObjects(ingredients), toStack(output), false); - MineTweakerAPI.apply(new Add(new CarpenterRecipe(packagingTime, null, toStack(box), craftRecipe))); - } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /** - * Adds a shaped recipe for the Carpenter - * - * @param output recipe output - * @param ingredients recipe ingredients - * @param fluidInput recipe fluid amount - * @param packagingTime time per crafting operation - * @optionalParam box recipes casting item (optional) - */ - @ZenMethod - public static void addRecipe(IItemStack output, IIngredient[][] ingredients, ILiquidStack fluidInput, int packagingTime, @Optional IItemStack box) { - IDescriptiveRecipe craftRecipe = new DescriptiveRecipe(3, 3, toShapedObjects(ingredients), toStack(output), false); - MineTweakerAPI.apply(new Add(new CarpenterRecipe(packagingTime, toFluid(fluidInput), toStack(box), craftRecipe))); - } + /** + * Adds a shaped recipe for the Carpenter + * + * @param output recipe output + * @param ingredients recipe ingredients + * @param packagingTime time per crafting operation + * @optionalParam box recipes casting item (optional) + */ + @ZenMethod + public static void addRecipe(IItemStack output, IIngredient[][] ingredients, int packagingTime, + @Optional IItemStack box) { + IDescriptiveRecipe craftRecipe = new DescriptiveRecipe( + 3, + 3, + toShapedObjects(ingredients), + toStack(output), + false); + MineTweakerAPI.apply(new Add(new CarpenterRecipe(packagingTime, null, toStack(box), craftRecipe))); + } - @Deprecated - @ZenMethod - public static void addRecipe(int packagingTime, ILiquidStack fluidInput, IItemStack[] ingredients, IItemStack box, IItemStack output) { - IDescriptiveRecipe craftRecipe = new DescriptiveRecipe(3, 3, toShapedObjects(transform(ingredients, 3)), toStack(output), false); - MineTweakerAPI.apply(new Add(new CarpenterRecipe(packagingTime, toFluid(fluidInput), toStack(box), craftRecipe))); - } + /** + * Adds a shaped recipe for the Carpenter + * + * @param output recipe output + * @param ingredients recipe ingredients + * @param fluidInput recipe fluid amount + * @param packagingTime time per crafting operation + * @optionalParam box recipes casting item (optional) + */ + @ZenMethod + public static void addRecipe(IItemStack output, IIngredient[][] ingredients, ILiquidStack fluidInput, + int packagingTime, @Optional IItemStack box) { + IDescriptiveRecipe craftRecipe = new DescriptiveRecipe( + 3, + 3, + toShapedObjects(ingredients), + toStack(output), + false); + MineTweakerAPI + .apply(new Add(new CarpenterRecipe(packagingTime, toFluid(fluidInput), toStack(box), craftRecipe))); + } - private static IItemStack[][] transform(IItemStack[] arr, int N) { - int M = (arr.length + N - 1) / N; - IItemStack[][] mat = new IItemStack[M][]; - int start = 0; - for (int r = 0; r < M; r++) { - int L = Math.min(N, arr.length - start); - mat[r] = java.util.Arrays.copyOfRange(arr, start, start + L); - start += L; - } - return mat; - } + @Deprecated + @ZenMethod + public static void addRecipe(int packagingTime, ILiquidStack fluidInput, IItemStack[] ingredients, IItemStack box, + IItemStack output) { + IDescriptiveRecipe craftRecipe = new DescriptiveRecipe( + 3, + 3, + toShapedObjects(transform(ingredients, 3)), + toStack(output), + false); + MineTweakerAPI + .apply(new Add(new CarpenterRecipe(packagingTime, toFluid(fluidInput), toStack(box), craftRecipe))); + } - private static class Add extends ForestryListAddition { + private static IItemStack[][] transform(IItemStack[] arr, int N) { + int M = (arr.length + N - 1) / N; + IItemStack[][] mat = new IItemStack[M][]; + int start = 0; + for (int r = 0; r < M; r++) { + int L = Math.min(N, arr.length - start); + mat[r] = java.util.Arrays.copyOfRange(arr, start, start + L); + start += L; + } + return mat; + } - public Add(ICarpenterRecipe recipe) { - super(Carpenter.name, RecipeManagers.carpenterManager); - recipes.add(recipe); - } - - @Override - protected String getRecipeInfo(ICarpenterRecipe recipe) { - return LogHelper.getStackDescription(recipe.getCraftingGridRecipe().getRecipeOutput()); - } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - /** - * Removes a recipe for the Carpenter - * - * @param output = item output - * @optionalParam liquid = liquid input - */ - @ZenMethod - public static void removeRecipe(IIngredient output, @Optional IIngredient liquid) { - List recipes = new LinkedList(); - - for(ICarpenterRecipe recipe : RecipeManagers.carpenterManager.recipes()) { - if (recipe != null) { - ItemStack recipeResult = recipe.getCraftingGridRecipe().getRecipeOutput(); - if (recipeResult != null && matches(output, toIItemStack(recipeResult))) { - if (liquid != null) { - if (matches(liquid, toILiquidStack(recipe.getFluidResource()))) - recipes.add(recipe); - } else { - recipes.add(recipe); - } - } - } - } - - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new Remove(recipes)); - } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Carpenter.name, output.toString())); - } - } - - private static class Remove extends ForestryListRemoval { - - public Remove(List recipes) { - super(Carpenter.name, RecipeManagers.carpenterManager, recipes); - } - - @Override - protected String getRecipeInfo(ICarpenterRecipe recipe) { - return LogHelper.getStackDescription(recipe.getCraftingGridRecipe().getRecipeOutput()); - } - } + private static class Add extends ForestryListAddition { + + public Add(ICarpenterRecipe recipe) { + super(Carpenter.name, RecipeManagers.carpenterManager); + recipes.add(recipe); + } + + @Override + protected String getRecipeInfo(ICarpenterRecipe recipe) { + return LogHelper.getStackDescription(recipe.getCraftingGridRecipe().getRecipeOutput()); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Removes a recipe for the Carpenter + * + * @param output = item output + * @optionalParam liquid = liquid input + */ + @ZenMethod + public static void removeRecipe(IIngredient output, @Optional IIngredient liquid) { + List recipes = new LinkedList(); + + for (ICarpenterRecipe recipe : RecipeManagers.carpenterManager.recipes()) { + if (recipe != null) { + ItemStack recipeResult = recipe.getCraftingGridRecipe().getRecipeOutput(); + if (recipeResult != null && matches(output, toIItemStack(recipeResult))) { + if (liquid != null) { + if (matches(liquid, toILiquidStack(recipe.getFluidResource()))) recipes.add(recipe); + } else { + recipes.add(recipe); + } + } + } + } + + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new Remove(recipes)); + } else { + LogHelper.logWarning( + String.format("No %s Recipe found for %s. Command ignored!", Carpenter.name, output.toString())); + } + } + + private static class Remove extends ForestryListRemoval { + + public Remove(List recipes) { + super(Carpenter.name, RecipeManagers.carpenterManager, recipes); + } + + @Override + protected String getRecipeInfo(ICarpenterRecipe recipe) { + return LogHelper.getStackDescription(recipe.getCraftingGridRecipe().getRecipeOutput()); + } + } } diff --git a/src/main/java/modtweaker2/mods/forestry/handlers/Centrifuge.java b/src/main/java/modtweaker2/mods/forestry/handlers/Centrifuge.java index dd3a3c3..08848e4 100644 --- a/src/main/java/modtweaker2/mods/forestry/handlers/Centrifuge.java +++ b/src/main/java/modtweaker2/mods/forestry/handlers/Centrifuge.java @@ -17,95 +17,97 @@ import modtweaker2.helpers.LogHelper; import modtweaker2.mods.forestry.ForestryListAddition; import modtweaker2.mods.forestry.ForestryListRemoval; import modtweaker2.mods.forestry.recipes.CentrifugeRecipe; + import net.minecraft.item.ItemStack; + import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; - import forestry.api.recipes.ICentrifugeManager; import forestry.api.recipes.ICentrifugeRecipe; import forestry.api.recipes.RecipeManagers; - @ZenClass("mods.forestry.Centrifuge") public class Centrifuge { - - public static final String name = "Forestry Centrifuge"; - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - /** - * Adds a recipe for the Centrifuge - * - * @param output List of items to produce with associated chance - * @param ingredient item input - * @param timePerItem time per item to process - */ - @ZenMethod - public static void addRecipe(WeightedItemStack[] output, IItemStack ingredient, int timePerItem) { - Map products = new HashMap(); - for (WeightedItemStack product : output) { - products.put(toStack(product.getStack()), product.getChance()); - } - MineTweakerAPI.apply(new Add(new CentrifugeRecipe(timePerItem, toStack(ingredient), products))); - } - - @ZenMethod - @Deprecated - public static void addRecipe(int timePerItem, IItemStack itemInput, IItemStack[] output, int[] chances) { - Map products = new HashMap(); - int i = 0; - for (IItemStack product : output) { - products.put(toStack(product), ((float) chances[i] / 100)); - i++; - } - MineTweakerAPI.apply(new Add(new CentrifugeRecipe(timePerItem, toStack(itemInput), products))); - } - - private static class Add extends ForestryListAddition { - public Add(ICentrifugeRecipe recipe) { - super(Centrifuge.name, RecipeManagers.centrifugeManager); - recipes.add(recipe); - } - - @Override - protected String getRecipeInfo(ICentrifugeRecipe recipe) { - return LogHelper.getStackDescription(recipe.getInput()); - } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - /** - * Removes a recipe for the Centrifuge - * - * @param input item input - */ - @ZenMethod - public static void removeRecipe(IIngredient input) { - List recipes = new LinkedList(); - - for(ICentrifugeRecipe recipe : RecipeManagers.centrifugeManager.recipes()) { - if(recipe != null && matches(input, toIItemStack(recipe.getInput()))) { - recipes.add(recipe); - } - } - - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new Remove(recipes)); - } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Centrifuge.name, input.toString())); - } - } - - private static class Remove extends ForestryListRemoval { - - public Remove(List recipes) { - super(Centrifuge.name, RecipeManagers.centrifugeManager, recipes); - } - - @Override - protected String getRecipeInfo(ICentrifugeRecipe recipe) { - return LogHelper.getStackDescription(recipe.getInput()); - } - } + + public static final String name = "Forestry Centrifuge"; + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Adds a recipe for the Centrifuge + * + * @param output List of items to produce with associated chance + * @param ingredient item input + * @param timePerItem time per item to process + */ + @ZenMethod + public static void addRecipe(WeightedItemStack[] output, IItemStack ingredient, int timePerItem) { + Map products = new HashMap(); + for (WeightedItemStack product : output) { + products.put(toStack(product.getStack()), product.getChance()); + } + MineTweakerAPI.apply(new Add(new CentrifugeRecipe(timePerItem, toStack(ingredient), products))); + } + + @ZenMethod + @Deprecated + public static void addRecipe(int timePerItem, IItemStack itemInput, IItemStack[] output, int[] chances) { + Map products = new HashMap(); + int i = 0; + for (IItemStack product : output) { + products.put(toStack(product), ((float) chances[i] / 100)); + i++; + } + MineTweakerAPI.apply(new Add(new CentrifugeRecipe(timePerItem, toStack(itemInput), products))); + } + + private static class Add extends ForestryListAddition { + + public Add(ICentrifugeRecipe recipe) { + super(Centrifuge.name, RecipeManagers.centrifugeManager); + recipes.add(recipe); + } + + @Override + protected String getRecipeInfo(ICentrifugeRecipe recipe) { + return LogHelper.getStackDescription(recipe.getInput()); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Removes a recipe for the Centrifuge + * + * @param input item input + */ + @ZenMethod + public static void removeRecipe(IIngredient input) { + List recipes = new LinkedList(); + + for (ICentrifugeRecipe recipe : RecipeManagers.centrifugeManager.recipes()) { + if (recipe != null && matches(input, toIItemStack(recipe.getInput()))) { + recipes.add(recipe); + } + } + + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new Remove(recipes)); + } else { + LogHelper.logWarning( + String.format("No %s Recipe found for %s. Command ignored!", Centrifuge.name, input.toString())); + } + } + + private static class Remove extends ForestryListRemoval { + + public Remove(List recipes) { + super(Centrifuge.name, RecipeManagers.centrifugeManager, recipes); + } + + @Override + protected String getRecipeInfo(ICentrifugeRecipe recipe) { + return LogHelper.getStackDescription(recipe.getInput()); + } + } } diff --git a/src/main/java/modtweaker2/mods/forestry/handlers/Fermenter.java b/src/main/java/modtweaker2/mods/forestry/handlers/Fermenter.java index b1d5ab4..0145eff 100644 --- a/src/main/java/modtweaker2/mods/forestry/handlers/Fermenter.java +++ b/src/main/java/modtweaker2/mods/forestry/handlers/Fermenter.java @@ -23,6 +23,7 @@ import modtweaker2.mods.forestry.ForestryListRemoval; import modtweaker2.mods.forestry.recipes.FermenterRecipe; import modtweaker2.utils.BaseMapAddition; import modtweaker2.utils.BaseMapRemoval; + import net.minecraft.item.ItemStack; import stanhebben.zenscript.annotations.ZenClass; @@ -36,141 +37,164 @@ import forestry.api.recipes.RecipeManagers; @ZenClass("mods.forestry.Fermenter") public class Fermenter { - public static final String name = "Forestry Fermenter"; - public static final String nameFuel = name + " (Fuel)"; - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - /** - * Adds a fermenter recipe. Amount of fluid output is calculated: fermentationValue * fluidOutputModifier - * Note: the actual consumption of fluid input depends on the fermentation fuel - * - * @param fluidOutput type of fluid produced - * @param resource organic item - * @param fluidInput type of fluid required in input - * @param fermentationValue amount of inputFluid on organic item requires - * @param fluidOutputModifier Output multiplier (this is usually a from the input fluid - */ - @ZenMethod - public static void addRecipe(ILiquidStack fluidOutput, IItemStack resource, ILiquidStack fluidInput, int fermentationValue, float fluidOutputModifier) { - MineTweakerAPI.apply(new Add(new FermenterRecipe(toStack(resource), fermentationValue, fluidOutputModifier, getFluid(fluidOutput), toFluid(fluidInput)))); - } - - @Deprecated - @ZenMethod - public static void addRecipe(IItemStack resource, ILiquidStack fluidInput, int fermentationValue, float fluidOutputModifier, ILiquidStack fluidOutput) { - MineTweakerAPI.apply(new Add(new FermenterRecipe(toStack(resource), fermentationValue, fluidOutputModifier, getFluid(fluidOutput), toFluid(fluidInput)))); - } + public static final String name = "Forestry Fermenter"; + public static final String nameFuel = name + " (Fuel)"; - private static class Add extends ForestryListAddition { - public Add(IFermenterRecipe recipe) { - super(Fermenter.name, RecipeManagers.fermenterManager); - recipes.add(recipe); - } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - @Override - public String getRecipeInfo(IFermenterRecipe recipe) { - return LogHelper.getStackDescription(recipe.getOutput()); - } - } + /** + * Adds a fermenter recipe. Amount of fluid output is calculated: fermentationValue * fluidOutputModifier Note: the + * actual consumption of fluid input depends on the fermentation fuel + * + * @param fluidOutput type of fluid produced + * @param resource organic item + * @param fluidInput type of fluid required in input + * @param fermentationValue amount of inputFluid on organic item requires + * @param fluidOutputModifier Output multiplier (this is usually a from the input fluid + */ + @ZenMethod + public static void addRecipe(ILiquidStack fluidOutput, IItemStack resource, ILiquidStack fluidInput, + int fermentationValue, float fluidOutputModifier) { + MineTweakerAPI.apply( + new Add( + new FermenterRecipe( + toStack(resource), + fermentationValue, + fluidOutputModifier, + getFluid(fluidOutput), + toFluid(fluidInput)))); + } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - @ZenMethod - public static void removeRecipe(IIngredient input) { - List recipes = new LinkedList(); - - for(IFermenterRecipe recipe : RecipeManagers.fermenterManager.recipes()) { - // check for input items - if(recipe != null && recipe.getResource() != null && matches(input, toIItemStack(recipe.getResource()))) { - recipes.add(recipe); - } - - // check for input liquids - if(recipe != null && recipe.getResource() != null && matches(input, toILiquidStack(recipe.getFluidResource()))) { - recipes.add(recipe); - } - } - - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new Remove(recipes)); - } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Fermenter.name, input.toString())); - } - } + @Deprecated + @ZenMethod + public static void addRecipe(IItemStack resource, ILiquidStack fluidInput, int fermentationValue, + float fluidOutputModifier, ILiquidStack fluidOutput) { + MineTweakerAPI.apply( + new Add( + new FermenterRecipe( + toStack(resource), + fermentationValue, + fluidOutputModifier, + getFluid(fluidOutput), + toFluid(fluidInput)))); + } - private static class Remove extends ForestryListRemoval { + private static class Add extends ForestryListAddition { - public Remove(List recipes) { - super(Fermenter.name, RecipeManagers.fermenterManager, recipes); - } + public Add(IFermenterRecipe recipe) { + super(Fermenter.name, RecipeManagers.fermenterManager); + recipes.add(recipe); + } - @Override - protected String getRecipeInfo(IFermenterRecipe recipe) { - return LogHelper.getStackDescription(recipe.getOutput()); - } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - /** - * Adds fermenter fuel. - * Note: the actual consumption of fluid input depends on the fermentation fuel - * - * @param item Item that is a valid fuel for the fermenter - * @param fermentPerCycle How much is fermented per work cycle, i.e. how much fluid of the input is consumed. - * @param burnDuration Amount of work cycles a single item of this fuel lasts before expiring. - */ - @ZenMethod - public static void addFuel(IItemStack item, int fermentPerCycle, int burnDuration) { - MineTweakerAPI.apply(new AddFuel(new FermenterFuel(toStack(item), fermentPerCycle, burnDuration))); - } - - private static class AddFuel extends BaseMapAddition { - public AddFuel(FermenterFuel fuelEntry) { - super(Fermenter.nameFuel, FuelManager.fermenterFuel); - recipes.put(fuelEntry.item, fuelEntry); - } - - @Override - public String getRecipeInfo(Entry fuelEntry) { - return LogHelper.getStackDescription(fuelEntry.getKey()); - } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - /** - * Removes a fermenter fuel. - * - * @param fermenterItem Item that is a valid fuel for the fermenter - */ - @ZenMethod - public static void removeFuel(IIngredient fermenterItem) { - Map fuelItems = new HashMap(); - - for(Entry fuelItem : FuelManager.fermenterFuel.entrySet()) { - if(fuelItem != null && matches(fermenterItem, toIItemStack(fuelItem.getValue().item))) { - fuelItems.put(fuelItem.getKey(), fuelItem.getValue()); - } - } - - if(!fuelItems.isEmpty()) { - MineTweakerAPI.apply(new RemoveFuel(fuelItems)); - } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Fermenter.name, fermenterItem.toString())); - } - } - - private static class RemoveFuel extends BaseMapRemoval { - public RemoveFuel(Map recipes) { - super(Fermenter.nameFuel, FuelManager.fermenterFuel, recipes); - } - - @Override - public String getRecipeInfo(Entry fuelEntry) { - return LogHelper.getStackDescription(fuelEntry.getKey()); - } - } + @Override + public String getRecipeInfo(IFermenterRecipe recipe) { + return LogHelper.getStackDescription(recipe.getOutput()); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + @ZenMethod + public static void removeRecipe(IIngredient input) { + List recipes = new LinkedList(); + + for (IFermenterRecipe recipe : RecipeManagers.fermenterManager.recipes()) { + // check for input items + if (recipe != null && recipe.getResource() != null && matches(input, toIItemStack(recipe.getResource()))) { + recipes.add(recipe); + } + + // check for input liquids + if (recipe != null && recipe.getResource() != null + && matches(input, toILiquidStack(recipe.getFluidResource()))) { + recipes.add(recipe); + } + } + + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new Remove(recipes)); + } else { + LogHelper.logWarning( + String.format("No %s Recipe found for %s. Command ignored!", Fermenter.name, input.toString())); + } + } + + private static class Remove extends ForestryListRemoval { + + public Remove(List recipes) { + super(Fermenter.name, RecipeManagers.fermenterManager, recipes); + } + + @Override + protected String getRecipeInfo(IFermenterRecipe recipe) { + return LogHelper.getStackDescription(recipe.getOutput()); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Adds fermenter fuel. Note: the actual consumption of fluid input depends on the fermentation fuel + * + * @param item Item that is a valid fuel for the fermenter + * @param fermentPerCycle How much is fermented per work cycle, i.e. how much fluid of the input is consumed. + * @param burnDuration Amount of work cycles a single item of this fuel lasts before expiring. + */ + @ZenMethod + public static void addFuel(IItemStack item, int fermentPerCycle, int burnDuration) { + MineTweakerAPI.apply(new AddFuel(new FermenterFuel(toStack(item), fermentPerCycle, burnDuration))); + } + + private static class AddFuel extends BaseMapAddition { + + public AddFuel(FermenterFuel fuelEntry) { + super(Fermenter.nameFuel, FuelManager.fermenterFuel); + recipes.put(fuelEntry.item, fuelEntry); + } + + @Override + public String getRecipeInfo(Entry fuelEntry) { + return LogHelper.getStackDescription(fuelEntry.getKey()); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Removes a fermenter fuel. + * + * @param fermenterItem Item that is a valid fuel for the fermenter + */ + @ZenMethod + public static void removeFuel(IIngredient fermenterItem) { + Map fuelItems = new HashMap(); + + for (Entry fuelItem : FuelManager.fermenterFuel.entrySet()) { + if (fuelItem != null && matches(fermenterItem, toIItemStack(fuelItem.getValue().item))) { + fuelItems.put(fuelItem.getKey(), fuelItem.getValue()); + } + } + + if (!fuelItems.isEmpty()) { + MineTweakerAPI.apply(new RemoveFuel(fuelItems)); + } else { + LogHelper.logWarning( + String.format( + "No %s Recipe found for %s. Command ignored!", + Fermenter.name, + fermenterItem.toString())); + } + } + + private static class RemoveFuel extends BaseMapRemoval { + + public RemoveFuel(Map recipes) { + super(Fermenter.nameFuel, FuelManager.fermenterFuel, recipes); + } + + @Override + public String getRecipeInfo(Entry fuelEntry) { + return LogHelper.getStackDescription(fuelEntry.getKey()); + } + } } - diff --git a/src/main/java/modtweaker2/mods/forestry/handlers/Moistener.java b/src/main/java/modtweaker2/mods/forestry/handlers/Moistener.java index 96fe102..22c708e 100644 --- a/src/main/java/modtweaker2/mods/forestry/handlers/Moistener.java +++ b/src/main/java/modtweaker2/mods/forestry/handlers/Moistener.java @@ -10,7 +10,6 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; -import net.minecraft.item.ItemStack; import minetweaker.MineTweakerAPI; import minetweaker.api.item.IIngredient; import minetweaker.api.item.IItemStack; @@ -20,6 +19,9 @@ import modtweaker2.mods.forestry.ForestryListRemoval; import modtweaker2.mods.forestry.recipes.MoistenerRecipe; import modtweaker2.utils.BaseMapAddition; import modtweaker2.utils.BaseMapRemoval; + +import net.minecraft.item.ItemStack; + import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; import forestry.api.fuels.FuelManager; @@ -31,133 +33,148 @@ import forestry.api.recipes.RecipeManagers; @ZenClass("mods.forestry.Moistener") public class Moistener { - public static final String name = "Forestry Moistener"; - public static final String nameFuel = name + " (Fuel)"; + public static final String name = "Forestry Moistener"; + public static final String nameFuel = name + " (Fuel)"; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /** - * Adds a recipe for the Moistener - * - * @param output recipe output - * @param resource organic item - * @param timePerItem time per item to process - */ - @ZenMethod - public static void addRecipe(IItemStack output, IItemStack resource, int timePerItem) { - MineTweakerAPI.apply(new Add(new MoistenerRecipe(toStack(resource), toStack(output), timePerItem))); - } + /** + * Adds a recipe for the Moistener + * + * @param output recipe output + * @param resource organic item + * @param timePerItem time per item to process + */ + @ZenMethod + public static void addRecipe(IItemStack output, IItemStack resource, int timePerItem) { + MineTweakerAPI.apply(new Add(new MoistenerRecipe(toStack(resource), toStack(output), timePerItem))); + } - @Deprecated - @ZenMethod - public static void addRecipe(int timePerItem, IItemStack resource, IItemStack product) { - MineTweakerAPI.apply(new Add(new MoistenerRecipe(toStack(resource), toStack(product), timePerItem))); - } + @Deprecated + @ZenMethod + public static void addRecipe(int timePerItem, IItemStack resource, IItemStack product) { + MineTweakerAPI.apply(new Add(new MoistenerRecipe(toStack(resource), toStack(product), timePerItem))); + } - private static class Add extends ForestryListAddition { - public Add(IMoistenerRecipe recipe) { - super(Moistener.name, RecipeManagers.moistenerManager); - recipes.add(recipe); - } + private static class Add extends ForestryListAddition { - @Override - public String getRecipeInfo(IMoistenerRecipe recipe) { - return LogHelper.getStackDescription(recipe.getProduct()); - } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + public Add(IMoistenerRecipe recipe) { + super(Moistener.name, RecipeManagers.moistenerManager); + recipes.add(recipe); + } - @ZenMethod - public static void removeRecipe(IIngredient output) { - List recipes = new LinkedList(); - for (IMoistenerRecipe recipe : RecipeManagers.moistenerManager.recipes()) { - if (recipe != null && recipe.getProduct() != null && matches(output, toIItemStack(recipe.getProduct()))) { - recipes.add(recipe); - } - } + @Override + public String getRecipeInfo(IMoistenerRecipe recipe) { + return LogHelper.getStackDescription(recipe.getProduct()); + } + } - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new Remove(recipes)); - } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Moistener.name, output.toString())); - } - } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - private static class Remove extends ForestryListRemoval { - public Remove(List recipes) { - super(Moistener.name, RecipeManagers.moistenerManager, recipes); - } + @ZenMethod + public static void removeRecipe(IIngredient output) { + List recipes = new LinkedList(); + for (IMoistenerRecipe recipe : RecipeManagers.moistenerManager.recipes()) { + if (recipe != null && recipe.getProduct() != null && matches(output, toIItemStack(recipe.getProduct()))) { + recipes.add(recipe); + } + } - @Override - public String getRecipeInfo(IMoistenerRecipe recipe) { - return LogHelper.getStackDescription(recipe.getProduct()); - } - } + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new Remove(recipes)); + } else { + LogHelper.logWarning( + String.format("No %s Recipe found for %s. Command ignored!", Moistener.name, output.toString())); + } + } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + private static class Remove extends ForestryListRemoval { - /** - * Adds moistener fuel. - * - * @param item The item to use - * @param product The item that leaves the moistener's working slot (i.e. mouldy wheat, decayed wheat, mulch) - * @param moistenerValue How much this item contributes to the final product of the moistener (i.e. mycelium) - * @param stage What stage this product represents. Resources with lower stage value will be consumed first. (First Stage is 0) - */ - @ZenMethod - public static void addFuel(IItemStack item, IItemStack product, int moistenerValue, int stage) { - if(stage >= 0) { - MineTweakerAPI.apply(new AddFuel(new MoistenerFuel(toStack(item), toStack(product), moistenerValue, stage))); - } else { - LogHelper.logWarning(String.format("No %s Recipe add for %s. Stage parameter must positive!", Moistener.name, item.toString())); - } - } + public Remove(List recipes) { + super(Moistener.name, RecipeManagers.moistenerManager, recipes); + } - private static class AddFuel extends BaseMapAddition { - public AddFuel(MoistenerFuel fuelEntry) { - super(Moistener.nameFuel, FuelManager.moistenerResource); - recipes.put(fuelEntry.item, fuelEntry); - } - - @Override - public String getRecipeInfo(Entry fuelEntry) { - return LogHelper.getStackDescription(fuelEntry.getKey()); - } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - /** - * Removes a moistener fuel. - * - * @param moistenerItem Item that is a valid fuel for the moistener - */ - @ZenMethod - public static void removeFuel(IIngredient moistenerItem) { - Map fuelItems = new HashMap(); - - for(Entry fuelItem : FuelManager.moistenerResource.entrySet()) { - if(fuelItem != null && matches(moistenerItem, toIItemStack(fuelItem.getValue().item))) { - fuelItems.put(fuelItem.getKey(), fuelItem.getValue()); - } - } - - if(!fuelItems.isEmpty()) { - MineTweakerAPI.apply(new RemoveFuel(fuelItems)); - } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Moistener.name, moistenerItem.toString())); - } - } - - private static class RemoveFuel extends BaseMapRemoval { - public RemoveFuel(Map recipes) { - super(Moistener.nameFuel, FuelManager.moistenerResource, recipes); - } - - @Override - public String getRecipeInfo(Entry fuelEntry) { - return LogHelper.getStackDescription(fuelEntry.getKey()); - } - } + @Override + public String getRecipeInfo(IMoistenerRecipe recipe) { + return LogHelper.getStackDescription(recipe.getProduct()); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Adds moistener fuel. + * + * @param item The item to use + * @param product The item that leaves the moistener's working slot (i.e. mouldy wheat, decayed wheat, mulch) + * @param moistenerValue How much this item contributes to the final product of the moistener (i.e. mycelium) + * @param stage What stage this product represents. Resources with lower stage value will be consumed + * first. (First Stage is 0) + */ + @ZenMethod + public static void addFuel(IItemStack item, IItemStack product, int moistenerValue, int stage) { + if (stage >= 0) { + MineTweakerAPI + .apply(new AddFuel(new MoistenerFuel(toStack(item), toStack(product), moistenerValue, stage))); + } else { + LogHelper.logWarning( + String.format( + "No %s Recipe add for %s. Stage parameter must positive!", + Moistener.name, + item.toString())); + } + } + + private static class AddFuel extends BaseMapAddition { + + public AddFuel(MoistenerFuel fuelEntry) { + super(Moistener.nameFuel, FuelManager.moistenerResource); + recipes.put(fuelEntry.item, fuelEntry); + } + + @Override + public String getRecipeInfo(Entry fuelEntry) { + return LogHelper.getStackDescription(fuelEntry.getKey()); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Removes a moistener fuel. + * + * @param moistenerItem Item that is a valid fuel for the moistener + */ + @ZenMethod + public static void removeFuel(IIngredient moistenerItem) { + Map fuelItems = new HashMap(); + + for (Entry fuelItem : FuelManager.moistenerResource.entrySet()) { + if (fuelItem != null && matches(moistenerItem, toIItemStack(fuelItem.getValue().item))) { + fuelItems.put(fuelItem.getKey(), fuelItem.getValue()); + } + } + + if (!fuelItems.isEmpty()) { + MineTweakerAPI.apply(new RemoveFuel(fuelItems)); + } else { + LogHelper.logWarning( + String.format( + "No %s Recipe found for %s. Command ignored!", + Moistener.name, + moistenerItem.toString())); + } + } + + private static class RemoveFuel extends BaseMapRemoval { + + public RemoveFuel(Map recipes) { + super(Moistener.nameFuel, FuelManager.moistenerResource, recipes); + } + + @Override + public String getRecipeInfo(Entry fuelEntry) { + return LogHelper.getStackDescription(fuelEntry.getKey()); + } + } } diff --git a/src/main/java/modtweaker2/mods/forestry/handlers/Squeezer.java b/src/main/java/modtweaker2/mods/forestry/handlers/Squeezer.java index ec0f628..7c80f10 100644 --- a/src/main/java/modtweaker2/mods/forestry/handlers/Squeezer.java +++ b/src/main/java/modtweaker2/mods/forestry/handlers/Squeezer.java @@ -1,8 +1,8 @@ package modtweaker2.mods.forestry.handlers; import static modtweaker2.helpers.InputHelper.toFluid; -import static modtweaker2.helpers.InputHelper.toILiquidStack; import static modtweaker2.helpers.InputHelper.toIItemStack; +import static modtweaker2.helpers.InputHelper.toILiquidStack; import static modtweaker2.helpers.InputHelper.toStack; import static modtweaker2.helpers.InputHelper.toStacks; import static modtweaker2.helpers.StackHelper.matches; @@ -10,10 +10,6 @@ import static modtweaker2.helpers.StackHelper.matches; import java.util.LinkedList; import java.util.List; -import forestry.api.recipes.ISqueezerManager; -import forestry.api.recipes.ISqueezerRecipe; -import forestry.api.recipes.RecipeManagers; - import minetweaker.MineTweakerAPI; import minetweaker.api.item.IIngredient; import minetweaker.api.item.IItemStack; @@ -26,107 +22,131 @@ import modtweaker2.mods.forestry.recipes.SqueezerRecipe; import stanhebben.zenscript.annotations.Optional; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; +import forestry.api.recipes.ISqueezerManager; +import forestry.api.recipes.ISqueezerRecipe; +import forestry.api.recipes.RecipeManagers; @ZenClass("mods.forestry.Squeezer") public class Squeezer { - - public static final String name = "Forestry Squeezer"; - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - /** - * Adds a recipe without additional item output - * - * @param fluidOutput recipe fluid amount - * @param ingredients recipe ingredients - * @param timePerItem time per crafting operation - */ - @ZenMethod - public static void addRecipe(ILiquidStack fluidOutput, int timePerItem, IItemStack[] ingredients) { - MineTweakerAPI.apply(new Add(new SqueezerRecipe(timePerItem, toStacks(ingredients), toFluid(fluidOutput), null, 0))); - } - - /** - * Adds a recipe with additional item output - * - * @param fluidOutput recipe fluid amount - * @param itemOutput recipe output - * @param ingredients recipe ingredients - * @param timePerItem time per crafting operation - */ - @ZenMethod - public static void addRecipe(ILiquidStack fluidOutput, WeightedItemStack itemOutput, IItemStack[] ingredients, int timePerItem) { - MineTweakerAPI.apply(new Add(new SqueezerRecipe(timePerItem, toStacks(ingredients), toFluid(fluidOutput), toStack(itemOutput.getStack()), itemOutput.getChance()))); - } - - @ZenMethod - @Deprecated - public static void addRecipe(int timePerItem, IItemStack[] resources, ILiquidStack liquid, IItemStack remnants, int chance) { - MineTweakerAPI.apply(new Add(new SqueezerRecipe(timePerItem, toStacks(resources), toFluid(liquid), toStack(remnants), chance))); - } - - private static class Add extends ForestryListAddition { - public Add(ISqueezerRecipe recipe) { - super(Squeezer.name, RecipeManagers.squeezerManager); - recipes.add(recipe); - } - - @Override - public String getRecipeInfo(ISqueezerRecipe recipe) { - return LogHelper.getStackDescription(recipe.getFluidOutput()); - } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - /** - * Removes a recipe for the Centrifuge - * - * @param liquid liquid output - * @param ingredients list of ingredients - */ - @ZenMethod - public static void removeRecipe(IIngredient liquid, @Optional IIngredient[] ingredients) { - List recipes = new LinkedList(); - - for (ISqueezerRecipe r : RecipeManagers.squeezerManager.recipes()) { - if (r != null && r.getFluidOutput() != null && matches(liquid, toILiquidStack(r.getFluidOutput()))) { - // optional check for ingredients - if (ingredients != null) { - boolean matched = false; - for (int i = 0; i < ingredients.length; i++) { - if ( matches(ingredients[i], toIItemStack(r.getResources()[i])) ) - matched = true; - else { - matched = false; - // if one ingredients doesn't match abort all further checks - break; - } - } - // if some ingredient doesn't match, the last one is false - if (matched) - recipes.add(r); - } else { - recipes.add(r); - } - } - } - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new Remove(recipes)); - } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Squeezer.name, LogHelper.getStackDescription(liquid))); - } - } + public static final String name = "Forestry Squeezer"; - private static class Remove extends ForestryListRemoval { - public Remove(List recipes) { - super(Squeezer.name, RecipeManagers.squeezerManager, recipes); - } - - @Override - public String getRecipeInfo(ISqueezerRecipe recipe) { - return LogHelper.getStackDescription(recipe.getFluidOutput()); - } - } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Adds a recipe without additional item output + * + * @param fluidOutput recipe fluid amount + * @param ingredients recipe ingredients + * @param timePerItem time per crafting operation + */ + @ZenMethod + public static void addRecipe(ILiquidStack fluidOutput, int timePerItem, IItemStack[] ingredients) { + MineTweakerAPI + .apply(new Add(new SqueezerRecipe(timePerItem, toStacks(ingredients), toFluid(fluidOutput), null, 0))); + } + + /** + * Adds a recipe with additional item output + * + * @param fluidOutput recipe fluid amount + * @param itemOutput recipe output + * @param ingredients recipe ingredients + * @param timePerItem time per crafting operation + */ + @ZenMethod + public static void addRecipe(ILiquidStack fluidOutput, WeightedItemStack itemOutput, IItemStack[] ingredients, + int timePerItem) { + MineTweakerAPI.apply( + new Add( + new SqueezerRecipe( + timePerItem, + toStacks(ingredients), + toFluid(fluidOutput), + toStack(itemOutput.getStack()), + itemOutput.getChance()))); + } + + @ZenMethod + @Deprecated + public static void addRecipe(int timePerItem, IItemStack[] resources, ILiquidStack liquid, IItemStack remnants, + int chance) { + MineTweakerAPI.apply( + new Add( + new SqueezerRecipe( + timePerItem, + toStacks(resources), + toFluid(liquid), + toStack(remnants), + chance))); + } + + private static class Add extends ForestryListAddition { + + public Add(ISqueezerRecipe recipe) { + super(Squeezer.name, RecipeManagers.squeezerManager); + recipes.add(recipe); + } + + @Override + public String getRecipeInfo(ISqueezerRecipe recipe) { + return LogHelper.getStackDescription(recipe.getFluidOutput()); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Removes a recipe for the Centrifuge + * + * @param liquid liquid output + * @param ingredients list of ingredients + */ + @ZenMethod + public static void removeRecipe(IIngredient liquid, @Optional IIngredient[] ingredients) { + List recipes = new LinkedList(); + + for (ISqueezerRecipe r : RecipeManagers.squeezerManager.recipes()) { + if (r != null && r.getFluidOutput() != null && matches(liquid, toILiquidStack(r.getFluidOutput()))) { + // optional check for ingredients + if (ingredients != null) { + boolean matched = false; + for (int i = 0; i < ingredients.length; i++) { + if (matches(ingredients[i], toIItemStack(r.getResources()[i]))) matched = true; + else { + matched = false; + // if one ingredients doesn't match abort all further checks + break; + } + } + // if some ingredient doesn't match, the last one is false + if (matched) recipes.add(r); + } else { + recipes.add(r); + } + } + } + + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new Remove(recipes)); + } else { + LogHelper.logWarning( + String.format( + "No %s Recipe found for %s. Command ignored!", + Squeezer.name, + LogHelper.getStackDescription(liquid))); + } + } + + private static class Remove extends ForestryListRemoval { + + public Remove(List recipes) { + super(Squeezer.name, RecipeManagers.squeezerManager, recipes); + } + + @Override + public String getRecipeInfo(ISqueezerRecipe recipe) { + return LogHelper.getStackDescription(recipe.getFluidOutput()); + } + } } diff --git a/src/main/java/modtweaker2/mods/forestry/handlers/Still.java b/src/main/java/modtweaker2/mods/forestry/handlers/Still.java index cd7b1b5..5681fc8 100644 --- a/src/main/java/modtweaker2/mods/forestry/handlers/Still.java +++ b/src/main/java/modtweaker2/mods/forestry/handlers/Still.java @@ -17,93 +17,96 @@ import modtweaker2.mods.forestry.recipes.StillRecipe; import stanhebben.zenscript.annotations.Optional; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; - import forestry.api.recipes.IStillManager; import forestry.api.recipes.IStillRecipe; import forestry.api.recipes.RecipeManagers; @ZenClass("mods.forestry.Still") public class Still { - - public static final String name = "Forestry Still"; - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - /** - * Adds a recipe for the Still - * - * @param fluidOutput recipe fluid amount - * @param fluidInput recipe fluid input - * @param timePerUnit time per crafting operation - */ - @ZenMethod - public static void addRecipe(ILiquidStack fluidOutput, ILiquidStack fluidInput, int timePerUnit) { - fluidOutput.amount(fluidOutput.getAmount() / 100); - fluidInput.amount(fluidInput.getAmount() / 100); - - MineTweakerAPI.apply(new Add(new StillRecipe(timePerUnit, toFluid(fluidInput), toFluid(fluidOutput)))); - } - - @Deprecated - @ZenMethod - public static void addRecipe(int timePerUnit, ILiquidStack input, ILiquidStack output) { - output.amount(output.getAmount() / 100); - input.amount(input.getAmount() / 100); - - MineTweakerAPI.apply(new Add(new StillRecipe(timePerUnit, toFluid(input), toFluid(output)))); - } - - private static class Add extends ForestryListAddition { - public Add(IStillRecipe recipe) { - super("Forestry Still", RecipeManagers.stillManager); - recipes.add(recipe); - } - - @Override - public String getRecipeInfo(IStillRecipe recipe) { - return LogHelper.getStackDescription(recipe.getOutput()); - } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - /** - * Removes a recipe for the Still - * - * @param output = liquid output - * @optionalParam liquid = liquid input - */ - @ZenMethod - public static void removeRecipe(IIngredient output, @Optional ILiquidStack input) { - List recipes = new LinkedList(); - - for (IStillRecipe r : RecipeManagers.stillManager.recipes()) { - if (r != null && r.getOutput() != null && matches(output, toILiquidStack(r.getOutput()))) { - if (input != null) { - if (matches(input, toILiquidStack(r.getInput()))) { - recipes.add(r); - } - } - else - recipes.add(r); - } - } - - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new Remove(recipes)); - } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Still.name, LogHelper.getStackDescription(output))); - } - } - - private static class Remove extends ForestryListRemoval { - public Remove(List recipes) { - super(Still.name, RecipeManagers.stillManager, recipes); - } - - @Override - public String getRecipeInfo(IStillRecipe recipe) { - return LogHelper.getStackDescription(recipe.getOutput()); - } - } + + public static final String name = "Forestry Still"; + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Adds a recipe for the Still + * + * @param fluidOutput recipe fluid amount + * @param fluidInput recipe fluid input + * @param timePerUnit time per crafting operation + */ + @ZenMethod + public static void addRecipe(ILiquidStack fluidOutput, ILiquidStack fluidInput, int timePerUnit) { + fluidOutput.amount(fluidOutput.getAmount() / 100); + fluidInput.amount(fluidInput.getAmount() / 100); + + MineTweakerAPI.apply(new Add(new StillRecipe(timePerUnit, toFluid(fluidInput), toFluid(fluidOutput)))); + } + + @Deprecated + @ZenMethod + public static void addRecipe(int timePerUnit, ILiquidStack input, ILiquidStack output) { + output.amount(output.getAmount() / 100); + input.amount(input.getAmount() / 100); + + MineTweakerAPI.apply(new Add(new StillRecipe(timePerUnit, toFluid(input), toFluid(output)))); + } + + private static class Add extends ForestryListAddition { + + public Add(IStillRecipe recipe) { + super("Forestry Still", RecipeManagers.stillManager); + recipes.add(recipe); + } + + @Override + public String getRecipeInfo(IStillRecipe recipe) { + return LogHelper.getStackDescription(recipe.getOutput()); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Removes a recipe for the Still + * + * @param output = liquid output + * @optionalParam liquid = liquid input + */ + @ZenMethod + public static void removeRecipe(IIngredient output, @Optional ILiquidStack input) { + List recipes = new LinkedList(); + + for (IStillRecipe r : RecipeManagers.stillManager.recipes()) { + if (r != null && r.getOutput() != null && matches(output, toILiquidStack(r.getOutput()))) { + if (input != null) { + if (matches(input, toILiquidStack(r.getInput()))) { + recipes.add(r); + } + } else recipes.add(r); + } + } + + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new Remove(recipes)); + } else { + LogHelper.logWarning( + String.format( + "No %s Recipe found for %s. Command ignored!", + Still.name, + LogHelper.getStackDescription(output))); + } + } + + private static class Remove extends ForestryListRemoval { + + public Remove(List recipes) { + super(Still.name, RecipeManagers.stillManager, recipes); + } + + @Override + public String getRecipeInfo(IStillRecipe recipe) { + return LogHelper.getStackDescription(recipe.getOutput()); + } + } } diff --git a/src/main/java/modtweaker2/mods/forestry/handlers/ThermionicFabricator.java b/src/main/java/modtweaker2/mods/forestry/handlers/ThermionicFabricator.java index cb5e5a7..5274689 100644 --- a/src/main/java/modtweaker2/mods/forestry/handlers/ThermionicFabricator.java +++ b/src/main/java/modtweaker2/mods/forestry/handlers/ThermionicFabricator.java @@ -13,176 +13,207 @@ import minetweaker.api.liquid.ILiquidStack; import modtweaker2.helpers.LogHelper; import modtweaker2.mods.forestry.ForestryListAddition; import modtweaker2.mods.forestry.ForestryListRemoval; -import net.minecraftforge.fluids.FluidRegistry; - import modtweaker2.mods.forestry.recipes.DescriptiveRecipe; import modtweaker2.mods.forestry.recipes.FabricatorRecipe; import modtweaker2.mods.forestry.recipes.FabricatorSmeltingRecipe; + +import net.minecraftforge.fluids.FluidRegistry; + import stanhebben.zenscript.annotations.Optional; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; - import forestry.api.recipes.IDescriptiveRecipe; import forestry.api.recipes.IFabricatorManager; +import forestry.api.recipes.IFabricatorRecipe; import forestry.api.recipes.IFabricatorSmeltingManager; import forestry.api.recipes.IFabricatorSmeltingRecipe; import forestry.api.recipes.RecipeManagers; -import forestry.api.recipes.IFabricatorRecipe; @ZenClass("mods.forestry.ThermionicFabricator") public class ThermionicFabricator { - - public static final String nameSmelting = "Forestry Thermionic Fabricator (Smelting)"; - public static final String nameCasting = "Forestry Thermionic Fabricator (Casting)"; - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - /** - * Adds a smelting recipe for the Thermionic Fabricator - * - * @param fluidOutput recipe fluid amount - * @param itemInput recipe input input - * @param meltingPoint point at where itemInput melts down - */ - @ZenMethod - public static void addSmelting(int fluidOutput, IItemStack itemInput, int meltingPoint) { - //The machines internal tank accept only liquid glass, therefor this function only accept the amount and hardcode the fluid to glass - MineTweakerAPI.apply(new AddSmelting(new FabricatorSmeltingRecipe(toStack(itemInput), FluidRegistry.getFluidStack("glass", fluidOutput), meltingPoint))); - } - - @Deprecated - @ZenMethod - public static void addSmelting(IItemStack itemInput, int meltingPoint, int fluidOutput) { - //The machines internal tank accept only liquid glass, therefor this function only accept the amount and hardcode the fluid to glass - MineTweakerAPI.apply(new AddSmelting(new FabricatorSmeltingRecipe(toStack(itemInput), FluidRegistry.getFluidStack("glass", fluidOutput), meltingPoint))); - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - /** - * Adds a casting recipe for the Thermionic Fabricator - * - * @param output recipe output item - * @param ingredients list of input items - * @param fluidInput recipe fluid input - * @param plan recipe plan item - */ - @ZenMethod - public static void addCast(IItemStack output, IIngredient[][] ingredients, int fluidInput, @Optional IItemStack plan) { - IDescriptiveRecipe recipe = new DescriptiveRecipe(3, 3, toShapedObjects(ingredients), toStack(output), false); - MineTweakerAPI.apply(new AddCast(new FabricatorRecipe(toStack(plan), FluidRegistry.getFluidStack("glass", fluidInput), recipe))); - } - - @Deprecated - @ZenMethod - public static void addCast(ILiquidStack fluidInput, IIngredient[][] ingredients, IItemStack plan, IItemStack output) { - IDescriptiveRecipe recipe = new DescriptiveRecipe(3, 3, toShapedObjects(ingredients), toStack(output), false); - MineTweakerAPI.apply(new AddCast(new FabricatorRecipe(toStack(plan), toFluid(fluidInput), recipe))); - } - - /* - Implements the actions to add a recipe - Since the machine has two crafting Steps, this is a constructors for both - */ - private static class AddSmelting extends ForestryListAddition { - - public AddSmelting(IFabricatorSmeltingRecipe recipe) { - super(ThermionicFabricator.nameSmelting, RecipeManagers.fabricatorSmeltingManager); - recipes.add(recipe); - } - - @Override - public String getRecipeInfo(IFabricatorSmeltingRecipe recipe) { - return LogHelper.getStackDescription(recipe.getResource()); - } - } - - private static class AddCast extends ForestryListAddition { - - public AddCast(IFabricatorRecipe recipe) { - super(ThermionicFabricator.nameCasting, RecipeManagers.fabricatorManager); - recipes.add(recipe); - } - - @Override - public String getRecipeInfo(IFabricatorRecipe recipe) { - return LogHelper.getStackDescription(recipe.getRecipeOutput()); - } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - @ZenMethod - public static void removeSmelting(IIngredient itemInput) { - List recipes = new LinkedList(); - - for (IFabricatorSmeltingRecipe r : RecipeManagers.fabricatorSmeltingManager.recipes()) { - if (r != null && r.getResource() != null && matches(itemInput, toIItemStack(r.getResource()))) { - recipes.add(r); - } - } - - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new RemoveSmelting(recipes)); - } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", ThermionicFabricator.nameSmelting, itemInput.toString())); - } - } - - @ZenMethod - public static void removeCast(IIngredient product) { - List recipes = new LinkedList(); - - for (IFabricatorRecipe r : RecipeManagers.fabricatorManager.recipes()) { - if (r != null && r.getRecipeOutput() != null && matches(product, toIItemStack(r.getRecipeOutput()))) { - recipes.add(r); - } - } - - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new RemoveCasts(recipes)); - } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", ThermionicFabricator.nameSmelting, product.toString())); - } - } - - @Deprecated - @ZenMethod - public static void removeCasts(IIngredient product) { - List recipes = new LinkedList(); - - for (IFabricatorRecipe r : RecipeManagers.fabricatorManager.recipes()) { - if (r != null && r.getRecipeOutput() != null && matches(product, toIItemStack(r.getRecipeOutput()))) { - recipes.add(r); - } - } - - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new RemoveCasts(recipes)); - } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", ThermionicFabricator.nameSmelting, product.toString())); - } - } - - private static class RemoveSmelting extends ForestryListRemoval { - public RemoveSmelting(List recipes) { - super(ThermionicFabricator.nameSmelting, RecipeManagers.fabricatorSmeltingManager, recipes); - } - - @Override - public String getRecipeInfo(IFabricatorSmeltingRecipe recipe) { - return LogHelper.getStackDescription(recipe.getResource()); - } - } - - private static class RemoveCasts extends ForestryListRemoval { - public RemoveCasts(List recipes) { - super(ThermionicFabricator.nameCasting, RecipeManagers.fabricatorManager, recipes); - } - - @Override - public String getRecipeInfo(IFabricatorRecipe recipe) { - return LogHelper.getStackDescription(recipe.getRecipeOutput()); - } - } + + public static final String nameSmelting = "Forestry Thermionic Fabricator (Smelting)"; + public static final String nameCasting = "Forestry Thermionic Fabricator (Casting)"; + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Adds a smelting recipe for the Thermionic Fabricator + * + * @param fluidOutput recipe fluid amount + * @param itemInput recipe input input + * @param meltingPoint point at where itemInput melts down + */ + @ZenMethod + public static void addSmelting(int fluidOutput, IItemStack itemInput, int meltingPoint) { + // The machines internal tank accept only liquid glass, therefor this function only accept the amount and + // hardcode the fluid to glass + MineTweakerAPI.apply( + new AddSmelting( + new FabricatorSmeltingRecipe( + toStack(itemInput), + FluidRegistry.getFluidStack("glass", fluidOutput), + meltingPoint))); + } + + @Deprecated + @ZenMethod + public static void addSmelting(IItemStack itemInput, int meltingPoint, int fluidOutput) { + // The machines internal tank accept only liquid glass, therefor this function only accept the amount and + // hardcode the fluid to glass + MineTweakerAPI.apply( + new AddSmelting( + new FabricatorSmeltingRecipe( + toStack(itemInput), + FluidRegistry.getFluidStack("glass", fluidOutput), + meltingPoint))); + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Adds a casting recipe for the Thermionic Fabricator + * + * @param output recipe output item + * @param ingredients list of input items + * @param fluidInput recipe fluid input + * @param plan recipe plan item + */ + @ZenMethod + public static void addCast(IItemStack output, IIngredient[][] ingredients, int fluidInput, + @Optional IItemStack plan) { + IDescriptiveRecipe recipe = new DescriptiveRecipe(3, 3, toShapedObjects(ingredients), toStack(output), false); + MineTweakerAPI.apply( + new AddCast( + new FabricatorRecipe(toStack(plan), FluidRegistry.getFluidStack("glass", fluidInput), recipe))); + } + + @Deprecated + @ZenMethod + public static void addCast(ILiquidStack fluidInput, IIngredient[][] ingredients, IItemStack plan, + IItemStack output) { + IDescriptiveRecipe recipe = new DescriptiveRecipe(3, 3, toShapedObjects(ingredients), toStack(output), false); + MineTweakerAPI.apply(new AddCast(new FabricatorRecipe(toStack(plan), toFluid(fluidInput), recipe))); + } + + /* + * Implements the actions to add a recipe Since the machine has two crafting Steps, this is a constructors for both + */ + private static class AddSmelting + extends ForestryListAddition { + + public AddSmelting(IFabricatorSmeltingRecipe recipe) { + super(ThermionicFabricator.nameSmelting, RecipeManagers.fabricatorSmeltingManager); + recipes.add(recipe); + } + + @Override + public String getRecipeInfo(IFabricatorSmeltingRecipe recipe) { + return LogHelper.getStackDescription(recipe.getResource()); + } + } + + private static class AddCast extends ForestryListAddition { + + public AddCast(IFabricatorRecipe recipe) { + super(ThermionicFabricator.nameCasting, RecipeManagers.fabricatorManager); + recipes.add(recipe); + } + + @Override + public String getRecipeInfo(IFabricatorRecipe recipe) { + return LogHelper.getStackDescription(recipe.getRecipeOutput()); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + @ZenMethod + public static void removeSmelting(IIngredient itemInput) { + List recipes = new LinkedList(); + + for (IFabricatorSmeltingRecipe r : RecipeManagers.fabricatorSmeltingManager.recipes()) { + if (r != null && r.getResource() != null && matches(itemInput, toIItemStack(r.getResource()))) { + recipes.add(r); + } + } + + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new RemoveSmelting(recipes)); + } else { + LogHelper.logWarning( + String.format( + "No %s Recipe found for %s. Command ignored!", + ThermionicFabricator.nameSmelting, + itemInput.toString())); + } + } + + @ZenMethod + public static void removeCast(IIngredient product) { + List recipes = new LinkedList(); + + for (IFabricatorRecipe r : RecipeManagers.fabricatorManager.recipes()) { + if (r != null && r.getRecipeOutput() != null && matches(product, toIItemStack(r.getRecipeOutput()))) { + recipes.add(r); + } + } + + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new RemoveCasts(recipes)); + } else { + LogHelper.logWarning( + String.format( + "No %s Recipe found for %s. Command ignored!", + ThermionicFabricator.nameSmelting, + product.toString())); + } + } + + @Deprecated + @ZenMethod + public static void removeCasts(IIngredient product) { + List recipes = new LinkedList(); + + for (IFabricatorRecipe r : RecipeManagers.fabricatorManager.recipes()) { + if (r != null && r.getRecipeOutput() != null && matches(product, toIItemStack(r.getRecipeOutput()))) { + recipes.add(r); + } + } + + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new RemoveCasts(recipes)); + } else { + LogHelper.logWarning( + String.format( + "No %s Recipe found for %s. Command ignored!", + ThermionicFabricator.nameSmelting, + product.toString())); + } + } + + private static class RemoveSmelting + extends ForestryListRemoval { + + public RemoveSmelting(List recipes) { + super(ThermionicFabricator.nameSmelting, RecipeManagers.fabricatorSmeltingManager, recipes); + } + + @Override + public String getRecipeInfo(IFabricatorSmeltingRecipe recipe) { + return LogHelper.getStackDescription(recipe.getResource()); + } + } + + private static class RemoveCasts extends ForestryListRemoval { + + public RemoveCasts(List recipes) { + super(ThermionicFabricator.nameCasting, RecipeManagers.fabricatorManager, recipes); + } + + @Override + public String getRecipeInfo(IFabricatorRecipe recipe) { + return LogHelper.getStackDescription(recipe.getRecipeOutput()); + } + } } diff --git a/src/main/java/modtweaker2/mods/forestry/recipes/CarpenterRecipe.java b/src/main/java/modtweaker2/mods/forestry/recipes/CarpenterRecipe.java index 26a11b5..d8d2800 100644 --- a/src/main/java/modtweaker2/mods/forestry/recipes/CarpenterRecipe.java +++ b/src/main/java/modtweaker2/mods/forestry/recipes/CarpenterRecipe.java @@ -1,48 +1,48 @@ -package modtweaker2.mods.forestry.recipes; - -import javax.annotation.Nullable; - -import net.minecraft.item.ItemStack; - -import net.minecraftforge.fluids.FluidStack; - -import forestry.api.recipes.ICarpenterRecipe; -import forestry.api.recipes.IDescriptiveRecipe; - -public class CarpenterRecipe implements ICarpenterRecipe { - - private final int packagingTime; - @Nullable - private final FluidStack liquid; - @Nullable - private final ItemStack box; - private final IDescriptiveRecipe internal; - - public CarpenterRecipe(int packagingTime, @Nullable FluidStack liquid, @Nullable ItemStack box, IDescriptiveRecipe internal) { - this.packagingTime = packagingTime; - this.liquid = liquid; - this.box = box; - this.internal = internal; - } - - public int getPackagingTime() { - return packagingTime; - } - - @Override - @Nullable - public ItemStack getBox() { - return box; - } - - @Override - @Nullable - public FluidStack getFluidResource() { - return liquid; - } - - @Override - public IDescriptiveRecipe getCraftingGridRecipe() { - return internal; - } -} +package modtweaker2.mods.forestry.recipes; + +import javax.annotation.Nullable; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import forestry.api.recipes.ICarpenterRecipe; +import forestry.api.recipes.IDescriptiveRecipe; + +public class CarpenterRecipe implements ICarpenterRecipe { + + private final int packagingTime; + @Nullable + private final FluidStack liquid; + @Nullable + private final ItemStack box; + private final IDescriptiveRecipe internal; + + public CarpenterRecipe(int packagingTime, @Nullable FluidStack liquid, @Nullable ItemStack box, + IDescriptiveRecipe internal) { + this.packagingTime = packagingTime; + this.liquid = liquid; + this.box = box; + this.internal = internal; + } + + public int getPackagingTime() { + return packagingTime; + } + + @Override + @Nullable + public ItemStack getBox() { + return box; + } + + @Override + @Nullable + public FluidStack getFluidResource() { + return liquid; + } + + @Override + public IDescriptiveRecipe getCraftingGridRecipe() { + return internal; + } +} diff --git a/src/main/java/modtweaker2/mods/forestry/recipes/CentrifugeRecipe.java b/src/main/java/modtweaker2/mods/forestry/recipes/CentrifugeRecipe.java index 96718e8..2b19dcf 100644 --- a/src/main/java/modtweaker2/mods/forestry/recipes/CentrifugeRecipe.java +++ b/src/main/java/modtweaker2/mods/forestry/recipes/CentrifugeRecipe.java @@ -1,64 +1,63 @@ -package modtweaker2.mods.forestry.recipes; - -import com.google.common.collect.ImmutableMap; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Random; - -import net.minecraft.item.ItemStack; - -import forestry.api.recipes.ICentrifugeRecipe; - -public class CentrifugeRecipe implements ICentrifugeRecipe { - - private final int processingTime; - private final ItemStack input; - private final Map outputs; - - public CentrifugeRecipe(int processingTime, ItemStack input, Map outputs) { - this.processingTime = processingTime; - this.input = input; - this.outputs = outputs; - - for (ItemStack item : outputs.keySet()) { - if (item == null) { - throw new IllegalArgumentException("Tried to register a null product of " + input); - } - } - } - - @Override - public ItemStack getInput() { - return input; - } - - @Override - public int getProcessingTime() { - return processingTime; - } - - @Override - public Collection getProducts(Random random) { - List products = new ArrayList(); - - for (Map.Entry entry : this.outputs.entrySet()) { - float probability = entry.getValue(); - - if (probability >= 1.0) { - products.add(entry.getKey().copy()); - } else if (random.nextFloat() < probability) { - products.add(entry.getKey().copy()); - } - } - - return products; - } - - @Override - public Map getAllProducts() { - return ImmutableMap.copyOf(outputs); - } -} +package modtweaker2.mods.forestry.recipes; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Random; + +import net.minecraft.item.ItemStack; + +import com.google.common.collect.ImmutableMap; +import forestry.api.recipes.ICentrifugeRecipe; + +public class CentrifugeRecipe implements ICentrifugeRecipe { + + private final int processingTime; + private final ItemStack input; + private final Map outputs; + + public CentrifugeRecipe(int processingTime, ItemStack input, Map outputs) { + this.processingTime = processingTime; + this.input = input; + this.outputs = outputs; + + for (ItemStack item : outputs.keySet()) { + if (item == null) { + throw new IllegalArgumentException("Tried to register a null product of " + input); + } + } + } + + @Override + public ItemStack getInput() { + return input; + } + + @Override + public int getProcessingTime() { + return processingTime; + } + + @Override + public Collection getProducts(Random random) { + List products = new ArrayList(); + + for (Map.Entry entry : this.outputs.entrySet()) { + float probability = entry.getValue(); + + if (probability >= 1.0) { + products.add(entry.getKey().copy()); + } else if (random.nextFloat() < probability) { + products.add(entry.getKey().copy()); + } + } + + return products; + } + + @Override + public Map getAllProducts() { + return ImmutableMap.copyOf(outputs); + } +} diff --git a/src/main/java/modtweaker2/mods/forestry/recipes/DescriptiveRecipe.java b/src/main/java/modtweaker2/mods/forestry/recipes/DescriptiveRecipe.java index 70906ff..6a5bb46 100644 --- a/src/main/java/modtweaker2/mods/forestry/recipes/DescriptiveRecipe.java +++ b/src/main/java/modtweaker2/mods/forestry/recipes/DescriptiveRecipe.java @@ -4,68 +4,67 @@ import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.world.World; - import net.minecraftforge.oredict.ShapedOreRecipe; import forestry.api.recipes.IDescriptiveRecipe; public class DescriptiveRecipe implements IDescriptiveRecipe { - private final int width; - private final int height; - private final ShapedOreRecipe recipe; - private final boolean preserveNBT; + private final int width; + private final int height; + private final ShapedOreRecipe recipe; + private final boolean preserveNBT; - public DescriptiveRecipe(int width, int height, Object[] ingredients, ItemStack output, boolean preserveNBT) { - this.width = width; - this.height = height; - this.recipe = new ShapedOreRecipe(output, ingredients); - this.preserveNBT = preserveNBT; - } + public DescriptiveRecipe(int width, int height, Object[] ingredients, ItemStack output, boolean preserveNBT) { + this.width = width; + this.height = height; + this.recipe = new ShapedOreRecipe(output, ingredients); + this.preserveNBT = preserveNBT; + } - @Override - public int getWidth() { - return width; - } + @Override + public int getWidth() { + return width; + } - @Override - public int getHeight() { - return height; - } + @Override + public int getHeight() { + return height; + } - @Override - public ItemStack getRecipeOutput() { - return recipe.getRecipeOutput(); - } + @Override + public ItemStack getRecipeOutput() { + return recipe.getRecipeOutput(); + } - @Override - public Object[] getIngredients() { - return recipe.getInput(); - } + @Override + public Object[] getIngredients() { + return recipe.getInput(); + } - @Override - public boolean preserveNBT() { - return preserveNBT; - } + @Override + public boolean preserveNBT() { + return preserveNBT; + } - @Override - public boolean matches(InventoryCrafting inventoryCrafting, World world) { - return recipe.matches(inventoryCrafting, world); - } + @Override + public boolean matches(InventoryCrafting inventoryCrafting, World world) { + return recipe.matches(inventoryCrafting, world); + } - @Override - @Deprecated - public boolean matches(IInventory inventoryCrafting, World world) { - return false; - } + @Override + @Deprecated + public boolean matches(IInventory inventoryCrafting, World world) { + return false; + } - @Override - public ItemStack getCraftingResult(InventoryCrafting inventoryCrafting) { - return recipe.getCraftingResult(inventoryCrafting); - } + @Override + public ItemStack getCraftingResult(InventoryCrafting inventoryCrafting) { + return recipe.getCraftingResult(inventoryCrafting); + } - @Override - public int getRecipeSize() { - return width * height; - } + @Override + public int getRecipeSize() { + return width * height; + } } diff --git a/src/main/java/modtweaker2/mods/forestry/recipes/FabricatorRecipe.java b/src/main/java/modtweaker2/mods/forestry/recipes/FabricatorRecipe.java index bf64037..e6b9f39 100644 --- a/src/main/java/modtweaker2/mods/forestry/recipes/FabricatorRecipe.java +++ b/src/main/java/modtweaker2/mods/forestry/recipes/FabricatorRecipe.java @@ -1,77 +1,77 @@ -package modtweaker2.mods.forestry.recipes; - -import javax.annotation.Nullable; - -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; - -import net.minecraftforge.fluids.FluidStack; - -import forestry.api.recipes.IDescriptiveRecipe; -import forestry.api.recipes.IFabricatorRecipe; - -public class FabricatorRecipe implements IFabricatorRecipe { - - private final ItemStack plan; - private final FluidStack molten; - private final IDescriptiveRecipe internal; - - public FabricatorRecipe(ItemStack plan, FluidStack molten, ItemStack result, boolean preservesNbt, Object[] ingredients) { - this(plan, molten, new DescriptiveRecipe(3, 3, ingredients, result, preservesNbt)); - } - - public FabricatorRecipe(ItemStack plan, FluidStack molten, IDescriptiveRecipe internal) { - this.plan = plan; - this.molten = molten; - this.internal = internal; - } - - @Override - @Deprecated - public boolean matches(@Nullable ItemStack plan, ItemStack[][] resources) { - return false; - } - - @Override - public Object[] getIngredients() { - return internal.getIngredients(); - } - - @Override - public int getWidth() { - return internal.getWidth(); - } - - @Override - public int getHeight() { - return internal.getHeight(); - } - - @Override - public boolean preservesNbt() { - return internal.preserveNBT(); - } - - @Override - @Nullable - public ItemStack getPlan() { - return plan; - } - - @Override - public FluidStack getLiquid() { - return molten; - } - - @Override - @Deprecated - public ItemStack getCraftingResult(IInventory craftingInventory) { - return getRecipeOutput(); - } - - @Override - public ItemStack getRecipeOutput() { - return internal.getRecipeOutput(); - } - -} +package modtweaker2.mods.forestry.recipes; + +import javax.annotation.Nullable; + +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import forestry.api.recipes.IDescriptiveRecipe; +import forestry.api.recipes.IFabricatorRecipe; + +public class FabricatorRecipe implements IFabricatorRecipe { + + private final ItemStack plan; + private final FluidStack molten; + private final IDescriptiveRecipe internal; + + public FabricatorRecipe(ItemStack plan, FluidStack molten, ItemStack result, boolean preservesNbt, + Object[] ingredients) { + this(plan, molten, new DescriptiveRecipe(3, 3, ingredients, result, preservesNbt)); + } + + public FabricatorRecipe(ItemStack plan, FluidStack molten, IDescriptiveRecipe internal) { + this.plan = plan; + this.molten = molten; + this.internal = internal; + } + + @Override + @Deprecated + public boolean matches(@Nullable ItemStack plan, ItemStack[][] resources) { + return false; + } + + @Override + public Object[] getIngredients() { + return internal.getIngredients(); + } + + @Override + public int getWidth() { + return internal.getWidth(); + } + + @Override + public int getHeight() { + return internal.getHeight(); + } + + @Override + public boolean preservesNbt() { + return internal.preserveNBT(); + } + + @Override + @Nullable + public ItemStack getPlan() { + return plan; + } + + @Override + public FluidStack getLiquid() { + return molten; + } + + @Override + @Deprecated + public ItemStack getCraftingResult(IInventory craftingInventory) { + return getRecipeOutput(); + } + + @Override + public ItemStack getRecipeOutput() { + return internal.getRecipeOutput(); + } + +} diff --git a/src/main/java/modtweaker2/mods/forestry/recipes/FabricatorSmeltingRecipe.java b/src/main/java/modtweaker2/mods/forestry/recipes/FabricatorSmeltingRecipe.java index 3fe3ef3..1386ba9 100644 --- a/src/main/java/modtweaker2/mods/forestry/recipes/FabricatorSmeltingRecipe.java +++ b/src/main/java/modtweaker2/mods/forestry/recipes/FabricatorSmeltingRecipe.java @@ -1,38 +1,38 @@ -package modtweaker2.mods.forestry.recipes; - -import net.minecraft.item.ItemStack; - -import net.minecraftforge.fluids.FluidStack; - -import forestry.api.recipes.IFabricatorSmeltingRecipe; - -public class FabricatorSmeltingRecipe implements IFabricatorSmeltingRecipe { - private final ItemStack resource; - private final FluidStack product; - private final int meltingPoint; - - public FabricatorSmeltingRecipe(ItemStack resource, FluidStack molten, int meltingPoint) { - if (resource == null) { - throw new IllegalArgumentException("Resource cannot be null"); - } - if (molten == null) { - throw new IllegalArgumentException("Molten cannot be null"); - } - - this.resource = resource; - this.product = molten; - this.meltingPoint = meltingPoint; - } - - public ItemStack getResource() { - return resource; - } - - public FluidStack getProduct() { - return product; - } - - public int getMeltingPoint() { - return meltingPoint; - } -} +package modtweaker2.mods.forestry.recipes; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import forestry.api.recipes.IFabricatorSmeltingRecipe; + +public class FabricatorSmeltingRecipe implements IFabricatorSmeltingRecipe { + + private final ItemStack resource; + private final FluidStack product; + private final int meltingPoint; + + public FabricatorSmeltingRecipe(ItemStack resource, FluidStack molten, int meltingPoint) { + if (resource == null) { + throw new IllegalArgumentException("Resource cannot be null"); + } + if (molten == null) { + throw new IllegalArgumentException("Molten cannot be null"); + } + + this.resource = resource; + this.product = molten; + this.meltingPoint = meltingPoint; + } + + public ItemStack getResource() { + return resource; + } + + public FluidStack getProduct() { + return product; + } + + public int getMeltingPoint() { + return meltingPoint; + } +} diff --git a/src/main/java/modtweaker2/mods/forestry/recipes/FermenterRecipe.java b/src/main/java/modtweaker2/mods/forestry/recipes/FermenterRecipe.java index 50f79d4..77a4362 100644 --- a/src/main/java/modtweaker2/mods/forestry/recipes/FermenterRecipe.java +++ b/src/main/java/modtweaker2/mods/forestry/recipes/FermenterRecipe.java @@ -1,68 +1,68 @@ -package modtweaker2.mods.forestry.recipes; - -import net.minecraft.item.ItemStack; - -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; - -import forestry.api.recipes.IFermenterRecipe; - -public class FermenterRecipe implements IFermenterRecipe { - - private final ItemStack resource; - private final int fermentationValue; - private final float modifier; - private final Fluid output; - private final FluidStack fluidResource; - - public FermenterRecipe(ItemStack resource, int fermentationValue, float modifier, Fluid output, FluidStack fluidResource) { - if (resource == null) { - throw new NullPointerException("Fermenter Resource cannot be null!"); - } - - if (output == null) { - throw new NullPointerException("Fermenter Output cannot be null!"); - } - - if (fluidResource == null) { - throw new NullPointerException("Fermenter Liquid cannot be null!"); - } - - // assume that fermenter recipes want to use Forestry's honey and not the legacy "fluid.honey" - if (fluidResource.getFluid().getName().equals("fluid.honey")) { - fluidResource = new FluidStack(FluidRegistry.getFluid("fluid.for.honey"), fluidResource.amount); - } - - this.resource = resource; - this.fermentationValue = fermentationValue; - this.modifier = modifier; - this.output = output; - this.fluidResource = fluidResource; - } - - @Override - public ItemStack getResource() { - return resource; - } - - @Override - public FluidStack getFluidResource() { - return fluidResource; - } - - @Override - public int getFermentationValue() { - return fermentationValue; - } - - @Override - public float getModifier() { - return modifier; - } - - @Override - public Fluid getOutput() { - return output; - } -} +package modtweaker2.mods.forestry.recipes; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import forestry.api.recipes.IFermenterRecipe; + +public class FermenterRecipe implements IFermenterRecipe { + + private final ItemStack resource; + private final int fermentationValue; + private final float modifier; + private final Fluid output; + private final FluidStack fluidResource; + + public FermenterRecipe(ItemStack resource, int fermentationValue, float modifier, Fluid output, + FluidStack fluidResource) { + if (resource == null) { + throw new NullPointerException("Fermenter Resource cannot be null!"); + } + + if (output == null) { + throw new NullPointerException("Fermenter Output cannot be null!"); + } + + if (fluidResource == null) { + throw new NullPointerException("Fermenter Liquid cannot be null!"); + } + + // assume that fermenter recipes want to use Forestry's honey and not the legacy "fluid.honey" + if (fluidResource.getFluid().getName().equals("fluid.honey")) { + fluidResource = new FluidStack(FluidRegistry.getFluid("fluid.for.honey"), fluidResource.amount); + } + + this.resource = resource; + this.fermentationValue = fermentationValue; + this.modifier = modifier; + this.output = output; + this.fluidResource = fluidResource; + } + + @Override + public ItemStack getResource() { + return resource; + } + + @Override + public FluidStack getFluidResource() { + return fluidResource; + } + + @Override + public int getFermentationValue() { + return fermentationValue; + } + + @Override + public float getModifier() { + return modifier; + } + + @Override + public Fluid getOutput() { + return output; + } +} diff --git a/src/main/java/modtweaker2/mods/forestry/recipes/MoistenerRecipe.java b/src/main/java/modtweaker2/mods/forestry/recipes/MoistenerRecipe.java index 926838a..f0afebc 100644 --- a/src/main/java/modtweaker2/mods/forestry/recipes/MoistenerRecipe.java +++ b/src/main/java/modtweaker2/mods/forestry/recipes/MoistenerRecipe.java @@ -1,30 +1,30 @@ -package modtweaker2.mods.forestry.recipes; - -import net.minecraft.item.ItemStack; - -import forestry.api.recipes.IMoistenerRecipe; - -public class MoistenerRecipe implements IMoistenerRecipe { - - private final int timePerItem; - private final ItemStack resource; - private final ItemStack product; - - public MoistenerRecipe(ItemStack resource, ItemStack product, int timePerItem) { - this.timePerItem = timePerItem; - this.resource = resource; - this.product = product; - } - - public int getTimePerItem() { - return timePerItem; - } - - public ItemStack getResource() { - return resource; - } - - public ItemStack getProduct() { - return product; - } -} +package modtweaker2.mods.forestry.recipes; + +import net.minecraft.item.ItemStack; + +import forestry.api.recipes.IMoistenerRecipe; + +public class MoistenerRecipe implements IMoistenerRecipe { + + private final int timePerItem; + private final ItemStack resource; + private final ItemStack product; + + public MoistenerRecipe(ItemStack resource, ItemStack product, int timePerItem) { + this.timePerItem = timePerItem; + this.resource = resource; + this.product = product; + } + + public int getTimePerItem() { + return timePerItem; + } + + public ItemStack getResource() { + return resource; + } + + public ItemStack getProduct() { + return product; + } +} diff --git a/src/main/java/modtweaker2/mods/forestry/recipes/SqueezerRecipe.java b/src/main/java/modtweaker2/mods/forestry/recipes/SqueezerRecipe.java index 54c37cb..5b55cd1 100644 --- a/src/main/java/modtweaker2/mods/forestry/recipes/SqueezerRecipe.java +++ b/src/main/java/modtweaker2/mods/forestry/recipes/SqueezerRecipe.java @@ -1,50 +1,50 @@ -package modtweaker2.mods.forestry.recipes; - -import net.minecraft.item.ItemStack; - -import net.minecraftforge.fluids.FluidStack; - -import forestry.api.recipes.ISqueezerRecipe; - -public class SqueezerRecipe implements ISqueezerRecipe { - - private final int processingTime; - private final ItemStack[] resources; - private final FluidStack fluidOutput; - private final ItemStack remnants; - private final float remnantsChance; - - public SqueezerRecipe(int processingTime, ItemStack[] resources, FluidStack fluidOutput, ItemStack remnants, float remnantsChance) { - this.processingTime = processingTime; - this.resources = resources; - this.fluidOutput = fluidOutput; - this.remnants = remnants; - this.remnantsChance = remnantsChance; - } - - @Override - public ItemStack[] getResources() { - return resources; - } - - @Override - public ItemStack getRemnants() { - return remnants; - } - - @Override - public float getRemnantsChance() { - return remnantsChance; - } - - @Override - public FluidStack getFluidOutput() { - return fluidOutput; - } - - @Override - public int getProcessingTime() { - return processingTime; - } - -} +package modtweaker2.mods.forestry.recipes; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import forestry.api.recipes.ISqueezerRecipe; + +public class SqueezerRecipe implements ISqueezerRecipe { + + private final int processingTime; + private final ItemStack[] resources; + private final FluidStack fluidOutput; + private final ItemStack remnants; + private final float remnantsChance; + + public SqueezerRecipe(int processingTime, ItemStack[] resources, FluidStack fluidOutput, ItemStack remnants, + float remnantsChance) { + this.processingTime = processingTime; + this.resources = resources; + this.fluidOutput = fluidOutput; + this.remnants = remnants; + this.remnantsChance = remnantsChance; + } + + @Override + public ItemStack[] getResources() { + return resources; + } + + @Override + public ItemStack getRemnants() { + return remnants; + } + + @Override + public float getRemnantsChance() { + return remnantsChance; + } + + @Override + public FluidStack getFluidOutput() { + return fluidOutput; + } + + @Override + public int getProcessingTime() { + return processingTime; + } + +} diff --git a/src/main/java/modtweaker2/mods/forestry/recipes/StillRecipe.java b/src/main/java/modtweaker2/mods/forestry/recipes/StillRecipe.java index 49df0a4..7c99138 100644 --- a/src/main/java/modtweaker2/mods/forestry/recipes/StillRecipe.java +++ b/src/main/java/modtweaker2/mods/forestry/recipes/StillRecipe.java @@ -1,38 +1,39 @@ -package modtweaker2.mods.forestry.recipes; - -import net.minecraftforge.fluids.FluidStack; - -import forestry.api.recipes.IStillRecipe; - -public class StillRecipe implements IStillRecipe { - private final int timePerUnit; - private final FluidStack input; - private final FluidStack output; - - public StillRecipe(int timePerUnit, FluidStack input, FluidStack output) { - this.timePerUnit = timePerUnit; - if (input == null) { - throw new IllegalArgumentException("Still recipes need an input. Input was null."); - } - if (output == null) { - throw new IllegalArgumentException("Still recipes need an output. Output was null."); - } - this.input = input; - this.output = output; - } - - @Override - public int getCyclesPerUnit() { - return timePerUnit; - } - - @Override - public FluidStack getInput() { - return input; - } - - @Override - public FluidStack getOutput() { - return output; - } -} +package modtweaker2.mods.forestry.recipes; + +import net.minecraftforge.fluids.FluidStack; + +import forestry.api.recipes.IStillRecipe; + +public class StillRecipe implements IStillRecipe { + + private final int timePerUnit; + private final FluidStack input; + private final FluidStack output; + + public StillRecipe(int timePerUnit, FluidStack input, FluidStack output) { + this.timePerUnit = timePerUnit; + if (input == null) { + throw new IllegalArgumentException("Still recipes need an input. Input was null."); + } + if (output == null) { + throw new IllegalArgumentException("Still recipes need an output. Output was null."); + } + this.input = input; + this.output = output; + } + + @Override + public int getCyclesPerUnit() { + return timePerUnit; + } + + @Override + public FluidStack getInput() { + return input; + } + + @Override + public FluidStack getOutput() { + return output; + } +} diff --git a/src/main/java/modtweaker2/mods/ic2c/IC2C.java b/src/main/java/modtweaker2/mods/ic2c/IC2C.java index 91559e6..fd7d432 100644 --- a/src/main/java/modtweaker2/mods/ic2c/IC2C.java +++ b/src/main/java/modtweaker2/mods/ic2c/IC2C.java @@ -15,18 +15,18 @@ import modtweaker2.mods.ic2c.mods.Recycler; public class IC2C { - public IC2C() { - MineTweakerAPI.registerClass(BlastFurnace.class); - MineTweakerAPI.registerClass(BlockCutter.class); - MineTweakerAPI.registerClass(Centrifuge.class); - MineTweakerAPI.registerClass(Compressor.class); - MineTweakerAPI.registerClass(Extractor.class); - MineTweakerAPI.registerClass(Macerator.class); - MineTweakerAPI.registerClass(MetalFormerCutting.class); - MineTweakerAPI.registerClass(MetalFormerExtruding.class); - MineTweakerAPI.registerClass(MetalFormerRolling.class); - MineTweakerAPI.registerClass(OreWashing.class); - MineTweakerAPI.registerClass(Recycler.class); + public IC2C() { + MineTweakerAPI.registerClass(BlastFurnace.class); + MineTweakerAPI.registerClass(BlockCutter.class); + MineTweakerAPI.registerClass(Centrifuge.class); + MineTweakerAPI.registerClass(Compressor.class); + MineTweakerAPI.registerClass(Extractor.class); + MineTweakerAPI.registerClass(Macerator.class); + MineTweakerAPI.registerClass(MetalFormerCutting.class); + MineTweakerAPI.registerClass(MetalFormerExtruding.class); + MineTweakerAPI.registerClass(MetalFormerRolling.class); + MineTweakerAPI.registerClass(OreWashing.class); + MineTweakerAPI.registerClass(Recycler.class); - } + } } diff --git a/src/main/java/modtweaker2/mods/ic2c/mods/BlastFurnace.java b/src/main/java/modtweaker2/mods/ic2c/mods/BlastFurnace.java index 438193d..4592dd3 100644 --- a/src/main/java/modtweaker2/mods/ic2c/mods/BlastFurnace.java +++ b/src/main/java/modtweaker2/mods/ic2c/mods/BlastFurnace.java @@ -1,10 +1,5 @@ package modtweaker2.mods.ic2c.mods; -import ic2.api.recipe.IRecipeInput; -import ic2.api.recipe.RecipeInputItemStack; -import ic2.api.recipe.RecipeOutput; -import ic2.api.recipe.Recipes; - import java.util.LinkedHashMap; import java.util.Map; import java.util.Map.Entry; @@ -14,56 +9,62 @@ import minetweaker.api.item.IItemStack; import modtweaker2.helpers.InputHelper; import modtweaker2.utils.BaseMapAddition; import modtweaker2.utils.BaseMapRemoval; + import net.minecraft.item.ItemStack; + import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; +import ic2.api.recipe.IRecipeInput; +import ic2.api.recipe.RecipeInputItemStack; +import ic2.api.recipe.RecipeOutput; +import ic2.api.recipe.Recipes; @ZenClass("mods.ic2classic.BlastFurnace") public class BlastFurnace { - @ZenMethod - public static void addRecipe(IItemStack output, IItemStack input) { - MineTweakerAPI.apply(new Add(InputHelper.toStack(output), InputHelper.toStack(input))); - } + @ZenMethod + public static void addRecipe(IItemStack output, IItemStack input) { + MineTweakerAPI.apply(new Add(InputHelper.toStack(output), InputHelper.toStack(input))); + } - private static class Add extends BaseMapAddition { + private static class Add extends BaseMapAddition { - protected Add(ItemStack output, ItemStack input) { - super("BlastFurnace", Recipes.blastfurance.getRecipes()); - recipes.put(new RecipeInputItemStack(input), new RecipeOutput(null, output)); - } + protected Add(ItemStack output, ItemStack input) { + super("BlastFurnace", Recipes.blastfurance.getRecipes()); + recipes.put(new RecipeInputItemStack(input), new RecipeOutput(null, output)); + } - @Override - protected String getRecipeInfo(Entry recipe) { - return recipe.toString(); - } + @Override + protected String getRecipeInfo(Entry recipe) { + return recipe.toString(); + } - } + } - @ZenMethod - public static void removeRecipe(IItemStack output) { - LinkedHashMap recipes = new LinkedHashMap(); - for (Entry set : Recipes.blastfurance.getRecipes().entrySet()) { - for (ItemStack stack : set.getValue().items) { - if (stack.isItemEqual(InputHelper.toStack(output))) { - recipes.put(set.getKey(), set.getValue()); - } - } - } - MineTweakerAPI.apply(new Remove(recipes)); - } + @ZenMethod + public static void removeRecipe(IItemStack output) { + LinkedHashMap recipes = new LinkedHashMap(); + for (Entry set : Recipes.blastfurance.getRecipes().entrySet()) { + for (ItemStack stack : set.getValue().items) { + if (stack.isItemEqual(InputHelper.toStack(output))) { + recipes.put(set.getKey(), set.getValue()); + } + } + } + MineTweakerAPI.apply(new Remove(recipes)); + } - private static class Remove extends BaseMapRemoval { + private static class Remove extends BaseMapRemoval { - protected Remove(Map recipes) { - super("BlastFurnace", Recipes.blastfurance.getRecipes(), recipes); - } + protected Remove(Map recipes) { + super("BlastFurnace", Recipes.blastfurance.getRecipes(), recipes); + } - @Override - protected String getRecipeInfo(Entry recipe) { - return recipe.toString(); - } + @Override + protected String getRecipeInfo(Entry recipe) { + return recipe.toString(); + } - } + } } diff --git a/src/main/java/modtweaker2/mods/ic2c/mods/BlockCutter.java b/src/main/java/modtweaker2/mods/ic2c/mods/BlockCutter.java index 93b4dc4..3f9ec72 100644 --- a/src/main/java/modtweaker2/mods/ic2c/mods/BlockCutter.java +++ b/src/main/java/modtweaker2/mods/ic2c/mods/BlockCutter.java @@ -1,10 +1,5 @@ package modtweaker2.mods.ic2c.mods; -import ic2.api.recipe.IRecipeInput; -import ic2.api.recipe.RecipeInputItemStack; -import ic2.api.recipe.RecipeOutput; -import ic2.api.recipe.Recipes; - import java.util.LinkedHashMap; import java.util.Map; import java.util.Map.Entry; @@ -14,56 +9,62 @@ import minetweaker.api.item.IItemStack; import modtweaker2.helpers.InputHelper; import modtweaker2.utils.BaseMapAddition; import modtweaker2.utils.BaseMapRemoval; + import net.minecraft.item.ItemStack; + import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; +import ic2.api.recipe.IRecipeInput; +import ic2.api.recipe.RecipeInputItemStack; +import ic2.api.recipe.RecipeOutput; +import ic2.api.recipe.Recipes; @ZenClass("mods.ic2classic.BlockCutter") public class BlockCutter { - @ZenMethod - public static void addRecipe(IItemStack output, IItemStack input) { - MineTweakerAPI.apply(new Add(InputHelper.toStack(output), InputHelper.toStack(input))); - } + @ZenMethod + public static void addRecipe(IItemStack output, IItemStack input) { + MineTweakerAPI.apply(new Add(InputHelper.toStack(output), InputHelper.toStack(input))); + } - private static class Add extends BaseMapAddition { + private static class Add extends BaseMapAddition { - protected Add(ItemStack output, ItemStack input) { - super("BlockCutter", Recipes.blockcutter.getRecipes()); - recipes.put(new RecipeInputItemStack(input), new RecipeOutput(null, output)); - } + protected Add(ItemStack output, ItemStack input) { + super("BlockCutter", Recipes.blockcutter.getRecipes()); + recipes.put(new RecipeInputItemStack(input), new RecipeOutput(null, output)); + } - @Override - protected String getRecipeInfo(Entry recipe) { - return recipe.toString(); - } + @Override + protected String getRecipeInfo(Entry recipe) { + return recipe.toString(); + } - } + } - @ZenMethod - public static void removeRecipe(IItemStack output) { - LinkedHashMap recipes = new LinkedHashMap(); - for (Entry set : Recipes.blockcutter.getRecipes().entrySet()) { - for (ItemStack stack : set.getValue().items) { - if (stack.isItemEqual(InputHelper.toStack(output))) { - recipes.put(set.getKey(), set.getValue()); - } - } - } - MineTweakerAPI.apply(new Remove(recipes)); - } + @ZenMethod + public static void removeRecipe(IItemStack output) { + LinkedHashMap recipes = new LinkedHashMap(); + for (Entry set : Recipes.blockcutter.getRecipes().entrySet()) { + for (ItemStack stack : set.getValue().items) { + if (stack.isItemEqual(InputHelper.toStack(output))) { + recipes.put(set.getKey(), set.getValue()); + } + } + } + MineTweakerAPI.apply(new Remove(recipes)); + } - private static class Remove extends BaseMapRemoval { + private static class Remove extends BaseMapRemoval { - protected Remove(Map recipes) { - super("BlockCutter", Recipes.blockcutter.getRecipes(), recipes); - } + protected Remove(Map recipes) { + super("BlockCutter", Recipes.blockcutter.getRecipes(), recipes); + } - @Override - protected String getRecipeInfo(Entry recipe) { - return recipe.toString(); - } + @Override + protected String getRecipeInfo(Entry recipe) { + return recipe.toString(); + } - } + } } diff --git a/src/main/java/modtweaker2/mods/ic2c/mods/Centrifuge.java b/src/main/java/modtweaker2/mods/ic2c/mods/Centrifuge.java index ee8ebc3..134c19d 100644 --- a/src/main/java/modtweaker2/mods/ic2c/mods/Centrifuge.java +++ b/src/main/java/modtweaker2/mods/ic2c/mods/Centrifuge.java @@ -1,10 +1,5 @@ package modtweaker2.mods.ic2c.mods; -import ic2.api.recipe.IRecipeInput; -import ic2.api.recipe.RecipeInputItemStack; -import ic2.api.recipe.RecipeOutput; -import ic2.api.recipe.Recipes; - import java.util.LinkedHashMap; import java.util.Map; import java.util.Map.Entry; @@ -14,56 +9,62 @@ import minetweaker.api.item.IItemStack; import modtweaker2.helpers.InputHelper; import modtweaker2.utils.BaseMapAddition; import modtweaker2.utils.BaseMapRemoval; + import net.minecraft.item.ItemStack; + import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; +import ic2.api.recipe.IRecipeInput; +import ic2.api.recipe.RecipeInputItemStack; +import ic2.api.recipe.RecipeOutput; +import ic2.api.recipe.Recipes; @ZenClass("mods.ic2classic.Centrifuge") public class Centrifuge { - @ZenMethod - public static void addRecipe(IItemStack output, IItemStack input) { - MineTweakerAPI.apply(new Add(InputHelper.toStack(output), InputHelper.toStack(input))); - } + @ZenMethod + public static void addRecipe(IItemStack output, IItemStack input) { + MineTweakerAPI.apply(new Add(InputHelper.toStack(output), InputHelper.toStack(input))); + } - private static class Add extends BaseMapAddition { + private static class Add extends BaseMapAddition { - protected Add(ItemStack output, ItemStack input) { - super("Centrifuge", Recipes.centrifuge.getRecipes()); - recipes.put(new RecipeInputItemStack(input), new RecipeOutput(null, output)); - } + protected Add(ItemStack output, ItemStack input) { + super("Centrifuge", Recipes.centrifuge.getRecipes()); + recipes.put(new RecipeInputItemStack(input), new RecipeOutput(null, output)); + } - @Override - protected String getRecipeInfo(Entry recipe) { - return recipe.toString(); - } + @Override + protected String getRecipeInfo(Entry recipe) { + return recipe.toString(); + } - } + } - @ZenMethod - public static void removeRecipe(IItemStack output) { - LinkedHashMap recipes = new LinkedHashMap(); - for (Entry set : Recipes.centrifuge.getRecipes().entrySet()) { - for (ItemStack stack : set.getValue().items) { - if (stack.isItemEqual(InputHelper.toStack(output))) { - recipes.put(set.getKey(), set.getValue()); - } - } - } - MineTweakerAPI.apply(new Remove(recipes)); - } + @ZenMethod + public static void removeRecipe(IItemStack output) { + LinkedHashMap recipes = new LinkedHashMap(); + for (Entry set : Recipes.centrifuge.getRecipes().entrySet()) { + for (ItemStack stack : set.getValue().items) { + if (stack.isItemEqual(InputHelper.toStack(output))) { + recipes.put(set.getKey(), set.getValue()); + } + } + } + MineTweakerAPI.apply(new Remove(recipes)); + } - private static class Remove extends BaseMapRemoval { + private static class Remove extends BaseMapRemoval { - protected Remove(Map recipes) { - super("Centrifuge", Recipes.centrifuge.getRecipes(), recipes); - } + protected Remove(Map recipes) { + super("Centrifuge", Recipes.centrifuge.getRecipes(), recipes); + } - @Override - protected String getRecipeInfo(Entry recipe) { - return recipe.toString(); - } + @Override + protected String getRecipeInfo(Entry recipe) { + return recipe.toString(); + } - } + } } diff --git a/src/main/java/modtweaker2/mods/ic2c/mods/Compressor.java b/src/main/java/modtweaker2/mods/ic2c/mods/Compressor.java index 8627a23..bb9e9cd 100644 --- a/src/main/java/modtweaker2/mods/ic2c/mods/Compressor.java +++ b/src/main/java/modtweaker2/mods/ic2c/mods/Compressor.java @@ -1,10 +1,5 @@ package modtweaker2.mods.ic2c.mods; -import ic2.api.recipe.IRecipeInput; -import ic2.api.recipe.RecipeInputItemStack; -import ic2.api.recipe.RecipeOutput; -import ic2.api.recipe.Recipes; - import java.util.LinkedHashMap; import java.util.Map; import java.util.Map.Entry; @@ -14,56 +9,62 @@ import minetweaker.api.item.IItemStack; import modtweaker2.helpers.InputHelper; import modtweaker2.utils.BaseMapAddition; import modtweaker2.utils.BaseMapRemoval; + import net.minecraft.item.ItemStack; + import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; +import ic2.api.recipe.IRecipeInput; +import ic2.api.recipe.RecipeInputItemStack; +import ic2.api.recipe.RecipeOutput; +import ic2.api.recipe.Recipes; @ZenClass("mods.ic2classic.Compressor") public class Compressor { - @ZenMethod - public static void addRecipe(IItemStack output, IItemStack input) { - MineTweakerAPI.apply(new Add(InputHelper.toStack(output), InputHelper.toStack(input))); - } + @ZenMethod + public static void addRecipe(IItemStack output, IItemStack input) { + MineTweakerAPI.apply(new Add(InputHelper.toStack(output), InputHelper.toStack(input))); + } - private static class Add extends BaseMapAddition { + private static class Add extends BaseMapAddition { - protected Add(ItemStack output, ItemStack input) { - super("Compressor", Recipes.compressor.getRecipes()); - recipes.put(new RecipeInputItemStack(input), new RecipeOutput(null, output)); - } + protected Add(ItemStack output, ItemStack input) { + super("Compressor", Recipes.compressor.getRecipes()); + recipes.put(new RecipeInputItemStack(input), new RecipeOutput(null, output)); + } - @Override - protected String getRecipeInfo(Entry recipe) { - return recipe.toString(); - } + @Override + protected String getRecipeInfo(Entry recipe) { + return recipe.toString(); + } - } + } - @ZenMethod - public static void removeRecipe(IItemStack output) { - LinkedHashMap recipes = new LinkedHashMap(); - for (Entry set : Recipes.compressor.getRecipes().entrySet()) { - for (ItemStack stack : set.getValue().items) { - if (stack.isItemEqual(InputHelper.toStack(output))) { - recipes.put(set.getKey(), set.getValue()); - } - } - } - MineTweakerAPI.apply(new Remove(recipes)); - } + @ZenMethod + public static void removeRecipe(IItemStack output) { + LinkedHashMap recipes = new LinkedHashMap(); + for (Entry set : Recipes.compressor.getRecipes().entrySet()) { + for (ItemStack stack : set.getValue().items) { + if (stack.isItemEqual(InputHelper.toStack(output))) { + recipes.put(set.getKey(), set.getValue()); + } + } + } + MineTweakerAPI.apply(new Remove(recipes)); + } - private static class Remove extends BaseMapRemoval { + private static class Remove extends BaseMapRemoval { - protected Remove(Map recipes) { - super("Compressor", Recipes.compressor.getRecipes(), recipes); - } + protected Remove(Map recipes) { + super("Compressor", Recipes.compressor.getRecipes(), recipes); + } - @Override - protected String getRecipeInfo(Entry recipe) { - return recipe.toString(); - } + @Override + protected String getRecipeInfo(Entry recipe) { + return recipe.toString(); + } - } + } } diff --git a/src/main/java/modtweaker2/mods/ic2c/mods/Extractor.java b/src/main/java/modtweaker2/mods/ic2c/mods/Extractor.java index f3881a7..3075e47 100644 --- a/src/main/java/modtweaker2/mods/ic2c/mods/Extractor.java +++ b/src/main/java/modtweaker2/mods/ic2c/mods/Extractor.java @@ -1,70 +1,70 @@ package modtweaker2.mods.ic2c.mods; -import ic2.api.recipe.IRecipeInput; -import ic2.api.recipe.RecipeInputItemStack; -import ic2.api.recipe.RecipeOutput; -import ic2.api.recipe.Recipes; - import java.util.LinkedHashMap; import java.util.Map; import java.util.Map.Entry; -import java.util.Set; import minetweaker.MineTweakerAPI; import minetweaker.api.item.IItemStack; import modtweaker2.helpers.InputHelper; import modtweaker2.utils.BaseMapAddition; import modtweaker2.utils.BaseMapRemoval; + import net.minecraft.item.ItemStack; + import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; +import ic2.api.recipe.IRecipeInput; +import ic2.api.recipe.RecipeInputItemStack; +import ic2.api.recipe.RecipeOutput; +import ic2.api.recipe.Recipes; @ZenClass("mods.ic2classic.Extractor") public class Extractor { - @ZenMethod - public static void addRecipe(IItemStack output, IItemStack input) { - MineTweakerAPI.apply(new Add(InputHelper.toStack(output), InputHelper.toStack(input))); - } + @ZenMethod + public static void addRecipe(IItemStack output, IItemStack input) { + MineTweakerAPI.apply(new Add(InputHelper.toStack(output), InputHelper.toStack(input))); + } - private static class Add extends BaseMapAddition { + private static class Add extends BaseMapAddition { - protected Add(ItemStack output, ItemStack input) { - super("Extractor", Recipes.extractor.getRecipes()); - recipes.put(new RecipeInputItemStack(input), new RecipeOutput(null, output)); - } + protected Add(ItemStack output, ItemStack input) { + super("Extractor", Recipes.extractor.getRecipes()); + recipes.put(new RecipeInputItemStack(input), new RecipeOutput(null, output)); + } - @Override - protected String getRecipeInfo(Entry recipe) { - return recipe.toString(); - } + @Override + protected String getRecipeInfo(Entry recipe) { + return recipe.toString(); + } - } + } - @ZenMethod - public static void removeRecipe(IItemStack output) { - LinkedHashMap recipes = new LinkedHashMap(); - for (Entry set : Recipes.extractor.getRecipes().entrySet()) { - for (ItemStack stack : set.getValue().items) { - if (stack.isItemEqual(InputHelper.toStack(output))) { - recipes.put(set.getKey(), set.getValue()); - } - } - } - MineTweakerAPI.apply(new Remove(recipes)); - } + @ZenMethod + public static void removeRecipe(IItemStack output) { + LinkedHashMap recipes = new LinkedHashMap(); + for (Entry set : Recipes.extractor.getRecipes().entrySet()) { + for (ItemStack stack : set.getValue().items) { + if (stack.isItemEqual(InputHelper.toStack(output))) { + recipes.put(set.getKey(), set.getValue()); + } + } + } + MineTweakerAPI.apply(new Remove(recipes)); + } - private static class Remove extends BaseMapRemoval { + private static class Remove extends BaseMapRemoval { - protected Remove(Map recipes) { - super("Extractor", Recipes.extractor.getRecipes(), recipes); - } + protected Remove(Map recipes) { + super("Extractor", Recipes.extractor.getRecipes(), recipes); + } - @Override - protected String getRecipeInfo(Entry recipe) { - return recipe.toString(); - } + @Override + protected String getRecipeInfo(Entry recipe) { + return recipe.toString(); + } - } + } } diff --git a/src/main/java/modtweaker2/mods/ic2c/mods/Macerator.java b/src/main/java/modtweaker2/mods/ic2c/mods/Macerator.java index 2aece42..46d96fb 100644 --- a/src/main/java/modtweaker2/mods/ic2c/mods/Macerator.java +++ b/src/main/java/modtweaker2/mods/ic2c/mods/Macerator.java @@ -1,70 +1,70 @@ package modtweaker2.mods.ic2c.mods; -import ic2.api.recipe.IRecipeInput; -import ic2.api.recipe.RecipeInputItemStack; -import ic2.api.recipe.RecipeOutput; -import ic2.api.recipe.Recipes; - import java.util.LinkedHashMap; import java.util.Map; import java.util.Map.Entry; -import java.util.Set; import minetweaker.MineTweakerAPI; import minetweaker.api.item.IItemStack; import modtweaker2.helpers.InputHelper; import modtweaker2.utils.BaseMapAddition; import modtweaker2.utils.BaseMapRemoval; + import net.minecraft.item.ItemStack; + import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; +import ic2.api.recipe.IRecipeInput; +import ic2.api.recipe.RecipeInputItemStack; +import ic2.api.recipe.RecipeOutput; +import ic2.api.recipe.Recipes; @ZenClass("mods.ic2classic.Macerator") public class Macerator { - @ZenMethod - public static void addRecipe(IItemStack output, IItemStack input) { - MineTweakerAPI.apply(new Add(InputHelper.toStack(output), InputHelper.toStack(input))); - } + @ZenMethod + public static void addRecipe(IItemStack output, IItemStack input) { + MineTweakerAPI.apply(new Add(InputHelper.toStack(output), InputHelper.toStack(input))); + } - private static class Add extends BaseMapAddition { + private static class Add extends BaseMapAddition { - protected Add(ItemStack output, ItemStack input) { - super("Macerator", Recipes.macerator.getRecipes()); - recipes.put(new RecipeInputItemStack(input), new RecipeOutput(null, output)); - } + protected Add(ItemStack output, ItemStack input) { + super("Macerator", Recipes.macerator.getRecipes()); + recipes.put(new RecipeInputItemStack(input), new RecipeOutput(null, output)); + } - @Override - protected String getRecipeInfo(Entry recipe) { - return recipe.toString(); - } + @Override + protected String getRecipeInfo(Entry recipe) { + return recipe.toString(); + } - } + } - @ZenMethod - public static void removeRecipe(IItemStack output) { - LinkedHashMap recipes = new LinkedHashMap(); - for (Entry set : Recipes.macerator.getRecipes().entrySet()) { - for (ItemStack stack : set.getValue().items) { - if (stack.isItemEqual(InputHelper.toStack(output))) { - recipes.put(set.getKey(), set.getValue()); - } - } - } - MineTweakerAPI.apply(new Remove(recipes)); - } + @ZenMethod + public static void removeRecipe(IItemStack output) { + LinkedHashMap recipes = new LinkedHashMap(); + for (Entry set : Recipes.macerator.getRecipes().entrySet()) { + for (ItemStack stack : set.getValue().items) { + if (stack.isItemEqual(InputHelper.toStack(output))) { + recipes.put(set.getKey(), set.getValue()); + } + } + } + MineTweakerAPI.apply(new Remove(recipes)); + } - private static class Remove extends BaseMapRemoval { + private static class Remove extends BaseMapRemoval { - protected Remove(Map recipes) { - super("Macerator", Recipes.macerator.getRecipes(), recipes); - } + protected Remove(Map recipes) { + super("Macerator", Recipes.macerator.getRecipes(), recipes); + } - @Override - protected String getRecipeInfo(Entry recipe) { - return recipe.toString(); - } + @Override + protected String getRecipeInfo(Entry recipe) { + return recipe.toString(); + } - } + } } diff --git a/src/main/java/modtweaker2/mods/ic2c/mods/MetalFormerCutting.java b/src/main/java/modtweaker2/mods/ic2c/mods/MetalFormerCutting.java index ab90ef5..f96534f 100644 --- a/src/main/java/modtweaker2/mods/ic2c/mods/MetalFormerCutting.java +++ b/src/main/java/modtweaker2/mods/ic2c/mods/MetalFormerCutting.java @@ -1,10 +1,5 @@ package modtweaker2.mods.ic2c.mods; -import ic2.api.recipe.IRecipeInput; -import ic2.api.recipe.RecipeInputItemStack; -import ic2.api.recipe.RecipeOutput; -import ic2.api.recipe.Recipes; - import java.util.LinkedHashMap; import java.util.Map; import java.util.Map.Entry; @@ -14,56 +9,62 @@ import minetweaker.api.item.IItemStack; import modtweaker2.helpers.InputHelper; import modtweaker2.utils.BaseMapAddition; import modtweaker2.utils.BaseMapRemoval; + import net.minecraft.item.ItemStack; + import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; +import ic2.api.recipe.IRecipeInput; +import ic2.api.recipe.RecipeInputItemStack; +import ic2.api.recipe.RecipeOutput; +import ic2.api.recipe.Recipes; @ZenClass("mods.ic2classic.MetalFormerCutting") public class MetalFormerCutting { - @ZenMethod - public static void addRecipe(IItemStack output, IItemStack input) { - MineTweakerAPI.apply(new Add(InputHelper.toStack(output), InputHelper.toStack(input))); - } + @ZenMethod + public static void addRecipe(IItemStack output, IItemStack input) { + MineTweakerAPI.apply(new Add(InputHelper.toStack(output), InputHelper.toStack(input))); + } - private static class Add extends BaseMapAddition { + private static class Add extends BaseMapAddition { - protected Add(ItemStack output, ItemStack input) { - super("MetalFormerCutting", Recipes.metalformerCutting.getRecipes()); - recipes.put(new RecipeInputItemStack(input), new RecipeOutput(null, output)); - } + protected Add(ItemStack output, ItemStack input) { + super("MetalFormerCutting", Recipes.metalformerCutting.getRecipes()); + recipes.put(new RecipeInputItemStack(input), new RecipeOutput(null, output)); + } - @Override - protected String getRecipeInfo(Entry recipe) { - return recipe.toString(); - } + @Override + protected String getRecipeInfo(Entry recipe) { + return recipe.toString(); + } - } + } - @ZenMethod - public static void removeRecipe(IItemStack output) { - LinkedHashMap recipes = new LinkedHashMap(); - for (Entry set : Recipes.metalformerCutting.getRecipes().entrySet()) { - for (ItemStack stack : set.getValue().items) { - if (stack.isItemEqual(InputHelper.toStack(output))) { - recipes.put(set.getKey(), set.getValue()); - } - } - } - MineTweakerAPI.apply(new Remove(recipes)); - } + @ZenMethod + public static void removeRecipe(IItemStack output) { + LinkedHashMap recipes = new LinkedHashMap(); + for (Entry set : Recipes.metalformerCutting.getRecipes().entrySet()) { + for (ItemStack stack : set.getValue().items) { + if (stack.isItemEqual(InputHelper.toStack(output))) { + recipes.put(set.getKey(), set.getValue()); + } + } + } + MineTweakerAPI.apply(new Remove(recipes)); + } - private static class Remove extends BaseMapRemoval { + private static class Remove extends BaseMapRemoval { - protected Remove(Map recipes) { - super("MetalFormerCutting", Recipes.metalformerCutting.getRecipes(), recipes); - } + protected Remove(Map recipes) { + super("MetalFormerCutting", Recipes.metalformerCutting.getRecipes(), recipes); + } - @Override - protected String getRecipeInfo(Entry recipe) { - return recipe.toString(); - } + @Override + protected String getRecipeInfo(Entry recipe) { + return recipe.toString(); + } - } + } } diff --git a/src/main/java/modtweaker2/mods/ic2c/mods/MetalFormerExtruding.java b/src/main/java/modtweaker2/mods/ic2c/mods/MetalFormerExtruding.java index d82a5b3..15a9703 100644 --- a/src/main/java/modtweaker2/mods/ic2c/mods/MetalFormerExtruding.java +++ b/src/main/java/modtweaker2/mods/ic2c/mods/MetalFormerExtruding.java @@ -1,10 +1,5 @@ package modtweaker2.mods.ic2c.mods; -import ic2.api.recipe.IRecipeInput; -import ic2.api.recipe.RecipeInputItemStack; -import ic2.api.recipe.RecipeOutput; -import ic2.api.recipe.Recipes; - import java.util.LinkedHashMap; import java.util.Map; import java.util.Map.Entry; @@ -14,56 +9,62 @@ import minetweaker.api.item.IItemStack; import modtweaker2.helpers.InputHelper; import modtweaker2.utils.BaseMapAddition; import modtweaker2.utils.BaseMapRemoval; + import net.minecraft.item.ItemStack; + import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; +import ic2.api.recipe.IRecipeInput; +import ic2.api.recipe.RecipeInputItemStack; +import ic2.api.recipe.RecipeOutput; +import ic2.api.recipe.Recipes; @ZenClass("mods.ic2classic.MetalFormerExtruding") public class MetalFormerExtruding { - @ZenMethod - public static void addRecipe(IItemStack output, IItemStack input) { - MineTweakerAPI.apply(new Add(InputHelper.toStack(output), InputHelper.toStack(input))); - } + @ZenMethod + public static void addRecipe(IItemStack output, IItemStack input) { + MineTweakerAPI.apply(new Add(InputHelper.toStack(output), InputHelper.toStack(input))); + } - private static class Add extends BaseMapAddition { + private static class Add extends BaseMapAddition { - protected Add(ItemStack output, ItemStack input) { - super("MetalFormerExtruding", Recipes.metalformerExtruding.getRecipes()); - recipes.put(new RecipeInputItemStack(input), new RecipeOutput(null, output)); - } + protected Add(ItemStack output, ItemStack input) { + super("MetalFormerExtruding", Recipes.metalformerExtruding.getRecipes()); + recipes.put(new RecipeInputItemStack(input), new RecipeOutput(null, output)); + } - @Override - protected String getRecipeInfo(Entry recipe) { - return recipe.toString(); - } + @Override + protected String getRecipeInfo(Entry recipe) { + return recipe.toString(); + } - } + } - @ZenMethod - public static void removeRecipe(IItemStack output) { - LinkedHashMap recipes = new LinkedHashMap(); - for (Entry set : Recipes.metalformerExtruding.getRecipes().entrySet()) { - for (ItemStack stack : set.getValue().items) { - if (stack.isItemEqual(InputHelper.toStack(output))) { - recipes.put(set.getKey(), set.getValue()); - } - } - } - MineTweakerAPI.apply(new Remove(recipes)); - } + @ZenMethod + public static void removeRecipe(IItemStack output) { + LinkedHashMap recipes = new LinkedHashMap(); + for (Entry set : Recipes.metalformerExtruding.getRecipes().entrySet()) { + for (ItemStack stack : set.getValue().items) { + if (stack.isItemEqual(InputHelper.toStack(output))) { + recipes.put(set.getKey(), set.getValue()); + } + } + } + MineTweakerAPI.apply(new Remove(recipes)); + } - private static class Remove extends BaseMapRemoval { + private static class Remove extends BaseMapRemoval { - protected Remove(Map recipes) { - super("MetalFormerExtruding", Recipes.metalformerExtruding.getRecipes(), recipes); - } + protected Remove(Map recipes) { + super("MetalFormerExtruding", Recipes.metalformerExtruding.getRecipes(), recipes); + } - @Override - protected String getRecipeInfo(Entry recipe) { - return recipe.toString(); - } + @Override + protected String getRecipeInfo(Entry recipe) { + return recipe.toString(); + } - } + } } diff --git a/src/main/java/modtweaker2/mods/ic2c/mods/MetalFormerRolling.java b/src/main/java/modtweaker2/mods/ic2c/mods/MetalFormerRolling.java index 3d26580..ad65a7f 100644 --- a/src/main/java/modtweaker2/mods/ic2c/mods/MetalFormerRolling.java +++ b/src/main/java/modtweaker2/mods/ic2c/mods/MetalFormerRolling.java @@ -1,10 +1,5 @@ package modtweaker2.mods.ic2c.mods; -import ic2.api.recipe.IRecipeInput; -import ic2.api.recipe.RecipeInputItemStack; -import ic2.api.recipe.RecipeOutput; -import ic2.api.recipe.Recipes; - import java.util.LinkedHashMap; import java.util.Map; import java.util.Map.Entry; @@ -14,56 +9,62 @@ import minetweaker.api.item.IItemStack; import modtweaker2.helpers.InputHelper; import modtweaker2.utils.BaseMapAddition; import modtweaker2.utils.BaseMapRemoval; + import net.minecraft.item.ItemStack; + import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; +import ic2.api.recipe.IRecipeInput; +import ic2.api.recipe.RecipeInputItemStack; +import ic2.api.recipe.RecipeOutput; +import ic2.api.recipe.Recipes; @ZenClass("mods.ic2classic.MetalFormerRolling") public class MetalFormerRolling { - @ZenMethod - public static void addRecipe(IItemStack output, IItemStack input) { - MineTweakerAPI.apply(new Add(InputHelper.toStack(output), InputHelper.toStack(input))); - } + @ZenMethod + public static void addRecipe(IItemStack output, IItemStack input) { + MineTweakerAPI.apply(new Add(InputHelper.toStack(output), InputHelper.toStack(input))); + } - private static class Add extends BaseMapAddition { + private static class Add extends BaseMapAddition { - protected Add(ItemStack output, ItemStack input) { - super("MetalFormerRolling", Recipes.metalformerRolling.getRecipes()); - recipes.put(new RecipeInputItemStack(input), new RecipeOutput(null, output)); - } + protected Add(ItemStack output, ItemStack input) { + super("MetalFormerRolling", Recipes.metalformerRolling.getRecipes()); + recipes.put(new RecipeInputItemStack(input), new RecipeOutput(null, output)); + } - @Override - protected String getRecipeInfo(Entry recipe) { - return recipe.toString(); - } + @Override + protected String getRecipeInfo(Entry recipe) { + return recipe.toString(); + } - } + } - @ZenMethod - public static void removeRecipe(IItemStack output) { - LinkedHashMap recipes = new LinkedHashMap(); - for (Entry set : Recipes.metalformerRolling.getRecipes().entrySet()) { - for (ItemStack stack : set.getValue().items) { - if (stack.isItemEqual(InputHelper.toStack(output))) { - recipes.put(set.getKey(), set.getValue()); - } - } - } - MineTweakerAPI.apply(new Remove(recipes)); - } + @ZenMethod + public static void removeRecipe(IItemStack output) { + LinkedHashMap recipes = new LinkedHashMap(); + for (Entry set : Recipes.metalformerRolling.getRecipes().entrySet()) { + for (ItemStack stack : set.getValue().items) { + if (stack.isItemEqual(InputHelper.toStack(output))) { + recipes.put(set.getKey(), set.getValue()); + } + } + } + MineTweakerAPI.apply(new Remove(recipes)); + } - private static class Remove extends BaseMapRemoval { + private static class Remove extends BaseMapRemoval { - protected Remove(Map recipes) { - super("MetalFormerRolling", Recipes.metalformerRolling.getRecipes(), recipes); - } + protected Remove(Map recipes) { + super("MetalFormerRolling", Recipes.metalformerRolling.getRecipes(), recipes); + } - @Override - protected String getRecipeInfo(Entry recipe) { - return recipe.toString(); - } + @Override + protected String getRecipeInfo(Entry recipe) { + return recipe.toString(); + } - } + } } diff --git a/src/main/java/modtweaker2/mods/ic2c/mods/OreWashing.java b/src/main/java/modtweaker2/mods/ic2c/mods/OreWashing.java index 09e5700..bca1663 100644 --- a/src/main/java/modtweaker2/mods/ic2c/mods/OreWashing.java +++ b/src/main/java/modtweaker2/mods/ic2c/mods/OreWashing.java @@ -1,10 +1,5 @@ package modtweaker2.mods.ic2c.mods; -import ic2.api.recipe.IRecipeInput; -import ic2.api.recipe.RecipeInputItemStack; -import ic2.api.recipe.RecipeOutput; -import ic2.api.recipe.Recipes; - import java.util.LinkedHashMap; import java.util.Map; import java.util.Map.Entry; @@ -14,56 +9,62 @@ import minetweaker.api.item.IItemStack; import modtweaker2.helpers.InputHelper; import modtweaker2.utils.BaseMapAddition; import modtweaker2.utils.BaseMapRemoval; + import net.minecraft.item.ItemStack; + import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; +import ic2.api.recipe.IRecipeInput; +import ic2.api.recipe.RecipeInputItemStack; +import ic2.api.recipe.RecipeOutput; +import ic2.api.recipe.Recipes; @ZenClass("mods.ic2classic.OreWashing") public class OreWashing { - @ZenMethod - public static void addRecipe(IItemStack output, IItemStack input) { - MineTweakerAPI.apply(new Add(InputHelper.toStack(output), InputHelper.toStack(input))); - } + @ZenMethod + public static void addRecipe(IItemStack output, IItemStack input) { + MineTweakerAPI.apply(new Add(InputHelper.toStack(output), InputHelper.toStack(input))); + } - private static class Add extends BaseMapAddition { + private static class Add extends BaseMapAddition { - protected Add(ItemStack output, ItemStack input) { - super("OreWashing", Recipes.oreWashing.getRecipes()); - recipes.put(new RecipeInputItemStack(input), new RecipeOutput(null, output)); - } + protected Add(ItemStack output, ItemStack input) { + super("OreWashing", Recipes.oreWashing.getRecipes()); + recipes.put(new RecipeInputItemStack(input), new RecipeOutput(null, output)); + } - @Override - protected String getRecipeInfo(Entry recipe) { - return recipe.toString(); - } + @Override + protected String getRecipeInfo(Entry recipe) { + return recipe.toString(); + } - } + } - @ZenMethod - public static void removeRecipe(IItemStack output) { - LinkedHashMap recipes = new LinkedHashMap(); - for (Entry set : Recipes.oreWashing.getRecipes().entrySet()) { - for (ItemStack stack : set.getValue().items) { - if (stack.isItemEqual(InputHelper.toStack(output))) { - recipes.put(set.getKey(), set.getValue()); - } - } - } - MineTweakerAPI.apply(new Remove(recipes)); - } + @ZenMethod + public static void removeRecipe(IItemStack output) { + LinkedHashMap recipes = new LinkedHashMap(); + for (Entry set : Recipes.oreWashing.getRecipes().entrySet()) { + for (ItemStack stack : set.getValue().items) { + if (stack.isItemEqual(InputHelper.toStack(output))) { + recipes.put(set.getKey(), set.getValue()); + } + } + } + MineTweakerAPI.apply(new Remove(recipes)); + } - private static class Remove extends BaseMapRemoval { + private static class Remove extends BaseMapRemoval { - protected Remove(Map recipes) { - super("OreWashing", Recipes.oreWashing.getRecipes(), recipes); - } + protected Remove(Map recipes) { + super("OreWashing", Recipes.oreWashing.getRecipes(), recipes); + } - @Override - protected String getRecipeInfo(Entry recipe) { - return recipe.toString(); - } + @Override + protected String getRecipeInfo(Entry recipe) { + return recipe.toString(); + } - } + } } diff --git a/src/main/java/modtweaker2/mods/ic2c/mods/Recycler.java b/src/main/java/modtweaker2/mods/ic2c/mods/Recycler.java index d109e0d..de9b353 100644 --- a/src/main/java/modtweaker2/mods/ic2c/mods/Recycler.java +++ b/src/main/java/modtweaker2/mods/ic2c/mods/Recycler.java @@ -1,10 +1,5 @@ package modtweaker2.mods.ic2c.mods; -import ic2.api.recipe.IRecipeInput; -import ic2.api.recipe.RecipeInputItemStack; -import ic2.api.recipe.RecipeOutput; -import ic2.api.recipe.Recipes; - import java.util.LinkedHashMap; import java.util.Map; import java.util.Map.Entry; @@ -14,56 +9,62 @@ import minetweaker.api.item.IItemStack; import modtweaker2.helpers.InputHelper; import modtweaker2.utils.BaseMapAddition; import modtweaker2.utils.BaseMapRemoval; + import net.minecraft.item.ItemStack; + import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; +import ic2.api.recipe.IRecipeInput; +import ic2.api.recipe.RecipeInputItemStack; +import ic2.api.recipe.RecipeOutput; +import ic2.api.recipe.Recipes; @ZenClass("mods.ic2classic.Recycler") public class Recycler { - @ZenMethod - public static void addRecipe(IItemStack output, IItemStack input) { - MineTweakerAPI.apply(new Add(InputHelper.toStack(output), InputHelper.toStack(input))); - } + @ZenMethod + public static void addRecipe(IItemStack output, IItemStack input) { + MineTweakerAPI.apply(new Add(InputHelper.toStack(output), InputHelper.toStack(input))); + } - private static class Add extends BaseMapAddition { + private static class Add extends BaseMapAddition { - protected Add(ItemStack output, ItemStack input) { - super("Recycler", Recipes.recycler.getRecipes()); - recipes.put(new RecipeInputItemStack(input), new RecipeOutput(null, output)); - } + protected Add(ItemStack output, ItemStack input) { + super("Recycler", Recipes.recycler.getRecipes()); + recipes.put(new RecipeInputItemStack(input), new RecipeOutput(null, output)); + } - @Override - protected String getRecipeInfo(Entry recipe) { - return recipe.toString(); - } + @Override + protected String getRecipeInfo(Entry recipe) { + return recipe.toString(); + } - } + } - @ZenMethod - public static void removeRecipe(IItemStack output) { - LinkedHashMap recipes = new LinkedHashMap(); - for (Entry set : Recipes.recycler.getRecipes().entrySet()) { - for (ItemStack stack : set.getValue().items) { - if (stack.isItemEqual(InputHelper.toStack(output))) { - recipes.put(set.getKey(), set.getValue()); - } - } - } - MineTweakerAPI.apply(new Remove(recipes)); - } + @ZenMethod + public static void removeRecipe(IItemStack output) { + LinkedHashMap recipes = new LinkedHashMap(); + for (Entry set : Recipes.recycler.getRecipes().entrySet()) { + for (ItemStack stack : set.getValue().items) { + if (stack.isItemEqual(InputHelper.toStack(output))) { + recipes.put(set.getKey(), set.getValue()); + } + } + } + MineTweakerAPI.apply(new Remove(recipes)); + } - private static class Remove extends BaseMapRemoval { + private static class Remove extends BaseMapRemoval { - protected Remove(Map recipes) { - super("Recycler", Recipes.recycler.getRecipes(), recipes); - } + protected Remove(Map recipes) { + super("Recycler", Recipes.recycler.getRecipes(), recipes); + } - @Override - protected String getRecipeInfo(Entry recipe) { - return recipe.toString(); - } + @Override + protected String getRecipeInfo(Entry recipe) { + return recipe.toString(); + } - } + } } diff --git a/src/main/java/modtweaker2/mods/mariculture/Mariculture.java b/src/main/java/modtweaker2/mods/mariculture/Mariculture.java index 5e53e2a..5eb4cb5 100644 --- a/src/main/java/modtweaker2/mods/mariculture/Mariculture.java +++ b/src/main/java/modtweaker2/mods/mariculture/Mariculture.java @@ -8,6 +8,7 @@ import modtweaker2.mods.mariculture.handlers.Fishing; import modtweaker2.mods.mariculture.handlers.Vat; public class Mariculture { + public Mariculture() { MineTweakerAPI.registerClass(Anvil.class); MineTweakerAPI.registerClass(Casting.class); diff --git a/src/main/java/modtweaker2/mods/mariculture/MaricultureHelper.java b/src/main/java/modtweaker2/mods/mariculture/MaricultureHelper.java index 2db7fd3..1cee99c 100644 --- a/src/main/java/modtweaker2/mods/mariculture/MaricultureHelper.java +++ b/src/main/java/modtweaker2/mods/mariculture/MaricultureHelper.java @@ -10,12 +10,14 @@ import mariculture.api.fishery.Fishing; import mariculture.api.fishery.Loot; import mariculture.api.fishery.Loot.Rarity; import modtweaker2.helpers.ReflectionHelper; + import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; public class MaricultureHelper { + public static Map fuels = null; public static HashMap> loot = null; diff --git a/src/main/java/modtweaker2/mods/mariculture/handlers/Anvil.java b/src/main/java/modtweaker2/mods/mariculture/handlers/Anvil.java index 29680ef..87c9840 100644 --- a/src/main/java/modtweaker2/mods/mariculture/handlers/Anvil.java +++ b/src/main/java/modtweaker2/mods/mariculture/handlers/Anvil.java @@ -22,9 +22,9 @@ import stanhebben.zenscript.annotations.ZenMethod; @ZenClass("mods.mariculture.Anvil") public class Anvil { - + public static final String name = "Mariculture Anvil"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @ZenMethod @@ -33,6 +33,7 @@ public class Anvil { } private static class Add extends BaseMapAddition { + public Add(RecipeAnvil recipe) { super("Mariculture Anvil", MaricultureHandlers.anvil.getRecipes()); recipes.put(MaricultureHelper.getKey(recipe.input), recipe); @@ -46,25 +47,29 @@ public class Anvil { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //Removing a Mariculture Anvil recipe + // Removing a Mariculture Anvil recipe @ZenMethod public static void removeRecipe(IIngredient input) { Map recipes = new HashMap(); - - for(Entry recipe : MaricultureHandlers.anvil.getRecipes().entrySet()) { - if(recipe != null && recipe.getValue() != null && recipe.getValue().input != null && matches(input, toIItemStack(recipe.getValue().input))) { + + for (Entry recipe : MaricultureHandlers.anvil.getRecipes().entrySet()) { + if (recipe != null && recipe.getValue() != null + && recipe.getValue().input != null + && matches(input, toIItemStack(recipe.getValue().input))) { recipes.put(recipe.getKey(), recipe.getValue()); } } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new Remove(recipes)); } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Anvil.name, input.toString())); + LogHelper.logWarning( + String.format("No %s Recipe found for %s. Command ignored!", Anvil.name, input.toString())); } } private static class Remove extends BaseMapRemoval { + public Remove(Map recipes) { super("Mariculture Anvil", MaricultureHandlers.anvil.getRecipes(), recipes); } diff --git a/src/main/java/modtweaker2/mods/mariculture/handlers/Casting.java b/src/main/java/modtweaker2/mods/mariculture/handlers/Casting.java index 091dd31..e502278 100644 --- a/src/main/java/modtweaker2/mods/mariculture/handlers/Casting.java +++ b/src/main/java/modtweaker2/mods/mariculture/handlers/Casting.java @@ -26,27 +26,37 @@ import stanhebben.zenscript.annotations.ZenMethod; @ZenClass("mods.mariculture.Casting") public class Casting { - + public static final String name = "Mariculture Casting"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @ZenMethod public static void addNuggetRecipe(ILiquidStack input, IItemStack output) { - MineTweakerAPI.apply(new Add(new RecipeNuggetCasting(toFluid(input), toStack(output)), MaricultureHandlers.casting.getNuggetRecipes())); + MineTweakerAPI.apply( + new Add( + new RecipeNuggetCasting(toFluid(input), toStack(output)), + MaricultureHandlers.casting.getNuggetRecipes())); } @ZenMethod public static void addIngotRecipe(ILiquidStack input, IItemStack output) { - MineTweakerAPI.apply(new Add(new RecipeNuggetCasting(toFluid(input), toStack(output)), MaricultureHandlers.casting.getIngotRecipes())); + MineTweakerAPI.apply( + new Add( + new RecipeNuggetCasting(toFluid(input), toStack(output)), + MaricultureHandlers.casting.getIngotRecipes())); } @ZenMethod public static void addBlockRecipe(ILiquidStack input, IItemStack output) { - MineTweakerAPI.apply(new Add(new RecipeNuggetCasting(toFluid(input), toStack(output)), MaricultureHandlers.casting.getBlockRecipes())); + MineTweakerAPI.apply( + new Add( + new RecipeNuggetCasting(toFluid(input), toStack(output)), + MaricultureHandlers.casting.getBlockRecipes())); } private static class Add extends BaseMapAddition { + public Add(RecipeCasting recipe, HashMap map) { super(Casting.name, map); recipes.put(MaricultureHelper.getKey(recipe.fluid), recipe); @@ -74,28 +84,29 @@ public class Casting { public static void removeBlockRecipe(IIngredient ingredient) { removeRecipe(ingredient, MaricultureHandlers.casting.getBlockRecipes()); } - + public static void removeRecipe(IIngredient ingredient, HashMap map) { Map recipes = new HashMap(); - - for(Entry recipe : map.entrySet()) { - if(recipe != null && recipe.getValue() != null) { - if(recipe.getValue().fluid != null && matches(ingredient, toILiquidStack(recipe.getValue().fluid))) { + + for (Entry recipe : map.entrySet()) { + if (recipe != null && recipe.getValue() != null) { + if (recipe.getValue().fluid != null && matches(ingredient, toILiquidStack(recipe.getValue().fluid))) { recipes.put(recipe.getKey(), recipe.getValue()); } - - if(recipe.getValue().output != null && matches(ingredient, toIItemStack(recipe.getValue().output))) { + + if (recipe.getValue().output != null && matches(ingredient, toIItemStack(recipe.getValue().output))) { recipes.put(recipe.getKey(), recipe.getValue()); } } } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new Remove(map, recipes)); } } private static class Remove extends BaseMapRemoval { + public Remove(Map map, Map recipes) { super(Casting.name, map, recipes); } diff --git a/src/main/java/modtweaker2/mods/mariculture/handlers/Crucible.java b/src/main/java/modtweaker2/mods/mariculture/handlers/Crucible.java index a11a738..066deb1 100644 --- a/src/main/java/modtweaker2/mods/mariculture/handlers/Crucible.java +++ b/src/main/java/modtweaker2/mods/mariculture/handlers/Crucible.java @@ -24,46 +24,52 @@ import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; import modtweaker2.utils.BaseMapAddition; import modtweaker2.utils.BaseMapRemoval; + import net.minecraft.item.ItemStack; + import stanhebben.zenscript.annotations.Optional; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; @ZenClass("mods.mariculture.Crucible") public class Crucible { - + public static final String nameSmelting = "Mariculture Crucible (Smelting)"; public static final String nameFuel = "Mariculture Crucible (Fuel)"; - /********************************************** Mariculture Crucible Recipes **********************************************/ + /********************************************** + * Mariculture Crucible Recipes + **********************************************/ - // Adding a Mariculture Crucible recipe - @ZenMethod - public static void addRecipe(int temp, IItemStack input, ILiquidStack fluid, @Optional IItemStack output, @Optional int chance) { - ItemStack out = output != null ? toStack(output) : null; - MineTweakerAPI.apply(new AddRecipe(new RecipeSmelter(toStack(input), null, temp, toFluid(fluid), out, chance))); - } + // Adding a Mariculture Crucible recipe + @ZenMethod + public static void addRecipe(int temp, IItemStack input, ILiquidStack fluid, @Optional IItemStack output, + @Optional int chance) { + ItemStack out = output != null ? toStack(output) : null; + MineTweakerAPI.apply(new AddRecipe(new RecipeSmelter(toStack(input), null, temp, toFluid(fluid), out, chance))); + } - // Passes the list to the base list implementation, and adds the recipe - private static class AddRecipe extends BaseListAddition { - public AddRecipe(RecipeSmelter recipe) { - super(Crucible.nameSmelting, MaricultureHandlers.crucible.getRecipes()); - recipes.add(recipe); - } + // Passes the list to the base list implementation, and adds the recipe + private static class AddRecipe extends BaseListAddition { - @Override - public String getRecipeInfo(RecipeSmelter recipe) { - return LogHelper.getStackDescription(recipe.input); - } - } + public AddRecipe(RecipeSmelter recipe) { + super(Crucible.nameSmelting, MaricultureHandlers.crucible.getRecipes()); + recipes.add(recipe); + } - // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + @Override + public String getRecipeInfo(RecipeSmelter recipe) { + return LogHelper.getStackDescription(recipe.input); + } + } + + // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // Removing a Mariculture Crucible recipe + @ZenMethod + public static void removeRecipe(IIngredient input) { + List recipes = new LinkedList(); - // Removing a Mariculture Crucible recipe - @ZenMethod - public static void removeRecipe(IIngredient input) { - List recipes = new LinkedList(); - for (RecipeSmelter r : MaricultureHandlers.crucible.getRecipes()) { if (r != null) { if (r.input != null && matches(input, toIItemStack(r.input))) { @@ -71,95 +77,102 @@ public class Crucible { } } } - - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new RemoveRecipe(recipes)); - } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored", Crucible.nameSmelting, input.toString())); - } - - } - private static class RemoveRecipe extends BaseListRemoval { - public RemoveRecipe(List recipes) { - super(Crucible.nameSmelting, MaricultureHandlers.crucible.getRecipes(), recipes); - } - + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new RemoveRecipe(recipes)); + } else { + LogHelper.logWarning( + String.format( + "No %s Recipe found for %s. Command ignored", + Crucible.nameSmelting, + input.toString())); + } + + } + + private static class RemoveRecipe extends BaseListRemoval { + + public RemoveRecipe(List recipes) { + super(Crucible.nameSmelting, MaricultureHandlers.crucible.getRecipes(), recipes); + } + @Override public String getRecipeInfo(RecipeSmelter recipe) { return LogHelper.getStackDescription(recipe.input); } - } + } - /********************************************** Crucible Fuels **********************************************/ - @ZenMethod - public static void addFuel(IItemStack input, int max, int per, int time) { - MineTweakerAPI.apply(new AddFuel(toStack(input), new FuelInfo(max, per, time))); - } + /********************************************** Crucible Fuels **********************************************/ + @ZenMethod + public static void addFuel(IItemStack input, int max, int per, int time) { + MineTweakerAPI.apply(new AddFuel(toStack(input), new FuelInfo(max, per, time))); + } - @ZenMethod - public static void addFuel(ILiquidStack input, int max, int per, int time) { - MineTweakerAPI.apply(new AddFuel(toFluid(input), new FuelInfo(max, per, time))); - } + @ZenMethod + public static void addFuel(ILiquidStack input, int max, int per, int time) { + MineTweakerAPI.apply(new AddFuel(toFluid(input), new FuelInfo(max, per, time))); + } - @ZenMethod - public static void addFuel(String input, int max, int per, int time) { - MineTweakerAPI.apply(new AddFuel(input, new FuelInfo(max, per, time))); - } + @ZenMethod + public static void addFuel(String input, int max, int per, int time) { + MineTweakerAPI.apply(new AddFuel(input, new FuelInfo(max, per, time))); + } - // Passes the list to the base map implementation, and adds the recipe - private static class AddFuel extends BaseMapAddition { - public AddFuel(Object o, FuelInfo info) { - super(Crucible.nameFuel, MaricultureHelper.fuels); - recipes.put(MaricultureHelper.getKey(o), info); - } + // Passes the list to the base map implementation, and adds the recipe + private static class AddFuel extends BaseMapAddition { + + public AddFuel(Object o, FuelInfo info) { + super(Crucible.nameFuel, MaricultureHelper.fuels); + recipes.put(MaricultureHelper.getKey(o), info); + } @Override public String getRecipeInfo(Entry recipe) { return (String) recipe.getKey(); } - } + } - // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - @ZenMethod - public static void removeFuel(IItemStack fuel) { - removeFuelEntry(fuel); - } + // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + @ZenMethod + public static void removeFuel(IItemStack fuel) { + removeFuelEntry(fuel); + } - @ZenMethod - public static void removeFuel(ILiquidStack fuel) { - removeFuelEntry(fuel); - } + @ZenMethod + public static void removeFuel(ILiquidStack fuel) { + removeFuelEntry(fuel); + } - @ZenMethod - public static void removeFuel(String fuel) { - removeFuelEntry(fuel); - } - - public static void removeFuelEntry(Object o) { - String key = MaricultureHelper.getKey(o); - Map recipes = new HashMap(); - - for(Entry entry : MaricultureHelper.fuels.entrySet()) { - if(key.matches((String)entry.getKey())) { - recipes.put(key, entry.getValue()); - } - } - - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new RemoveFuel(recipes)); - } - } + @ZenMethod + public static void removeFuel(String fuel) { + removeFuelEntry(fuel); + } - // Removes a recipe, will always remove the key, so all should be good - private static class RemoveFuel extends BaseMapRemoval { - public RemoveFuel(Map recipes) { - super(Crucible.nameFuel, MaricultureHelper.fuels, recipes); - } + public static void removeFuelEntry(Object o) { + String key = MaricultureHelper.getKey(o); + Map recipes = new HashMap(); + + for (Entry entry : MaricultureHelper.fuels.entrySet()) { + if (key.matches((String) entry.getKey())) { + recipes.put(key, entry.getValue()); + } + } + + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new RemoveFuel(recipes)); + } + } + + // Removes a recipe, will always remove the key, so all should be good + private static class RemoveFuel extends BaseMapRemoval { + + public RemoveFuel(Map recipes) { + super(Crucible.nameFuel, MaricultureHelper.fuels, recipes); + } @Override public String getRecipeInfo(Entry recipe) { return (String) recipe.getKey(); } - } + } } diff --git a/src/main/java/modtweaker2/mods/mariculture/handlers/Fishing.java b/src/main/java/modtweaker2/mods/mariculture/handlers/Fishing.java index 6d1a749..7cba483 100644 --- a/src/main/java/modtweaker2/mods/mariculture/handlers/Fishing.java +++ b/src/main/java/modtweaker2/mods/mariculture/handlers/Fishing.java @@ -15,7 +15,9 @@ import minetweaker.api.item.IItemStack; import modtweaker2.helpers.ReflectionHelper; import modtweaker2.mods.mariculture.MaricultureHelper; import modtweaker2.utils.BaseUndoable; + import net.minecraft.item.ItemStack; + import stanhebben.zenscript.annotations.Optional; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; @@ -23,7 +25,8 @@ import cpw.mods.fml.common.Loader; @ZenClass("mods.mariculture.Fishing") public class Fishing { - //HashMap Helper for converting strings to rodtypes, (will personally add a registry to mariculture eventually...) + + // HashMap Helper for converting strings to rodtypes, (will personally add a registry to mariculture eventually...) public static HashMap rodTypes = new HashMap(); static { @@ -35,38 +38,47 @@ public class Fishing { rodTypes.put("flux", RodType.FLUX); if (Loader.isModLoaded("AWWayofTime")) { try { - rodTypes.put("blood", (RodType) ReflectionHelper.getStaticObject(Class.forName("mariculture.plugins.PluginBloodMagic"), "BLOOD")); + rodTypes.put( + "blood", + (RodType) ReflectionHelper + .getStaticObject(Class.forName("mariculture.plugins.PluginBloodMagic"), "BLOOD")); } catch (ClassNotFoundException e) { e.printStackTrace(); } } } - //Adding Fishing Loot + // Adding Fishing Loot @ZenMethod - public static void addJunk(IItemStack loot, double chance, @Optional String type, @Optional boolean exact, @Optional int[] dimension) { + public static void addJunk(IItemStack loot, double chance, @Optional String type, @Optional boolean exact, + @Optional int[] dimension) { addLoot(toStack(loot), chance, type, exact, dimension, Rarity.JUNK); } @ZenMethod - public static void addGood(IItemStack loot, double chance, @Optional String type, @Optional boolean exact, @Optional int[] dimension) { + public static void addGood(IItemStack loot, double chance, @Optional String type, @Optional boolean exact, + @Optional int[] dimension) { addLoot(toStack(loot), chance, type, exact, dimension, Rarity.GOOD); } @ZenMethod - public static void addRare(IItemStack loot, double chance, @Optional String type, @Optional boolean exact, @Optional int[] dimension) { + public static void addRare(IItemStack loot, double chance, @Optional String type, @Optional boolean exact, + @Optional int[] dimension) { addLoot(toStack(loot), chance, type, exact, dimension, Rarity.RARE); } - private static void addLoot(ItemStack stack, double chance, String type, boolean exact, int[] dimension, Rarity rarity) { + private static void addLoot(ItemStack stack, double chance, String type, boolean exact, int[] dimension, + Rarity rarity) { if (dimension == null || dimension.length == 0) dimension = new int[] { Short.MAX_VALUE }; if (type == null) type = "dire"; for (int dim : dimension) { - MineTweakerAPI.apply(new AddLoot(new Loot(stack, chance, rarity, dim, rodTypes.get(type), exact), rarity.name())); + MineTweakerAPI + .apply(new AddLoot(new Loot(stack, chance, rarity, dim, rodTypes.get(type), exact), rarity.name())); } } private static class AddLoot extends BaseUndoable { + private final Loot loot; public AddLoot(Loot loot, String description) { @@ -97,13 +109,14 @@ public class Fishing { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //Removing Fishing Loot, will remove it from every single list + // Removing Fishing Loot, will remove it from every single list @ZenMethod public static void removeLoot(IItemStack loot) { MineTweakerAPI.apply(new RemoveLoot(toStack(loot))); } private static class RemoveLoot extends BaseUndoable { + private HashMap loot; private final ItemStack stack; @@ -122,7 +135,7 @@ public class Fishing { success = true; } - //Performs the apply function on all rarity types + // Performs the apply function on all rarity types public void apply(Rarity rarity) { ArrayList list = MaricultureHelper.loot.get(rarity); int preSize = list.size(); @@ -145,7 +158,7 @@ public class Fishing { } } - //Undoes the action on the applicable rarities + // Undoes the action on the applicable rarities public void undo(Rarity rarity, Loot l) { ArrayList list = MaricultureHelper.loot.get(rarity); list.add(l); diff --git a/src/main/java/modtweaker2/mods/mariculture/handlers/Vat.java b/src/main/java/modtweaker2/mods/mariculture/handlers/Vat.java index fa43000..e987c29 100644 --- a/src/main/java/modtweaker2/mods/mariculture/handlers/Vat.java +++ b/src/main/java/modtweaker2/mods/mariculture/handlers/Vat.java @@ -23,103 +23,117 @@ import stanhebben.zenscript.annotations.ZenMethod; @ZenClass("mods.mariculture.Vat") public class Vat { - + public static final String name = "Mariculture Vat"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - // Adding a Mariculture Vat recipe - @ZenMethod - public static void addRecipe(ILiquidStack fluid1, ILiquidStack fluid2, ILiquidStack outputFluid, int time) { - addRecipe(fluid1, fluid2, null, outputFluid, null, time); - } - @ZenMethod - public static void addRecipe(ILiquidStack fluid1, ILiquidStack fluid2, IItemStack outputItem, int time) { - addRecipe(fluid1, fluid2, null, null, outputItem, time); - } + // Adding a Mariculture Vat recipe + @ZenMethod + public static void addRecipe(ILiquidStack fluid1, ILiquidStack fluid2, ILiquidStack outputFluid, int time) { + addRecipe(fluid1, fluid2, null, outputFluid, null, time); + } - @ZenMethod - public static void addRecipe(ILiquidStack fluid1, ILiquidStack fluid2, ILiquidStack outputFluid, IItemStack outputItem, int time) { - addRecipe(fluid1, fluid2, null, outputFluid, outputItem, time); - } + @ZenMethod + public static void addRecipe(ILiquidStack fluid1, ILiquidStack fluid2, IItemStack outputItem, int time) { + addRecipe(fluid1, fluid2, null, null, outputItem, time); + } - @ZenMethod - public static void addRecipe(ILiquidStack fluid1, IItemStack input, ILiquidStack outputFluid, int time) { - addRecipe(fluid1, null, input, outputFluid, null, time); - } + @ZenMethod + public static void addRecipe(ILiquidStack fluid1, ILiquidStack fluid2, ILiquidStack outputFluid, + IItemStack outputItem, int time) { + addRecipe(fluid1, fluid2, null, outputFluid, outputItem, time); + } - @ZenMethod - public static void addRecipe(ILiquidStack fluid1, IItemStack input, IItemStack outputItem, int time) { - addRecipe(fluid1, null, input, null, outputItem, time); - } + @ZenMethod + public static void addRecipe(ILiquidStack fluid1, IItemStack input, ILiquidStack outputFluid, int time) { + addRecipe(fluid1, null, input, outputFluid, null, time); + } - @ZenMethod - public static void addRecipe(ILiquidStack fluid1, IItemStack input, ILiquidStack outputFluid, IItemStack outputItem, int time) { - addRecipe(fluid1, null, input, outputFluid, outputItem, time); - } + @ZenMethod + public static void addRecipe(ILiquidStack fluid1, IItemStack input, IItemStack outputItem, int time) { + addRecipe(fluid1, null, input, null, outputItem, time); + } - @ZenMethod - public static void addRecipe(ILiquidStack fluid1, ILiquidStack fluid2, IItemStack input, ILiquidStack outputFluid, int time) { - addRecipe(fluid1, fluid2, input, outputFluid, null, time); - } + @ZenMethod + public static void addRecipe(ILiquidStack fluid1, IItemStack input, ILiquidStack outputFluid, IItemStack outputItem, + int time) { + addRecipe(fluid1, null, input, outputFluid, outputItem, time); + } - @ZenMethod - public static void addRecipe(ILiquidStack fluid1, ILiquidStack fluid2, IItemStack input, IItemStack outputItem, int time) { - addRecipe(fluid1, fluid2, input, null, outputItem, time); - } + @ZenMethod + public static void addRecipe(ILiquidStack fluid1, ILiquidStack fluid2, IItemStack input, ILiquidStack outputFluid, + int time) { + addRecipe(fluid1, fluid2, input, outputFluid, null, time); + } - @ZenMethod - public static void addRecipe(ILiquidStack fluid1, ILiquidStack fluid2, IItemStack input, ILiquidStack outputFluid, IItemStack outputItem, int time) { - MineTweakerAPI.apply(new Add(new RecipeVat(toStack(input), toFluid(fluid1), toFluid(fluid2), toFluid(outputFluid), toStack(outputItem), time))); - } + @ZenMethod + public static void addRecipe(ILiquidStack fluid1, ILiquidStack fluid2, IItemStack input, IItemStack outputItem, + int time) { + addRecipe(fluid1, fluid2, input, null, outputItem, time); + } - // Passes the list to the base list implementation, and adds the recipe - private static class Add extends BaseListAddition { - public Add(RecipeVat recipe) { - super("Mariculture Vat", MaricultureHandlers.vat.getRecipes()); - recipes.add(recipe); - } + @ZenMethod + public static void addRecipe(ILiquidStack fluid1, ILiquidStack fluid2, IItemStack input, ILiquidStack outputFluid, + IItemStack outputItem, int time) { + MineTweakerAPI.apply( + new Add( + new RecipeVat( + toStack(input), + toFluid(fluid1), + toFluid(fluid2), + toFluid(outputFluid), + toStack(outputItem), + time))); + } - @Override - public String getRecipeInfo(RecipeVat recipe) { - if(recipe.outputItem != null) { - return LogHelper.getStackDescription(recipe.outputItem); - } else { - return LogHelper.getStackDescription(recipe.outputFluid); - } - } - } + // Passes the list to the base list implementation, and adds the recipe + private static class Add extends BaseListAddition { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + public Add(RecipeVat recipe) { + super("Mariculture Vat", MaricultureHandlers.vat.getRecipes()); + recipes.add(recipe); + } - // Removing a Mariculture Vat recipe - @ZenMethod - public static void removeRecipe(IIngredient ingredient) { - List recipes = new LinkedList(); - - for(RecipeVat r : MaricultureHandlers.vat.getRecipes()) { - if(r != null) { - if(r.outputItem != null && matches(ingredient, toIItemStack(r.outputItem))) { - recipes.add(r); - } - else if(r.outputFluid != null && matches(ingredient, toILiquidStack(r.outputFluid))) { + @Override + public String getRecipeInfo(RecipeVat recipe) { + if (recipe.outputItem != null) { + return LogHelper.getStackDescription(recipe.outputItem); + } else { + return LogHelper.getStackDescription(recipe.outputFluid); + } + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // Removing a Mariculture Vat recipe + @ZenMethod + public static void removeRecipe(IIngredient ingredient) { + List recipes = new LinkedList(); + + for (RecipeVat r : MaricultureHandlers.vat.getRecipes()) { + if (r != null) { + if (r.outputItem != null && matches(ingredient, toIItemStack(r.outputItem))) { + recipes.add(r); + } else if (r.outputFluid != null && matches(ingredient, toILiquidStack(r.outputFluid))) { recipes.add(r); } - } - } - - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new Remove(recipes)); - } else { - LogHelper.logWarning(String.format("No %s Recipes found for %s. Command ignored!", Vat.name, ingredient.toString())); - } - } + } + } + + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new Remove(recipes)); + } else { + LogHelper.logWarning( + String.format("No %s Recipes found for %s. Command ignored!", Vat.name, ingredient.toString())); + } + } + + @ZenMethod + public static void removeRecipe(IIngredient outputItem, IIngredient outputFluid) { + List recipes = new LinkedList(); - @ZenMethod - public static void removeRecipe(IIngredient outputItem, IIngredient outputFluid) { - List recipes = new LinkedList(); - for (RecipeVat r : MaricultureHandlers.vat.getRecipes()) { if (r != null) { if (r.outputItem != null && matches(outputItem, toIItemStack(r.outputItem))) { @@ -129,28 +143,34 @@ public class Vat { } } } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new Remove(recipes)); } else { - LogHelper.logWarning(String.format("No %s Recipes found for %s and %s. Command ignored!", Vat.name, outputItem.toString(), outputFluid.toString())); + LogHelper.logWarning( + String.format( + "No %s Recipes found for %s and %s. Command ignored!", + Vat.name, + outputItem.toString(), + outputFluid.toString())); } - } + } - // Removes a recipe, apply is never the same for anything, so will always - // need to override it - private static class Remove extends BaseListRemoval { - public Remove(List recipes) { - super("Mariculture Vat", MaricultureHandlers.vat.getRecipes(), recipes); - } + // Removes a recipe, apply is never the same for anything, so will always + // need to override it + private static class Remove extends BaseListRemoval { + + public Remove(List recipes) { + super("Mariculture Vat", MaricultureHandlers.vat.getRecipes(), recipes); + } @Override public String getRecipeInfo(RecipeVat recipe) { - if(recipe.outputItem != null) { + if (recipe.outputItem != null) { return LogHelper.getStackDescription(recipe.outputItem); } else { return LogHelper.getStackDescription(recipe.outputFluid); } } - } + } } diff --git a/src/main/java/modtweaker2/mods/mekanism/Mekanism.java b/src/main/java/modtweaker2/mods/mekanism/Mekanism.java index 99010cf..d1934fb 100644 --- a/src/main/java/modtweaker2/mods/mekanism/Mekanism.java +++ b/src/main/java/modtweaker2/mods/mekanism/Mekanism.java @@ -25,6 +25,7 @@ import modtweaker2.mods.mekanism.handlers.SolarNeutronActivator; import modtweaker2.utils.TweakerPlugin; public class Mekanism extends TweakerPlugin { + public Mekanism() { MineTweakerAPI.registerBracketHandler(new GasBracketHandler()); MineTweakerAPI.registerClass(IGasDefinition.class); diff --git a/src/main/java/modtweaker2/mods/mekanism/MekanismHelper.java b/src/main/java/modtweaker2/mods/mekanism/MekanismHelper.java index 07a64a7..21305d3 100644 --- a/src/main/java/modtweaker2/mods/mekanism/MekanismHelper.java +++ b/src/main/java/modtweaker2/mods/mekanism/MekanismHelper.java @@ -6,6 +6,7 @@ import minetweaker.api.item.IIngredient; import modtweaker2.mods.mekanism.gas.IGasStack; public class MekanismHelper { + private MekanismHelper() {} public static GasStack toGas(IGasStack iStack) { @@ -20,8 +21,7 @@ public class MekanismHelper { public static GasStack[] toGases(IGasStack[] iStack) { GasStack[] stack = new GasStack[iStack.length]; - for (int i = 0; i < stack.length; i++) - stack[i] = toGas(iStack[i]); + for (int i = 0; i < stack.length; i++) stack[i] = toGas(iStack[i]); return stack; } } diff --git a/src/main/java/modtweaker2/mods/mekanism/commands/GasLogger.java b/src/main/java/modtweaker2/mods/mekanism/commands/GasLogger.java index 9e8bd4e..493d028 100644 --- a/src/main/java/modtweaker2/mods/mekanism/commands/GasLogger.java +++ b/src/main/java/modtweaker2/mods/mekanism/commands/GasLogger.java @@ -12,9 +12,11 @@ import minetweaker.api.player.IPlayer; import minetweaker.api.server.ICommandFunction; public class GasLogger implements ICommandFunction { + public static final Comparator COMPARATOR = new Compare(); private static class Compare implements Comparator { + @Override public int compare(Gas o1, Gas o2) { return o1.getName().compareTo(o2.getName()); @@ -32,7 +34,9 @@ public class GasLogger implements ICommandFunction { } if (player != null) { - player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir")); + player.sendChat( + MineTweakerImplementationAPI.platform + .getMessage("List generated; see minetweaker.log in your minecraft dir")); } } } diff --git a/src/main/java/modtweaker2/mods/mekanism/commands/MekanismLogger.java b/src/main/java/modtweaker2/mods/mekanism/commands/MekanismLogger.java index 72140da..e3671ac 100644 --- a/src/main/java/modtweaker2/mods/mekanism/commands/MekanismLogger.java +++ b/src/main/java/modtweaker2/mods/mekanism/commands/MekanismLogger.java @@ -34,7 +34,7 @@ import modtweaker2.helpers.StringHelper; public class MekanismLogger implements ICommandFunction { private static final List validArguments = new LinkedList(); - + static { validArguments.add("Combiner"); validArguments.add("Compressor"); @@ -53,185 +53,239 @@ public class MekanismLogger implements ICommandFunction { validArguments.add("Separator"); validArguments.add("Washer"); } - + @SuppressWarnings({ "unchecked" }) @Override public void execute(String[] arguments, IPlayer player) { List args = StringHelper.toLowerCase(Arrays.asList(arguments)); - - if(!validArguments.containsAll(args)) { - if(player != null) { - player.sendChat(MineTweakerImplementationAPI.platform.getMessage("Invalid arguments for command. Valid arguments: " + StringHelper.join(validArguments, ", "))); + + if (!validArguments.containsAll(args)) { + if (player != null) { + player.sendChat( + MineTweakerImplementationAPI.platform.getMessage( + "Invalid arguments for command. Valid arguments: " + + StringHelper.join(validArguments, ", "))); } } else { - if(args.isEmpty() || args.contains("Crystallizer")) { - for(CrystallizerRecipe recipe : (Collection)Recipe.CHEMICAL_CRYSTALLIZER.get().values()) { - MineTweakerAPI.logCommand(String.format("mods.mekanism.chemical.Crystallizer.addRecipe(%s, %s);", - LogHelper.getStackDescription(recipe.recipeInput.ingredient), - LogHelper.getStackDescription(recipe.recipeOutput.output))); + if (args.isEmpty() || args.contains("Crystallizer")) { + for (CrystallizerRecipe recipe : (Collection) Recipe.CHEMICAL_CRYSTALLIZER.get() + .values()) { + MineTweakerAPI.logCommand( + String.format( + "mods.mekanism.chemical.Crystallizer.addRecipe(%s, %s);", + LogHelper.getStackDescription(recipe.recipeInput.ingredient), + LogHelper.getStackDescription(recipe.recipeOutput.output))); } } - - if(args.isEmpty() || args.contains("Dissolution")) { - for(DissolutionRecipe recipe : (Collection)Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get().values()) { - MineTweakerAPI.logCommand(String.format("mods.mekanism.chemical.Dissolution.addRecipe(%s, %s);", - LogHelper.getStackDescription(recipe.recipeInput.ingredient), - LogHelper.getStackDescription(recipe.recipeOutput.output))); + + if (args.isEmpty() || args.contains("Dissolution")) { + for (DissolutionRecipe recipe : (Collection) Recipe.CHEMICAL_DISSOLUTION_CHAMBER + .get().values()) { + MineTweakerAPI.logCommand( + String.format( + "mods.mekanism.chemical.Dissolution.addRecipe(%s, %s);", + LogHelper.getStackDescription(recipe.recipeInput.ingredient), + LogHelper.getStackDescription(recipe.recipeOutput.output))); } } - - if(args.isEmpty() || args.contains("Infuser")) { - for(ChemicalInfuserRecipe recipe : (Collection)Recipe.CHEMICAL_INFUSER.get().values()) { - MineTweakerAPI.logCommand(String.format("mods.mekanism.chemical.Infuser.addRecipe(%s, %s, %s);", - LogHelper.getStackDescription(recipe.recipeInput.leftGas), - LogHelper.getStackDescription(recipe.recipeInput.rightGas), - LogHelper.getStackDescription(recipe.recipeOutput.output))); + + if (args.isEmpty() || args.contains("Infuser")) { + for (ChemicalInfuserRecipe recipe : (Collection) Recipe.CHEMICAL_INFUSER.get() + .values()) { + MineTweakerAPI.logCommand( + String.format( + "mods.mekanism.chemical.Infuser.addRecipe(%s, %s, %s);", + LogHelper.getStackDescription(recipe.recipeInput.leftGas), + LogHelper.getStackDescription(recipe.recipeInput.rightGas), + LogHelper.getStackDescription(recipe.recipeOutput.output))); } } - - if(args.isEmpty() || args.contains("Injection")) { - for(InjectionRecipe recipe : (Collection)Recipe.CHEMICAL_INJECTION_CHAMBER.get().values()) { - MineTweakerAPI.logCommand(String.format("mods.mekanism.chemical.Injection.addRecipe(%s, %s, %s);", - LogHelper.getStackDescription(recipe.recipeInput.itemStack), - LogHelper.getStackDescription(new GasStack(recipe.recipeInput.gasType, 1)), - LogHelper.getStackDescription(recipe.recipeOutput.output))); + + if (args.isEmpty() || args.contains("Injection")) { + for (InjectionRecipe recipe : (Collection) Recipe.CHEMICAL_INJECTION_CHAMBER.get() + .values()) { + MineTweakerAPI.logCommand( + String.format( + "mods.mekanism.chemical.Injection.addRecipe(%s, %s, %s);", + LogHelper.getStackDescription(recipe.recipeInput.itemStack), + LogHelper.getStackDescription(new GasStack(recipe.recipeInput.gasType, 1)), + LogHelper.getStackDescription(recipe.recipeOutput.output))); } } - - if(args.isEmpty() || args.contains("Oxidizer")) { - for(OxidationRecipe recipe : (Collection)Recipe.CHEMICAL_OXIDIZER.get().values()) { - MineTweakerAPI.logCommand(String.format("mods.mekanism.chemical.Oxidizer.addRecipe(%s, %s);", - LogHelper.getStackDescription(recipe.recipeInput.ingredient), - LogHelper.getStackDescription(recipe.recipeOutput.output))); + + if (args.isEmpty() || args.contains("Oxidizer")) { + for (OxidationRecipe recipe : (Collection) Recipe.CHEMICAL_OXIDIZER.get().values()) { + MineTweakerAPI.logCommand( + String.format( + "mods.mekanism.chemical.Oxidizer.addRecipe(%s, %s);", + LogHelper.getStackDescription(recipe.recipeInput.ingredient), + LogHelper.getStackDescription(recipe.recipeOutput.output))); } } - - if(args.isEmpty() || args.contains("Washer")) { - for(WasherRecipe recipe : (Collection)Recipe.CHEMICAL_WASHER.get().values()) { - MineTweakerAPI.logCommand(String.format("mods.mekanism.chemical.Washer.addRecipe(%s, %s);", - LogHelper.getStackDescription(recipe.recipeInput.ingredient), - LogHelper.getStackDescription(recipe.recipeOutput.output))); + + if (args.isEmpty() || args.contains("Washer")) { + for (WasherRecipe recipe : (Collection) Recipe.CHEMICAL_WASHER.get().values()) { + MineTweakerAPI.logCommand( + String.format( + "mods.mekanism.chemical.Washer.addRecipe(%s, %s);", + LogHelper.getStackDescription(recipe.recipeInput.ingredient), + LogHelper.getStackDescription(recipe.recipeOutput.output))); } } - - if(args.isEmpty() || args.contains("Combiner")) { - for(CombinerRecipe recipe : (Collection)Recipe.COMBINER.get().values()) { - MineTweakerAPI.logCommand(String.format("mods.mekanism.Combiner.addRecipe(%s, %s, %s);", - LogHelper.getStackDescription(recipe.recipeInput.itemStack), - LogHelper.getStackDescription(recipe.recipeOutput.output), - LogHelper.getStackDescription(new GasStack(recipe.recipeInput.gasType, 1)))); + + if (args.isEmpty() || args.contains("Combiner")) { + for (CombinerRecipe recipe : (Collection) Recipe.COMBINER.get().values()) { + MineTweakerAPI.logCommand( + String.format( + "mods.mekanism.Combiner.addRecipe(%s, %s, %s);", + LogHelper.getStackDescription(recipe.recipeInput.itemStack), + LogHelper.getStackDescription(recipe.recipeOutput.output), + LogHelper.getStackDescription(new GasStack(recipe.recipeInput.gasType, 1)))); } } - - if(args.isEmpty() || args.contains("Compressor")) { - for(CombinerRecipe recipe : (Collection)Recipe.COMBINER.get().values()) { - MineTweakerAPI.logCommand(String.format("mods.mekanism.Compressor.addRecipe(%s, %s, %s);", - LogHelper.getStackDescription(recipe.recipeInput.itemStack), - LogHelper.getStackDescription(new GasStack(recipe.recipeInput.gasType, 1)), - LogHelper.getStackDescription(recipe.recipeOutput.output))); + + if (args.isEmpty() || args.contains("Compressor")) { + for (CombinerRecipe recipe : (Collection) Recipe.COMBINER.get().values()) { + MineTweakerAPI.logCommand( + String.format( + "mods.mekanism.Compressor.addRecipe(%s, %s, %s);", + LogHelper.getStackDescription(recipe.recipeInput.itemStack), + LogHelper.getStackDescription(new GasStack(recipe.recipeInput.gasType, 1)), + LogHelper.getStackDescription(recipe.recipeOutput.output))); } } - - if(args.isEmpty() || args.contains("Crusher")) { - for(CrusherRecipe recipe : (Collection)Recipe.CRUSHER.get().values()) { - MineTweakerAPI.logCommand(String.format("mods.mekanism.Crusher.addRecipe(%s, %s);", - LogHelper.getStackDescription(recipe.recipeInput.ingredient), - LogHelper.getStackDescription(recipe.recipeOutput.output))); + + if (args.isEmpty() || args.contains("Crusher")) { + for (CrusherRecipe recipe : (Collection) Recipe.CRUSHER.get().values()) { + MineTweakerAPI.logCommand( + String.format( + "mods.mekanism.Crusher.addRecipe(%s, %s);", + LogHelper.getStackDescription(recipe.recipeInput.ingredient), + LogHelper.getStackDescription(recipe.recipeOutput.output))); } } - - if(args.isEmpty() || args.contains("Smelter")) { - for(SmeltingRecipe recipe : (Collection)Recipe.ENERGIZED_SMELTER.get().values()) { - MineTweakerAPI.logCommand(String.format("mods.mekanism.Smelter.addRecipe(%s, %s);", - LogHelper.getStackDescription(recipe.recipeInput.ingredient), - LogHelper.getStackDescription(recipe.recipeOutput.output))); + + if (args.isEmpty() || args.contains("Smelter")) { + for (SmeltingRecipe recipe : (Collection) Recipe.ENERGIZED_SMELTER.get().values()) { + MineTweakerAPI.logCommand( + String.format( + "mods.mekanism.Smelter.addRecipe(%s, %s);", + LogHelper.getStackDescription(recipe.recipeInput.ingredient), + LogHelper.getStackDescription(recipe.recipeOutput.output))); } } - - if(args.isEmpty() || args.contains("Enrichment")) { - for(EnrichmentRecipe recipe : (Collection)Recipe.ENRICHMENT_CHAMBER.get().values()) { - MineTweakerAPI.logCommand(String.format("mods.mekanism.Enrichment.addRecipe(%s, %s);", - LogHelper.getStackDescription(recipe.recipeInput.ingredient), - LogHelper.getStackDescription(recipe.recipeOutput.output))); + + if (args.isEmpty() || args.contains("Enrichment")) { + for (EnrichmentRecipe recipe : (Collection) Recipe.ENRICHMENT_CHAMBER.get() + .values()) { + MineTweakerAPI.logCommand( + String.format( + "mods.mekanism.Enrichment.addRecipe(%s, %s);", + LogHelper.getStackDescription(recipe.recipeInput.ingredient), + LogHelper.getStackDescription(recipe.recipeOutput.output))); } } - - if(args.isEmpty() || args.contains("Infuser")) { - for(MetallurgicInfuserRecipe recipe : (Collection)Recipe.METALLURGIC_INFUSER.get().values()) { - MineTweakerAPI.logCommand(String.format("mods.mekanism.Infuser.addRecipe(\"%s\", %d, %s, %s);", - recipe.getInput().infuse.type.name, - recipe.getInput().infuse.amount, - LogHelper.getStackDescription(recipe.recipeInput.inputStack), - LogHelper.getStackDescription(recipe.recipeOutput.output))); + + if (args.isEmpty() || args.contains("Infuser")) { + for (MetallurgicInfuserRecipe recipe : (Collection) Recipe.METALLURGIC_INFUSER + .get().values()) { + MineTweakerAPI.logCommand( + String.format( + "mods.mekanism.Infuser.addRecipe(\"%s\", %d, %s, %s);", + recipe.getInput().infuse.type.name, + recipe.getInput().infuse.amount, + LogHelper.getStackDescription(recipe.recipeInput.inputStack), + LogHelper.getStackDescription(recipe.recipeOutput.output))); } } - - if(args.isEmpty() || args.contains("Purification")) { - for(PurificationRecipe recipe : (Collection)Recipe.PURIFICATION_CHAMBER.get().values()) { - MineTweakerAPI.logCommand(String.format("mods.mekanism.Purification.addRecipe(%s, %s, %s);", - LogHelper.getStackDescription(recipe.recipeInput.itemStack), - LogHelper.getStackDescription(new GasStack(recipe.recipeInput.gasType, 1)), - LogHelper.getStackDescription(recipe.recipeOutput.output))); + + if (args.isEmpty() || args.contains("Purification")) { + for (PurificationRecipe recipe : (Collection) Recipe.PURIFICATION_CHAMBER.get() + .values()) { + MineTweakerAPI.logCommand( + String.format( + "mods.mekanism.Purification.addRecipe(%s, %s, %s);", + LogHelper.getStackDescription(recipe.recipeInput.itemStack), + LogHelper.getStackDescription(new GasStack(recipe.recipeInput.gasType, 1)), + LogHelper.getStackDescription(recipe.recipeOutput.output))); } } - - if(args.isEmpty() || args.contains("Reaction")) { - for(PressurizedRecipe recipe : (Collection)Recipe.PRESSURIZED_REACTION_CHAMBER.get().values()) { - MineTweakerAPI.logCommand(String.format("mods.mekanism.Reaction.addRecipe(%s, %s, %s, %s, %s, %s, %d);", - LogHelper.getStackDescription(recipe.recipeInput.getSolid()), - LogHelper.getStackDescription(recipe.recipeInput.getFluid()), - LogHelper.getStackDescription(recipe.recipeInput.getGas()), - LogHelper.getStackDescription(recipe.recipeOutput.getItemOutput()), - LogHelper.getStackDescription(recipe.recipeOutput.getGasOutput()), - recipe.extraEnergy, - recipe.ticks)); + + if (args.isEmpty() || args.contains("Reaction")) { + for (PressurizedRecipe recipe : (Collection) Recipe.PRESSURIZED_REACTION_CHAMBER + .get().values()) { + MineTweakerAPI.logCommand( + String.format( + "mods.mekanism.Reaction.addRecipe(%s, %s, %s, %s, %s, %s, %d);", + LogHelper.getStackDescription(recipe.recipeInput.getSolid()), + LogHelper.getStackDescription(recipe.recipeInput.getFluid()), + LogHelper.getStackDescription(recipe.recipeInput.getGas()), + LogHelper.getStackDescription(recipe.recipeOutput.getItemOutput()), + LogHelper.getStackDescription(recipe.recipeOutput.getGasOutput()), + recipe.extraEnergy, + recipe.ticks)); } } - - if(args.isEmpty() || args.contains("Sawmill")) { - for(SawmillRecipe recipe : (Collection)Recipe.PRECISION_SAWMILL.get().values()) { - if(recipe.getOutput().hasSecondary()) { - MineTweakerAPI.logCommand(String.format("mods.mekanism.Sawmill.addRecipe(%s, %s, %s, %s);", - LogHelper.getStackDescription(recipe.recipeInput.ingredient), - LogHelper.getStackDescription(recipe.recipeOutput.primaryOutput), - LogHelper.getStackDescription(recipe.recipeOutput.secondaryOutput), - recipe.recipeOutput.secondaryChance)); + + if (args.isEmpty() || args.contains("Sawmill")) { + for (SawmillRecipe recipe : (Collection) Recipe.PRECISION_SAWMILL.get().values()) { + if (recipe.getOutput().hasSecondary()) { + MineTweakerAPI.logCommand( + String.format( + "mods.mekanism.Sawmill.addRecipe(%s, %s, %s, %s);", + LogHelper.getStackDescription(recipe.recipeInput.ingredient), + LogHelper.getStackDescription(recipe.recipeOutput.primaryOutput), + LogHelper.getStackDescription(recipe.recipeOutput.secondaryOutput), + recipe.recipeOutput.secondaryChance)); } else { - MineTweakerAPI.logCommand(String.format("mods.mekanism.Sawmill.addRecipe(%s, %s);", - LogHelper.getStackDescription(recipe.recipeInput.ingredient), - LogHelper.getStackDescription(recipe.recipeOutput.primaryOutput))); + MineTweakerAPI.logCommand( + String.format( + "mods.mekanism.Sawmill.addRecipe(%s, %s);", + LogHelper.getStackDescription(recipe.recipeInput.ingredient), + LogHelper.getStackDescription(recipe.recipeOutput.primaryOutput))); } } } - - if(args.isEmpty() || args.contains("Separator")) { - for(SeparatorRecipe recipe : (Collection)Recipe.ELECTROLYTIC_SEPARATOR.get().values()) { - MineTweakerAPI.logCommand(String.format("mods.mekanism.Separator.addRecipe(%s, %s, %s, %s);", - LogHelper.getStackDescription(recipe.recipeInput.ingredient), - recipe.energyUsage, - LogHelper.getStackDescription(recipe.recipeOutput.leftGas), - LogHelper.getStackDescription(recipe.recipeOutput.rightGas))); + + if (args.isEmpty() || args.contains("Separator")) { + for (SeparatorRecipe recipe : (Collection) Recipe.ELECTROLYTIC_SEPARATOR.get() + .values()) { + MineTweakerAPI.logCommand( + String.format( + "mods.mekanism.Separator.addRecipe(%s, %s, %s, %s);", + LogHelper.getStackDescription(recipe.recipeInput.ingredient), + recipe.energyUsage, + LogHelper.getStackDescription(recipe.recipeOutput.leftGas), + LogHelper.getStackDescription(recipe.recipeOutput.rightGas))); } } - - if(args.isEmpty() || args.contains("SolarEvaporation")) { - for(SolarEvaporationRecipe recipe : (Collection)Recipe.SOLAR_EVAPORATION_PLANT.get().values()) { - MineTweakerAPI.logCommand(String.format("mods.mekanism.SolarEvaporation.addRecipe(%s, %s);", - LogHelper.getStackDescription(recipe.recipeInput.ingredient), - LogHelper.getStackDescription(recipe.recipeOutput.output))); + + if (args.isEmpty() || args.contains("SolarEvaporation")) { + for (SolarEvaporationRecipe recipe : (Collection) Recipe.SOLAR_EVAPORATION_PLANT + .get().values()) { + MineTweakerAPI.logCommand( + String.format( + "mods.mekanism.SolarEvaporation.addRecipe(%s, %s);", + LogHelper.getStackDescription(recipe.recipeInput.ingredient), + LogHelper.getStackDescription(recipe.recipeOutput.output))); } } - - if(args.isEmpty() || args.contains("SolarNeutronActivator")) { - for(SolarNeutronRecipe recipe : (Collection)Recipe.SOLAR_NEUTRON_ACTIVATOR.get().values()) { - MineTweakerAPI.logCommand(String.format("mods.mekanism.SolarNeutronActivator.addRecipe(%s, %s);", - LogHelper.getStackDescription(recipe.recipeInput.ingredient), - LogHelper.getStackDescription(recipe.recipeOutput.output))); + + if (args.isEmpty() || args.contains("SolarNeutronActivator")) { + for (SolarNeutronRecipe recipe : (Collection) Recipe.SOLAR_NEUTRON_ACTIVATOR.get() + .values()) { + MineTweakerAPI.logCommand( + String.format( + "mods.mekanism.SolarNeutronActivator.addRecipe(%s, %s);", + LogHelper.getStackDescription(recipe.recipeInput.ingredient), + LogHelper.getStackDescription(recipe.recipeOutput.output))); } } - + if (player != null) { - player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir")); + player.sendChat( + MineTweakerImplementationAPI.platform + .getMessage("List generated; see minetweaker.log in your minecraft dir")); } } } diff --git a/src/main/java/modtweaker2/mods/mekanism/gas/GasBracketHandler.java b/src/main/java/modtweaker2/mods/mekanism/gas/GasBracketHandler.java index 17f721c..a1448dc 100644 --- a/src/main/java/modtweaker2/mods/mekanism/gas/GasBracketHandler.java +++ b/src/main/java/modtweaker2/mods/mekanism/gas/GasBracketHandler.java @@ -20,6 +20,7 @@ import stanhebben.zenscript.util.ZenPosition; @BracketHandler(priority = 100) public class GasBracketHandler implements IBracketHandler { + public static IGasStack getGas(String name) { Gas gas = GasRegistry.getGas(name); if (gas != null) { @@ -69,6 +70,7 @@ public class GasBracketHandler implements IBracketHandler { } private class GasReferenceSymbol implements IZenSymbol { + private final IEnvironmentGlobal environment; private final String name; @@ -82,4 +84,4 @@ public class GasBracketHandler implements IBracketHandler { return new ExpressionCallStatic(position, environment, method, new ExpressionString(position, name)); } } -} \ No newline at end of file +} diff --git a/src/main/java/modtweaker2/mods/mekanism/gas/IGasDefinition.java b/src/main/java/modtweaker2/mods/mekanism/gas/IGasDefinition.java index 693865a..f4712f1 100644 --- a/src/main/java/modtweaker2/mods/mekanism/gas/IGasDefinition.java +++ b/src/main/java/modtweaker2/mods/mekanism/gas/IGasDefinition.java @@ -7,6 +7,7 @@ import stanhebben.zenscript.annotations.ZenOperator; @ZenClass("modtweaker.gas.IGasDefinition") public interface IGasDefinition { + @ZenOperator(OperatorType.MUL) public IGasStack asStack(int millibuckets); @@ -15,4 +16,4 @@ public interface IGasDefinition { @ZenGetter("displayName") public String getDisplayName(); -} \ No newline at end of file +} diff --git a/src/main/java/modtweaker2/mods/mekanism/gas/IGasStack.java b/src/main/java/modtweaker2/mods/mekanism/gas/IGasStack.java index 9e37d33..41e7f6c 100644 --- a/src/main/java/modtweaker2/mods/mekanism/gas/IGasStack.java +++ b/src/main/java/modtweaker2/mods/mekanism/gas/IGasStack.java @@ -9,6 +9,7 @@ import stanhebben.zenscript.annotations.ZenOperator; @ZenClass("modtweaker.gas.IGasStack") public interface IGasStack extends IIngredient { + @ZenGetter("definition") public IGasDefinition getDefinition(); @@ -26,4 +27,4 @@ public interface IGasStack extends IIngredient { public IGasStack withAmount(int amount); public Object getInternal(); -} \ No newline at end of file +} diff --git a/src/main/java/modtweaker2/mods/mekanism/gas/MCGasDefinition.java b/src/main/java/modtweaker2/mods/mekanism/gas/MCGasDefinition.java index aa6b716..4fa4526 100644 --- a/src/main/java/modtweaker2/mods/mekanism/gas/MCGasDefinition.java +++ b/src/main/java/modtweaker2/mods/mekanism/gas/MCGasDefinition.java @@ -3,8 +3,8 @@ package modtweaker2.mods.mekanism.gas; import mekanism.api.gas.Gas; import mekanism.api.gas.GasStack; - public class MCGasDefinition implements IGasDefinition { + private final Gas gas; public MCGasDefinition(Gas gas) { @@ -25,4 +25,4 @@ public class MCGasDefinition implements IGasDefinition { public IGasStack asStack(int millibuckets) { return new MCGasStack(new GasStack(gas, millibuckets)); } -} \ No newline at end of file +} diff --git a/src/main/java/modtweaker2/mods/mekanism/gas/MCGasStack.java b/src/main/java/modtweaker2/mods/mekanism/gas/MCGasStack.java index 20f43dd..6589a54 100644 --- a/src/main/java/modtweaker2/mods/mekanism/gas/MCGasStack.java +++ b/src/main/java/modtweaker2/mods/mekanism/gas/MCGasStack.java @@ -10,8 +10,8 @@ import minetweaker.api.item.IItemTransformer; import minetweaker.api.liquid.ILiquidStack; import minetweaker.api.player.IPlayer; - public class MCGasStack implements IGasStack { + private final GasStack stack; public MCGasStack(GasStack stack) { @@ -48,7 +48,7 @@ public class MCGasStack implements IGasStack { public Object getInternal() { return stack; } - + @Override public String toString() { return ""; @@ -130,6 +130,5 @@ public class MCGasStack implements IGasStack { // TODO Auto-generated method stub return null; } - - -} \ No newline at end of file + +} diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalCrystallizer.java b/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalCrystallizer.java index 4999d12..67a97e6 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalCrystallizer.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalCrystallizer.java @@ -29,21 +29,21 @@ import stanhebben.zenscript.annotations.ZenMethod; @ZenClass("mods.mekanism.chemical.Crystallizer") public class ChemicalCrystallizer { - + public static final String name = "Mekanism Chemical Crystallizer"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @SuppressWarnings("unchecked") @ZenMethod public static void addRecipe(IGasStack gasInput, IItemStack itemOutput) { - if(gasInput == null || itemOutput == null) { + if (gasInput == null || itemOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - + CrystallizerRecipe recipe = new CrystallizerRecipe(toGas(gasInput), toStack(itemOutput)); - + MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.CHEMICAL_CRYSTALLIZER.get(), recipe)); } @@ -52,29 +52,35 @@ public class ChemicalCrystallizer { @SuppressWarnings({ "unchecked", "rawtypes" }) @ZenMethod public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient gasInput) { - if(itemOutput == null) { + if (itemOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - - if(gasInput == null) gasInput = IngredientAny.INSTANCE; - + + if (gasInput == null) gasInput = IngredientAny.INSTANCE; + Map recipes = new HashMap(); - - for(Entry entry : ((Map)Recipe.CHEMICAL_CRYSTALLIZER.get()).entrySet()) { + + for (Entry entry : ((Map) Recipe.CHEMICAL_CRYSTALLIZER + .get()).entrySet()) { IGasStack inputGas = new MCGasStack(entry.getKey().ingredient); IItemStack outputItem = InputHelper.toIItemStack(entry.getValue().recipeOutput.output); - - if(!StackHelper.matches(itemOutput, outputItem)) continue; - if(!StackHelper.matches(gasInput, inputGas)) continue; - + + if (!StackHelper.matches(itemOutput, outputItem)) continue; + if (!StackHelper.matches(gasInput, inputGas)) continue; + recipes.put(entry.getKey(), entry.getValue()); } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.CHEMICAL_CRYSTALLIZER.get(), recipes)); } else { - LogHelper.logWarning(String.format("No %s recipe found for %s and %s. Command ignored!", name, gasInput.toString(), itemOutput.toString())); + LogHelper.logWarning( + String.format( + "No %s recipe found for %s and %s. Command ignored!", + name, + gasInput.toString(), + itemOutput.toString())); } } } diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalDissolution.java b/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalDissolution.java index a21f376..ce5fc56 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalDissolution.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalDissolution.java @@ -29,52 +29,58 @@ import stanhebben.zenscript.annotations.ZenMethod; @ZenClass("mods.mekanism.chemical.Dissolution") public class ChemicalDissolution { - + public static final String name = "Mekanism Chemical Dissolution Chamber"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @SuppressWarnings("unchecked") @ZenMethod public static void addRecipe(IItemStack itemInput, IGasStack gasOutput) { - if(itemInput == null || gasOutput == null) { + if (itemInput == null || gasOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - + DissolutionRecipe recipe = new DissolutionRecipe(toStack(itemInput), toGas(gasOutput)); - + MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), recipe)); } - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @SuppressWarnings({ "unchecked", "rawtypes" }) @ZenMethod public static void removeRecipe(IIngredient gasOutput, @Optional IIngredient itemInput) { - if(gasOutput == null) { + if (gasOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - - if(itemInput == null) itemInput = IngredientAny.INSTANCE; - + + if (itemInput == null) itemInput = IngredientAny.INSTANCE; + Map recipes = new HashMap(); - - for(Entry entry : ((Map)Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get()).entrySet()) { + + for (Entry entry : ((Map) Recipe.CHEMICAL_DISSOLUTION_CHAMBER + .get()).entrySet()) { IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().ingredient); IGasStack outputGas = new MCGasStack(entry.getValue().recipeOutput.output); - - if(!StackHelper.matches(gasOutput, outputGas)) continue; - if(!StackHelper.matches(itemInput, inputItem)) continue; + + if (!StackHelper.matches(gasOutput, outputGas)) continue; + if (!StackHelper.matches(itemInput, inputItem)) continue; recipes.put(entry.getKey(), entry.getValue()); } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(), recipes)); } else { - LogHelper.logWarning(String.format("No %s recipe found for %s and %s. Command ignored!", name, gasOutput.toString(), itemInput.toString())); + LogHelper.logWarning( + String.format( + "No %s recipe found for %s and %s. Command ignored!", + name, + gasOutput.toString(), + itemInput.toString())); } } } diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalInfuser.java b/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalInfuser.java index 10284be..cab9ed2 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalInfuser.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalInfuser.java @@ -28,53 +28,64 @@ import stanhebben.zenscript.annotations.ZenMethod; public class ChemicalInfuser { public static final String name = "Mekanism Chemical Infuser"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @SuppressWarnings("unchecked") @ZenMethod public static void addRecipe(IGasStack leftGasInput, IGasStack rightGasInput, IGasStack gasOutput) { - if(leftGasInput == null || rightGasInput == null || gasOutput == null) { + if (leftGasInput == null || rightGasInput == null || gasOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - - ChemicalInfuserRecipe recipe = new ChemicalInfuserRecipe(toGas(leftGasInput), toGas(rightGasInput), toGas(gasOutput)); - + + ChemicalInfuserRecipe recipe = new ChemicalInfuserRecipe( + toGas(leftGasInput), + toGas(rightGasInput), + toGas(gasOutput)); + MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.CHEMICAL_INFUSER.get(), recipe)); } - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @SuppressWarnings({ "unchecked", "rawtypes" }) @ZenMethod - public static void removeRecipe(IIngredient gasOutput, @Optional IIngredient leftGasInput, @Optional IIngredient rightGasInput) { - if(gasOutput == null) { + public static void removeRecipe(IIngredient gasOutput, @Optional IIngredient leftGasInput, + @Optional IIngredient rightGasInput) { + if (gasOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - - if(leftGasInput == null) leftGasInput = IngredientAny.INSTANCE; - if(rightGasInput == null) rightGasInput = IngredientAny.INSTANCE; - + + if (leftGasInput == null) leftGasInput = IngredientAny.INSTANCE; + if (rightGasInput == null) rightGasInput = IngredientAny.INSTANCE; + Map recipes = new HashMap(); - - for(Entry entry : ((Map)Recipe.CHEMICAL_INFUSER.get()).entrySet()) { + + for (Entry entry : ((Map) Recipe.CHEMICAL_INFUSER + .get()).entrySet()) { IGasStack inputGasLeft = new MCGasStack(entry.getKey().leftGas); IGasStack inputGasRight = new MCGasStack(entry.getKey().rightGas); IGasStack outputGas = new MCGasStack(entry.getValue().recipeOutput.output); - - if(!StackHelper.matches(gasOutput, outputGas)) continue; - if(!StackHelper.matches(leftGasInput, inputGasLeft)) continue; - if(!StackHelper.matches(rightGasInput, inputGasRight)) continue; - + + if (!StackHelper.matches(gasOutput, outputGas)) continue; + if (!StackHelper.matches(leftGasInput, inputGasLeft)) continue; + if (!StackHelper.matches(rightGasInput, inputGasRight)) continue; + recipes.put(entry.getKey(), entry.getValue()); } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.CHEMICAL_INFUSER.get(), recipes)); } else { - LogHelper.logWarning(String.format("No %s recipe found for %s, %s and %s. Command ignored!", name, gasOutput.toString(), leftGasInput.toString(), rightGasInput.toString())); + LogHelper.logWarning( + String.format( + "No %s recipe found for %s, %s and %s. Command ignored!", + name, + gasOutput.toString(), + leftGasInput.toString(), + rightGasInput.toString())); } } } diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalInjection.java b/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalInjection.java index d157907..36bbaa0 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalInjection.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalInjection.java @@ -31,58 +31,66 @@ import stanhebben.zenscript.annotations.ZenMethod; @ZenClass("mods.mekanism.chemical.Injection") public class ChemicalInjection { - + public static final String name = "Mekanism Chemical Injection Chamber"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @SuppressWarnings("unchecked") @ZenMethod public static void addRecipe(IItemStack itemInput, IGasStack gasInput, IItemStack itemOutput) { - if(itemInput == null || gasInput == null || itemOutput == null) { + if (itemInput == null || gasInput == null || itemOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - + AdvancedMachineInput input = new AdvancedMachineInput(toStack(itemInput), toGas(gasInput).getGas()); ItemStackOutput output = new ItemStackOutput(toStack(itemOutput)); - + InjectionRecipe recipe = new InjectionRecipe(input, output); - + MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.CHEMICAL_INJECTION_CHAMBER.get(), recipe)); } - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @SuppressWarnings({ "rawtypes", "unchecked" }) @ZenMethod - public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput, @Optional IIngredient gasInput) { - if(itemOutput == null) { + public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput, + @Optional IIngredient gasInput) { + if (itemOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - - if(itemInput == null) itemInput = IngredientAny.INSTANCE; - if(gasInput == null) gasInput = IngredientAny.INSTANCE; - + + if (itemInput == null) itemInput = IngredientAny.INSTANCE; + if (gasInput == null) gasInput = IngredientAny.INSTANCE; + Map recipes = new HashMap(); - - for(Entry entry : ((Map)Recipe.CHEMICAL_INJECTION_CHAMBER.get()).entrySet()) { + + for (Entry entry : ((Map) Recipe.CHEMICAL_INJECTION_CHAMBER + .get()).entrySet()) { IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().itemStack); IGasStack inputGas = new MCGasStack(new GasStack(entry.getKey().gasType, 1)); IItemStack outputItem = InputHelper.toIItemStack(entry.getValue().recipeOutput.output); - - if(!StackHelper.matches(itemOutput, outputItem)) continue; - if(!StackHelper.matches(itemInput, inputItem)) continue; - if(!StackHelper.matches(gasInput, inputGas)) continue; - + + if (!StackHelper.matches(itemOutput, outputItem)) continue; + if (!StackHelper.matches(itemInput, inputItem)) continue; + if (!StackHelper.matches(gasInput, inputGas)) continue; + recipes.put(entry.getKey(), entry.getValue()); } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.CHEMICAL_INJECTION_CHAMBER.get(), recipes)); } else { - LogHelper.logWarning(String.format("No %s recipe found for %s, %s and %s. Command ignored!", name, itemOutput.toString(), itemInput.toString(), gasInput.toString())); + LogHelper.logWarning( + String.format( + "No %s recipe found for %s, %s and %s. Command ignored!", + name, + itemOutput.toString(), + itemInput.toString(), + gasInput.toString())); } } } diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalOxidizer.java b/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalOxidizer.java index eaa8132..67be397 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalOxidizer.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalOxidizer.java @@ -29,52 +29,58 @@ import stanhebben.zenscript.annotations.ZenMethod; @ZenClass("mods.mekanism.chemical.Oxidizer") public class ChemicalOxidizer { - + public static final String name = "Mekanism Chemical Oxidizer"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @SuppressWarnings("unchecked") @ZenMethod public static void addRecipe(IItemStack itemInput, IGasStack gasOutput) { - if(itemInput == null || gasOutput == null) { + if (itemInput == null || gasOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - + OxidationRecipe recipe = new OxidationRecipe(toStack(itemInput), toGas(gasOutput)); - + MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.CHEMICAL_OXIDIZER.get(), recipe)); } - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @SuppressWarnings({ "unchecked", "rawtypes" }) @ZenMethod public static void removeRecipe(IIngredient gasOutput, @Optional IIngredient itemInput) { - if(gasOutput == null) { + if (gasOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - - if(itemInput == null) itemInput = IngredientAny.INSTANCE; - + + if (itemInput == null) itemInput = IngredientAny.INSTANCE; + Map recipes = new HashMap(); - - for(Entry entry : ((Map)Recipe.CHEMICAL_OXIDIZER.get()).entrySet()) { + + for (Entry entry : ((Map) Recipe.CHEMICAL_OXIDIZER + .get()).entrySet()) { IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().ingredient); IGasStack outputGas = new MCGasStack(entry.getValue().recipeOutput.output); - - if(!StackHelper.matches(itemInput, inputItem)) continue; - if(!StackHelper.matches(gasOutput, outputGas)) continue; - + + if (!StackHelper.matches(itemInput, inputItem)) continue; + if (!StackHelper.matches(gasOutput, outputGas)) continue; + recipes.put(entry.getKey(), entry.getValue()); } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.CHEMICAL_OXIDIZER.get(), recipes)); } else { - LogHelper.logWarning(String.format("No %s recipe found for %s and %s. Command ignored!", name, gasOutput.toString(), itemInput.toString())); + LogHelper.logWarning( + String.format( + "No %s recipe found for %s and %s. Command ignored!", + name, + gasOutput.toString(), + itemInput.toString())); } } } diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalWasher.java b/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalWasher.java index 6e079fa..3708ee2 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalWasher.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/ChemicalWasher.java @@ -26,52 +26,58 @@ import stanhebben.zenscript.annotations.ZenMethod; @ZenClass("mods.mekanism.chemical.Washer") public class ChemicalWasher { - + public static final String name = "Mekanism Chemical Washer"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @SuppressWarnings("unchecked") @ZenMethod public static void addRecipe(IGasStack gasInput, IGasStack gasOutput) { - if(gasInput == null || gasOutput == null) { + if (gasInput == null || gasOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - + WasherRecipe recipe = new WasherRecipe(toGas(gasInput), toGas(gasOutput)); - + MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.CHEMICAL_WASHER.get(), recipe)); } - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @SuppressWarnings({ "unchecked", "rawtypes" }) @ZenMethod public static void removeRecipe(IIngredient gasOutput, @Optional IIngredient gasInput) { - if(gasOutput == null) { + if (gasOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - - if(gasInput == null) gasInput = IngredientAny.INSTANCE; - + + if (gasInput == null) gasInput = IngredientAny.INSTANCE; + Map recipes = new HashMap(); - - for(Entry entry : ((Map)Recipe.CHEMICAL_WASHER.get()).entrySet()) { + + for (Entry entry : ((Map) Recipe.CHEMICAL_WASHER.get()) + .entrySet()) { IGasStack inputGas = new MCGasStack(entry.getKey().ingredient); IGasStack outputGas = new MCGasStack(entry.getValue().recipeOutput.output); - - if(!StackHelper.matches(gasInput, inputGas)) continue; - if(!StackHelper.matches(gasOutput, outputGas)) continue; - + + if (!StackHelper.matches(gasInput, inputGas)) continue; + if (!StackHelper.matches(gasOutput, outputGas)) continue; + recipes.put(entry.getKey(), entry.getValue()); } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.CHEMICAL_WASHER.get(), recipes)); } else { - LogHelper.logWarning(String.format("No %s recipe found for %s and %s. Command ignored!", name, gasOutput.toString(), gasInput.toString())); + LogHelper.logWarning( + String.format( + "No %s recipe found for %s and %s. Command ignored!", + name, + gasOutput.toString(), + gasInput.toString())); } } } diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/Combiner.java b/src/main/java/modtweaker2/mods/mekanism/handlers/Combiner.java index f107a32..962df91 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/Combiner.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/Combiner.java @@ -31,69 +31,77 @@ import stanhebben.zenscript.annotations.ZenMethod; @ZenClass("mods.mekanism.Combiner") public class Combiner { - + public static final String name = "Mekanism Combiner"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @SuppressWarnings({ "unchecked" }) @ZenMethod public static void addRecipe(IItemStack itemInput, IGasStack gasInput, IItemStack itemOutput) { - if(itemInput == null || gasInput == null || itemOutput == null) { + if (itemInput == null || gasInput == null || itemOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - + AdvancedMachineInput input = new AdvancedMachineInput(toStack(itemInput), toGas(gasInput).getGas()); ItemStackOutput output = new ItemStackOutput(toStack(itemOutput)); CombinerRecipe recipe = new CombinerRecipe(input, output); - + MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.COMBINER.get(), recipe)); } - + @SuppressWarnings("unchecked") @ZenMethod public static void addRecipe(IItemStack itemInput, IItemStack itemOutput) { - if(itemInput == null || itemOutput == null) { + if (itemInput == null || itemOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - + CombinerRecipe recipe = new CombinerRecipe(toStack(itemInput), toStack(itemOutput)); - + MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.COMBINER.get(), recipe)); } - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @SuppressWarnings({ "rawtypes", "unchecked" }) @ZenMethod - public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput, @Optional IIngredient gasInput) { - if(itemOutput == null) { + public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput, + @Optional IIngredient gasInput) { + if (itemOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - - if(gasInput == null) gasInput = IngredientAny.INSTANCE; - if(itemInput == null) itemInput = IngredientAny.INSTANCE; - + + if (gasInput == null) gasInput = IngredientAny.INSTANCE; + if (itemInput == null) itemInput = IngredientAny.INSTANCE; + Map recipes = new HashMap(); - - for(Entry entry : ((Map)Recipe.COMBINER.get()).entrySet()) { + + for (Entry entry : ((Map) Recipe.COMBINER + .get()).entrySet()) { IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().itemStack); IGasStack inputGas = new MCGasStack(new GasStack(entry.getKey().gasType, 1)); IItemStack outputItem = InputHelper.toIItemStack(entry.getValue().getOutput().output); - - if(!StackHelper.matches(itemInput, inputItem)) continue; - if(!StackHelper.matches(gasInput, inputGas)) continue; - if(!StackHelper.matches(itemOutput, outputItem)) continue; - + + if (!StackHelper.matches(itemInput, inputItem)) continue; + if (!StackHelper.matches(gasInput, inputGas)) continue; + if (!StackHelper.matches(itemOutput, outputItem)) continue; + recipes.put(entry.getKey(), entry.getValue()); } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.COMBINER.get(), recipes)); } else { - LogHelper.logWarning(String.format("No %s recipe found for %s, %s and %s. Command ignored!", name, itemInput.toString(), gasInput.toString(), itemOutput.toString())); + LogHelper.logWarning( + String.format( + "No %s recipe found for %s, %s and %s. Command ignored!", + name, + itemInput.toString(), + gasInput.toString(), + itemOutput.toString())); } } } diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/Compressor.java b/src/main/java/modtweaker2/mods/mekanism/handlers/Compressor.java index 2ed1c45..d88c889 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/Compressor.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/Compressor.java @@ -31,71 +31,79 @@ import stanhebben.zenscript.annotations.ZenMethod; @ZenClass("mods.mekanism.Compressor") public class Compressor { - + public static final String name = "Mekanism Compressor"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @SuppressWarnings("unchecked") @ZenMethod public static void addRecipe(IItemStack itemInput, IItemStack itemOutput) { - if(itemInput == null || itemOutput == null) { + if (itemInput == null || itemOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - + OsmiumCompressorRecipe recipe = new OsmiumCompressorRecipe(toStack(itemInput), toStack(itemOutput)); - + MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.OSMIUM_COMPRESSOR.get(), recipe)); } - + @SuppressWarnings("unchecked") @ZenMethod public static void addRecipe(IItemStack itemInput, IGasStack gasInput, IItemStack itemOutput) { - if(itemInput == null || gasInput == null || itemOutput == null) { + if (itemInput == null || gasInput == null || itemOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - + AdvancedMachineInput input = new AdvancedMachineInput(toStack(itemInput), toGas(gasInput).getGas()); ItemStackOutput output = new ItemStackOutput(toStack(itemOutput)); - + OsmiumCompressorRecipe recipe = new OsmiumCompressorRecipe(input, output); - + MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.OSMIUM_COMPRESSOR.get(), recipe)); } - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @SuppressWarnings({ "unchecked", "rawtypes" }) @ZenMethod - public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput, @Optional IIngredient gasInput) { - if(itemOutput == null) { + public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput, + @Optional IIngredient gasInput) { + if (itemOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - - if(itemInput == null) itemInput = IngredientAny.INSTANCE; - if(gasInput == null) gasInput = IngredientAny.INSTANCE; - + + if (itemInput == null) itemInput = IngredientAny.INSTANCE; + if (gasInput == null) gasInput = IngredientAny.INSTANCE; + Map recipes = new HashMap(); - - for(Entry entry : ((Map)Recipe.OSMIUM_COMPRESSOR.get()).entrySet()) { + + for (Entry entry : ((Map) Recipe.OSMIUM_COMPRESSOR + .get()).entrySet()) { IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().itemStack); IGasStack inputGas = new MCGasStack(new GasStack(entry.getKey().gasType, 1)); IItemStack outputItem = InputHelper.toIItemStack(entry.getValue().getOutput().output); - - if(!StackHelper.matches(itemInput, inputItem)) continue; - if(!StackHelper.matches(gasInput, inputGas)) continue; - if(!StackHelper.matches(itemOutput, outputItem)) continue; - + + if (!StackHelper.matches(itemInput, inputItem)) continue; + if (!StackHelper.matches(gasInput, inputGas)) continue; + if (!StackHelper.matches(itemOutput, outputItem)) continue; + recipes.put(entry.getKey(), entry.getValue()); } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.OSMIUM_COMPRESSOR.get(), recipes)); } else { - LogHelper.logWarning(String.format("No %s recipe found for %s, %s and %s. Command ignored!", name, itemInput.toString(), gasInput.toString(), itemOutput.toString())); + LogHelper.logWarning( + String.format( + "No %s recipe found for %s, %s and %s. Command ignored!", + name, + itemInput.toString(), + gasInput.toString(), + itemOutput.toString())); } } } diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/Crusher.java b/src/main/java/modtweaker2/mods/mekanism/handlers/Crusher.java index c8026e2..f4dd870 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/Crusher.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/Crusher.java @@ -26,52 +26,58 @@ import stanhebben.zenscript.annotations.ZenMethod; @ZenClass("mods.mekanism.Crusher") public class Crusher { - + public static final String name = "Mekanism Crusher"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @SuppressWarnings("unchecked") @ZenMethod public static void addRecipe(IItemStack itemInput, IItemStack itemOutput) { - if(itemInput == null || itemOutput == null) { + if (itemInput == null || itemOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - + CrusherRecipe recipe = new CrusherRecipe(toStack(itemInput), toStack(itemOutput)); - + MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.CRUSHER.get(), recipe)); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @SuppressWarnings({ "unchecked", "rawtypes" }) @ZenMethod public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput) { - if(itemOutput == null) { + if (itemOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - - if(itemInput == null) itemInput = IngredientAny.INSTANCE; - + + if (itemInput == null) itemInput = IngredientAny.INSTANCE; + Map recipes = new HashMap(); - - for(Entry entry : ((Map)Recipe.CRUSHER.get()).entrySet() ) { + + for (Entry entry : ((Map) Recipe.CRUSHER.get()) + .entrySet()) { IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().ingredient); IItemStack outputItem = InputHelper.toIItemStack(entry.getValue().recipeOutput.output); - - if(!StackHelper.matches(itemOutput, outputItem)) continue; - if(!StackHelper.matches(itemInput, inputItem)) continue; - + + if (!StackHelper.matches(itemOutput, outputItem)) continue; + if (!StackHelper.matches(itemInput, inputItem)) continue; + recipes.put(entry.getKey(), entry.getValue()); } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.CRUSHER.get(), recipes)); } else { - LogHelper.logWarning(String.format("No %s recipe found for %s and %s. Command ignored!", name, itemInput.toString(), itemOutput.toString())); + LogHelper.logWarning( + String.format( + "No %s recipe found for %s and %s. Command ignored!", + name, + itemInput.toString(), + itemOutput.toString())); } } } diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/EnergizedSmelter.java b/src/main/java/modtweaker2/mods/mekanism/handlers/EnergizedSmelter.java index ea34432..9cc67cf 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/EnergizedSmelter.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/EnergizedSmelter.java @@ -28,50 +28,56 @@ import stanhebben.zenscript.annotations.ZenMethod; public class EnergizedSmelter { public static final String name = "Mekanism Smelter"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @SuppressWarnings("unchecked") @ZenMethod public static void addRecipe(IItemStack itemInput, IItemStack itemOutput) { - if(itemInput == null || itemOutput == null) { + if (itemInput == null || itemOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - + SmeltingRecipe recipe = new SmeltingRecipe(toStack(itemInput), toStack(itemOutput)); - + MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.ENERGIZED_SMELTER.get(), recipe)); } - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @SuppressWarnings({ "unchecked", "rawtypes" }) @ZenMethod public static void removeRecipe(IIngredient itemInput, @Optional IIngredient itemOutput) { - if(itemInput == null) { + if (itemInput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - - if(itemOutput == null) itemOutput = IngredientAny.INSTANCE; + + if (itemOutput == null) itemOutput = IngredientAny.INSTANCE; Map recipes = new HashMap(); - for(Entry entry : ((Map)Recipe.ENERGIZED_SMELTER.get()).entrySet() ) { + for (Entry entry : ((Map) Recipe.ENERGIZED_SMELTER + .get()).entrySet()) { IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().ingredient); IItemStack outputItem = InputHelper.toIItemStack(entry.getValue().recipeOutput.output); - if(!StackHelper.matches(itemInput, inputItem)) continue; - if(!StackHelper.matches(itemOutput, outputItem)) continue; - + if (!StackHelper.matches(itemInput, inputItem)) continue; + if (!StackHelper.matches(itemOutput, outputItem)) continue; + recipes.put(entry.getKey(), entry.getValue()); } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.ENERGIZED_SMELTER.get(), recipes)); } else { - LogHelper.logWarning(String.format("No %s recipe found for %s and %s. Command ignored!", name, itemInput.toString(), itemOutput.toString())); + LogHelper.logWarning( + String.format( + "No %s recipe found for %s and %s. Command ignored!", + name, + itemInput.toString(), + itemOutput.toString())); } } } diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/Enrichment.java b/src/main/java/modtweaker2/mods/mekanism/handlers/Enrichment.java index 80bf1cb..3daedf9 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/Enrichment.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/Enrichment.java @@ -26,53 +26,59 @@ import stanhebben.zenscript.annotations.ZenMethod; @ZenClass("mods.mekanism.Enrichment") public class Enrichment { - + public static final String name = "Mekanism Enrichment"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @SuppressWarnings("unchecked") @ZenMethod public static void addRecipe(IItemStack itemInput, IItemStack itemOutput) { - if(itemInput == null || itemOutput == null) { + if (itemInput == null || itemOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - + EnrichmentRecipe recipe = new EnrichmentRecipe(toStack(itemInput), toStack(itemOutput)); - + MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.ENRICHMENT_CHAMBER.get(), recipe)); } - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @SuppressWarnings({ "unchecked", "rawtypes" }) @ZenMethod public static void removeRecipe(IIngredient itemInput, @Optional IIngredient itemOutput) { - if(itemInput == null) { + if (itemInput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - - if(itemOutput == null) itemOutput = IngredientAny.INSTANCE; - + + if (itemOutput == null) itemOutput = IngredientAny.INSTANCE; + Map recipes = new HashMap(); - - for(Entry entry : ((Map)Recipe.ENRICHMENT_CHAMBER.get()).entrySet() ) { + + for (Entry entry : ((Map) Recipe.ENRICHMENT_CHAMBER + .get()).entrySet()) { IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().ingredient); IItemStack outputItem = InputHelper.toIItemStack(entry.getValue().recipeOutput.output); - - if(!StackHelper.matches(itemOutput, outputItem)) continue; - if(!StackHelper.matches(itemInput, inputItem)) continue; - + + if (!StackHelper.matches(itemOutput, outputItem)) continue; + if (!StackHelper.matches(itemInput, inputItem)) continue; + recipes.put(entry.getKey(), entry.getValue()); } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.ENRICHMENT_CHAMBER.get(), recipes)); } else { - LogHelper.logWarning(String.format("No %s recipe found for %s and %s. Command ignored!", name, itemInput.toString(), itemOutput.toString())); + LogHelper.logWarning( + String.format( + "No %s recipe found for %s and %s. Command ignored!", + name, + itemInput.toString(), + itemOutput.toString())); } } - + } diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/Infuser.java b/src/main/java/modtweaker2/mods/mekanism/handlers/Infuser.java index d8a9683..2956aa2 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/Infuser.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/Infuser.java @@ -28,58 +28,65 @@ import stanhebben.zenscript.annotations.ZenMethod; @ZenClass("mods.mekanism.Infuser") public class Infuser { - + public static final String name = "Mekanism Metallurgic Infuser"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @SuppressWarnings("unchecked") @ZenMethod public static void addRecipe(String infuseType, int infuseAmount, IItemStack itemInput, IItemStack itemOutput) { - if(itemInput == null || itemOutput == null || infuseType == null || infuseType.isEmpty()) { + if (itemInput == null || itemOutput == null || infuseType == null || infuseType.isEmpty()) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - + InfusionInput input = new InfusionInput(InfuseRegistry.get(infuseType), infuseAmount, toStack(itemInput)); ItemStackOutput output = new ItemStackOutput(toStack(itemOutput)); - + MetallurgicInfuserRecipe recipe = new MetallurgicInfuserRecipe(input, output); - + MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.METALLURGIC_INFUSER.get(), recipe)); } - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @SuppressWarnings({ "unchecked", "rawtypes" }) @ZenMethod - public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput, @Optional String infuseType) { - if(itemOutput == null) { + public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput, + @Optional String infuseType) { + if (itemOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - - if(itemInput == null) itemInput = IngredientAny.INSTANCE; - if(infuseType == null) infuseType = ""; - + + if (itemInput == null) itemInput = IngredientAny.INSTANCE; + if (infuseType == null) infuseType = ""; + Map recipes = new HashMap(); - - for(Entry entry : ((Map)Recipe.METALLURGIC_INFUSER.get()).entrySet() ) { + + for (Entry entry : ((Map) Recipe.METALLURGIC_INFUSER + .get()).entrySet()) { IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().inputStack); String typeInfuse = entry.getKey().infuse.type.name; IItemStack outputItem = InputHelper.toIItemStack(entry.getValue().recipeOutput.output); - - if(!StackHelper.matches(itemOutput, outputItem)) continue; - if(!StackHelper.matches(itemInput, inputItem)) continue; - if(!infuseType.isEmpty() && !infuseType.equalsIgnoreCase(typeInfuse)) continue; - + + if (!StackHelper.matches(itemOutput, outputItem)) continue; + if (!StackHelper.matches(itemInput, inputItem)) continue; + if (!infuseType.isEmpty() && !infuseType.equalsIgnoreCase(typeInfuse)) continue; + recipes.put(entry.getKey(), entry.getValue()); } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.METALLURGIC_INFUSER.get(), recipes)); } else { - LogHelper.logWarning(String.format("No %s recipe found for %s and %s. Command ignored!", name, itemInput.toString(), itemOutput.toString())); + LogHelper.logWarning( + String.format( + "No %s recipe found for %s and %s. Command ignored!", + name, + itemInput.toString(), + itemOutput.toString())); } } } diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/Purification.java b/src/main/java/modtweaker2/mods/mekanism/handlers/Purification.java index baf3263..d395b3d 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/Purification.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/Purification.java @@ -31,71 +31,79 @@ import stanhebben.zenscript.annotations.ZenMethod; @ZenClass("mods.mekanism.Purification") public class Purification { - + public static final String name = "Mekanism Purification"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @SuppressWarnings("unchecked") @ZenMethod public static void addRecipe(IItemStack itemInput, IItemStack itemOutput) { - if(itemInput == null || itemOutput == null) { + if (itemInput == null || itemOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - + PurificationRecipe recipe = new PurificationRecipe(toStack(itemInput), toStack(itemOutput)); - + MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.PURIFICATION_CHAMBER.get(), recipe)); } - + @SuppressWarnings("unchecked") @ZenMethod public static void addRecipe(IItemStack itemInput, IGasStack gasInput, IItemStack itemOutput) { - if(itemInput == null || gasInput == null || itemOutput == null) { + if (itemInput == null || gasInput == null || itemOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } AdvancedMachineInput input = new AdvancedMachineInput(toStack(itemInput), toGas(gasInput).getGas()); ItemStackOutput output = new ItemStackOutput(toStack(itemOutput)); - + PurificationRecipe recipe = new PurificationRecipe(input, output); - + MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.PURIFICATION_CHAMBER.get(), recipe)); } - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @SuppressWarnings({ "rawtypes", "unchecked" }) @ZenMethod - public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput, @Optional IIngredient gasInput) { - if(itemOutput == null) { + public static void removeRecipe(IIngredient itemOutput, @Optional IIngredient itemInput, + @Optional IIngredient gasInput) { + if (itemOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - - if(itemInput == null) itemInput = IngredientAny.INSTANCE; - if(gasInput == null) gasInput = IngredientAny.INSTANCE; - + + if (itemInput == null) itemInput = IngredientAny.INSTANCE; + if (gasInput == null) gasInput = IngredientAny.INSTANCE; + Map recipes = new HashMap(); - - for(Entry entry : ((Map)Recipe.PURIFICATION_CHAMBER.get()).entrySet()) { + + for (Entry entry : ((Map) Recipe.PURIFICATION_CHAMBER + .get()).entrySet()) { IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().itemStack); IGasStack inputGas = new MCGasStack(new GasStack(entry.getKey().gasType, 1)); IItemStack outputItem = InputHelper.toIItemStack(entry.getValue().recipeOutput.output); - - if(!StackHelper.matches(itemOutput, outputItem)) continue; - if(!StackHelper.matches(itemInput, inputItem)) continue; - if(!StackHelper.matches(gasInput, inputGas)) continue; - + + if (!StackHelper.matches(itemOutput, outputItem)) continue; + if (!StackHelper.matches(itemInput, inputItem)) continue; + if (!StackHelper.matches(gasInput, inputGas)) continue; + recipes.put(entry.getKey(), entry.getValue()); } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.PURIFICATION_CHAMBER.get(), recipes)); } else { - LogHelper.logWarning(String.format("No %s recipe found for %s, %s and %s. Command ignored!", name, itemOutput.toString(), itemInput.toString(), gasInput.toString())); + LogHelper.logWarning( + String.format( + "No %s recipe found for %s, %s and %s. Command ignored!", + name, + itemOutput.toString(), + itemInput.toString(), + gasInput.toString())); } } } diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/Reaction.java b/src/main/java/modtweaker2/mods/mekanism/handlers/Reaction.java index d11d3c2..94c8cfa 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/Reaction.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/Reaction.java @@ -32,64 +32,75 @@ import stanhebben.zenscript.annotations.ZenMethod; @ZenClass("mods.mekanism.Reaction") public class Reaction { - + public static final String name = "Mekanism Reaction"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @SuppressWarnings("unchecked") @ZenMethod - public static void addRecipe(IItemStack itemInput, ILiquidStack liquidInput, IGasStack gasInput, IItemStack itemOutput, IGasStack gasOutput, double energy, int duration) { - if(itemInput == null || liquidInput == null || gasInput == null || itemOutput == null || gasOutput == null) { + public static void addRecipe(IItemStack itemInput, ILiquidStack liquidInput, IGasStack gasInput, + IItemStack itemOutput, IGasStack gasOutput, double energy, int duration) { + if (itemInput == null || liquidInput == null || gasInput == null || itemOutput == null || gasOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - + PressurizedInput input = new PressurizedInput(toStack(itemInput), toFluid(liquidInput), toGas(gasInput)); PressurizedOutput output = new PressurizedOutput(toStack(itemOutput), toGas(gasOutput)); - + PressurizedRecipe recipe = new PressurizedRecipe(input, output, energy, duration); - + MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.PRESSURIZED_REACTION_CHAMBER.get(), recipe)); } - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @SuppressWarnings({ "unchecked", "rawtypes" }) @ZenMethod - public static void removeRecipe(IIngredient itemOutput, IIngredient gasOutput, @Optional IIngredient itemInput, @Optional IIngredient liquidInput, @Optional IIngredient gasInput) { - if(itemOutput == null || gasOutput == null) { + public static void removeRecipe(IIngredient itemOutput, IIngredient gasOutput, @Optional IIngredient itemInput, + @Optional IIngredient liquidInput, @Optional IIngredient gasInput) { + if (itemOutput == null || gasOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - - if(itemInput == null) itemInput = IngredientAny.INSTANCE; - if(liquidInput == null) liquidInput = IngredientAny.INSTANCE; - if(gasInput == null) gasInput = IngredientAny.INSTANCE; - + + if (itemInput == null) itemInput = IngredientAny.INSTANCE; + if (liquidInput == null) liquidInput = IngredientAny.INSTANCE; + if (gasInput == null) gasInput = IngredientAny.INSTANCE; + Map recipes = new HashMap(); - - for(Entry entry : ((Map)Recipe.PRESSURIZED_REACTION_CHAMBER.get()).entrySet() ) { + + for (Entry entry : ((Map) Recipe.PRESSURIZED_REACTION_CHAMBER + .get()).entrySet()) { IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().getSolid()); ILiquidStack inputLiquid = InputHelper.toILiquidStack(entry.getKey().getFluid()); IGasStack inputGas = new MCGasStack(entry.getKey().getGas()); IItemStack outputItem = InputHelper.toIItemStack(entry.getValue().recipeOutput.getItemOutput()); IGasStack outputGas = new MCGasStack(entry.getValue().recipeOutput.getGasOutput()); - - if(!StackHelper.matches(itemInput, inputItem)) continue; - if(!StackHelper.matches(liquidInput, inputLiquid)) continue; - if(!StackHelper.matches(gasInput, inputGas)) continue; - if(!StackHelper.matches(itemOutput, outputItem)) continue; - if(!StackHelper.matches(gasOutput, outputGas)) continue; - + + if (!StackHelper.matches(itemInput, inputItem)) continue; + if (!StackHelper.matches(liquidInput, inputLiquid)) continue; + if (!StackHelper.matches(gasInput, inputGas)) continue; + if (!StackHelper.matches(itemOutput, outputItem)) continue; + if (!StackHelper.matches(gasOutput, outputGas)) continue; + recipes.put(entry.getKey(), entry.getValue()); } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.PRESSURIZED_REACTION_CHAMBER.get(), recipes)); } else { - LogHelper.logWarning(String.format("No %s recipe found for %s, %s, %s, %s and %s. Command ignored!", name, itemOutput.toString(), gasOutput.toString(), itemInput.toString(), liquidInput.toString(), gasInput.toString())); + LogHelper.logWarning( + String.format( + "No %s recipe found for %s, %s, %s, %s and %s. Command ignored!", + name, + itemOutput.toString(), + gasOutput.toString(), + itemInput.toString(), + liquidInput.toString(), + gasInput.toString())); } } - + } diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/Sawmill.java b/src/main/java/modtweaker2/mods/mekanism/handlers/Sawmill.java index e4953c7..72b3db9 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/Sawmill.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/Sawmill.java @@ -27,59 +27,67 @@ import stanhebben.zenscript.annotations.ZenMethod; @ZenClass("mods.mekanism.Sawmill") public class Sawmill { - + public static final String name = "Mekanism Sawmill"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @SuppressWarnings("unchecked") @ZenMethod - public static void addRecipe(IItemStack itemInput, IItemStack itemOutput, @Optional IItemStack optionalItemOutput, @Optional double optionalChance) { - if(itemInput == null || itemOutput == null) { + public static void addRecipe(IItemStack itemInput, IItemStack itemOutput, @Optional IItemStack optionalItemOutput, + @Optional double optionalChance) { + if (itemInput == null || itemOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - + ItemStackInput input = new ItemStackInput(toStack(itemInput)); - ChanceOutput output = optionalItemOutput == null ? new ChanceOutput(toStack(itemOutput)) : - new ChanceOutput(toStack(itemOutput), toStack(optionalItemOutput), optionalChance); - + ChanceOutput output = optionalItemOutput == null ? new ChanceOutput(toStack(itemOutput)) + : new ChanceOutput(toStack(itemOutput), toStack(optionalItemOutput), optionalChance); + SawmillRecipe recipe = new SawmillRecipe(input, output); - + MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.PRECISION_SAWMILL.get(), recipe)); } - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @SuppressWarnings({ "unchecked", "rawtypes" }) @ZenMethod - public static void removeRecipe(IIngredient itemInput, @Optional IIngredient itemOutput, @Optional IIngredient optionalItemOutput) { - if(itemInput == null) { + public static void removeRecipe(IIngredient itemInput, @Optional IIngredient itemOutput, + @Optional IIngredient optionalItemOutput) { + if (itemInput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - - if(itemOutput == null) itemOutput = IngredientAny.INSTANCE; - if(optionalItemOutput == null) optionalItemOutput = IngredientAny.INSTANCE; - + + if (itemOutput == null) itemOutput = IngredientAny.INSTANCE; + if (optionalItemOutput == null) optionalItemOutput = IngredientAny.INSTANCE; + Map recipes = new HashMap(); - - for(Entry entry : ((Map)Recipe.PRECISION_SAWMILL.get()).entrySet() ) { + + for (Entry entry : ((Map) Recipe.PRECISION_SAWMILL + .get()).entrySet()) { IItemStack inputItem = InputHelper.toIItemStack(entry.getKey().ingredient); IItemStack outputItem = InputHelper.toIItemStack(entry.getValue().recipeOutput.primaryOutput); IItemStack outputItemOptional = InputHelper.toIItemStack(entry.getValue().recipeOutput.secondaryOutput); - - if(!StackHelper.matches(itemOutput, outputItem)) continue; - if(!StackHelper.matches(itemInput, inputItem)) continue; - if(!StackHelper.matches(optionalItemOutput, outputItemOptional)) continue; - + + if (!StackHelper.matches(itemOutput, outputItem)) continue; + if (!StackHelper.matches(itemInput, inputItem)) continue; + if (!StackHelper.matches(optionalItemOutput, outputItemOptional)) continue; + recipes.put(entry.getKey(), entry.getValue()); } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.PRECISION_SAWMILL.get(), recipes)); } else { - LogHelper.logWarning(String.format("No %s recipe found for %s and %s. Command ignored!", name, itemInput.toString(), itemOutput.toString())); + LogHelper.logWarning( + String.format( + "No %s recipe found for %s and %s. Command ignored!", + name, + itemInput.toString(), + itemOutput.toString())); } } } diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/Separator.java b/src/main/java/modtweaker2/mods/mekanism/handlers/Separator.java index 09c2b7d..5e5cff5 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/Separator.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/Separator.java @@ -29,55 +29,68 @@ import stanhebben.zenscript.annotations.ZenMethod; @ZenClass("mods.mekanism.Separator") public class Separator { - + public static final String name = "Mekanism Separator"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @SuppressWarnings("unchecked") @ZenMethod - public static void addRecipe(ILiquidStack liquidInput, double energy, IGasStack leftGasOutput, IGasStack rightGasOutput) { - if(liquidInput == null || leftGasOutput == null || rightGasOutput == null) { + public static void addRecipe(ILiquidStack liquidInput, double energy, IGasStack leftGasOutput, + IGasStack rightGasOutput) { + if (liquidInput == null || leftGasOutput == null || rightGasOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - - SeparatorRecipe recipe = new SeparatorRecipe(toFluid(liquidInput), energy, toGas(leftGasOutput), toGas(rightGasOutput)); - + + SeparatorRecipe recipe = new SeparatorRecipe( + toFluid(liquidInput), + energy, + toGas(leftGasOutput), + toGas(rightGasOutput)); + MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.ELECTROLYTIC_SEPARATOR.get(), recipe)); } - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @SuppressWarnings({ "rawtypes", "unchecked" }) @ZenMethod - public static void removeRecipe(IIngredient liquidInput, @Optional IIngredient leftGasInput, @Optional IIngredient rightGasInput) { - if(liquidInput == null) { + public static void removeRecipe(IIngredient liquidInput, @Optional IIngredient leftGasInput, + @Optional IIngredient rightGasInput) { + if (liquidInput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - - if(leftGasInput == null) leftGasInput = IngredientAny.INSTANCE; - if(rightGasInput == null) leftGasInput = IngredientAny.INSTANCE; - + + if (leftGasInput == null) leftGasInput = IngredientAny.INSTANCE; + if (rightGasInput == null) leftGasInput = IngredientAny.INSTANCE; + Map recipes = new HashMap(); - - for(Entry entry : ((Map)Recipe.ELECTROLYTIC_SEPARATOR.get()).entrySet() ) { + + for (Entry entry : ((Map) Recipe.ELECTROLYTIC_SEPARATOR + .get()).entrySet()) { ILiquidStack inputLiquid = InputHelper.toILiquidStack(entry.getKey().ingredient); IGasStack outputItemLeft = new MCGasStack(entry.getValue().recipeOutput.leftGas); IGasStack outputItemRight = new MCGasStack(entry.getValue().recipeOutput.rightGas); - - if(!StackHelper.matches(liquidInput, inputLiquid)) continue; - if(!StackHelper.matches(leftGasInput, outputItemLeft)) continue; - if(!StackHelper.matches(rightGasInput, outputItemRight)) continue; - + + if (!StackHelper.matches(liquidInput, inputLiquid)) continue; + if (!StackHelper.matches(leftGasInput, outputItemLeft)) continue; + if (!StackHelper.matches(rightGasInput, outputItemRight)) continue; + recipes.put(entry.getKey(), entry.getValue()); } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.ELECTROLYTIC_SEPARATOR.get(), recipes)); } else { - LogHelper.logWarning(String.format("No %s recipe found for %s, %s and %s. Command ignored!", name, liquidInput.toString(), leftGasInput.toString(), rightGasInput.toString())); + LogHelper.logWarning( + String.format( + "No %s recipe found for %s, %s and %s. Command ignored!", + name, + liquidInput.toString(), + leftGasInput.toString(), + rightGasInput.toString())); } } } diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/SolarEvaporation.java b/src/main/java/modtweaker2/mods/mekanism/handlers/SolarEvaporation.java index e20268b..e7f4859 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/SolarEvaporation.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/SolarEvaporation.java @@ -26,52 +26,58 @@ import stanhebben.zenscript.annotations.ZenMethod; @ZenClass("mods.mekanism.SolarEvaporation") public class SolarEvaporation { - + public static final String name = "Mekanism Solar Evaporation"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @SuppressWarnings("unchecked") @ZenMethod public static void addRecipe(ILiquidStack liquidInput, ILiquidStack liquidOutput) { - if(liquidInput == null || liquidOutput == null) { + if (liquidInput == null || liquidOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - + SolarEvaporationRecipe recipe = new SolarEvaporationRecipe(toFluid(liquidInput), toFluid(liquidOutput)); - + MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.SOLAR_EVAPORATION_PLANT.get(), recipe)); } - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @SuppressWarnings({ "unchecked", "rawtypes" }) @ZenMethod public static void removeRecipe(IIngredient liquidInput, @Optional IIngredient liquidOutput) { - if(liquidInput == null) { + if (liquidInput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - - if(liquidOutput == null) liquidOutput = IngredientAny.INSTANCE; - + + if (liquidOutput == null) liquidOutput = IngredientAny.INSTANCE; + Map recipes = new HashMap(); - - for(Entry entry : ((Map)Recipe.SOLAR_EVAPORATION_PLANT.get()).entrySet() ) { + + for (Entry entry : ((Map) Recipe.SOLAR_EVAPORATION_PLANT + .get()).entrySet()) { ILiquidStack inputLiquid = InputHelper.toILiquidStack(entry.getKey().ingredient); ILiquidStack outputLiquid = InputHelper.toILiquidStack(entry.getValue().recipeOutput.output); - if(!StackHelper.matches(liquidInput, inputLiquid)) continue; - if(!StackHelper.matches(liquidOutput, outputLiquid)) continue; - + if (!StackHelper.matches(liquidInput, inputLiquid)) continue; + if (!StackHelper.matches(liquidOutput, outputLiquid)) continue; + recipes.put(entry.getKey(), entry.getValue()); } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.SOLAR_EVAPORATION_PLANT.get(), recipes)); } else { - LogHelper.logWarning(String.format("No %s recipe found for %s and %s. Command ignored!", name, liquidInput.toString(), liquidOutput.toString())); + LogHelper.logWarning( + String.format( + "No %s recipe found for %s and %s. Command ignored!", + name, + liquidInput.toString(), + liquidOutput.toString())); } } } diff --git a/src/main/java/modtweaker2/mods/mekanism/handlers/SolarNeutronActivator.java b/src/main/java/modtweaker2/mods/mekanism/handlers/SolarNeutronActivator.java index a3f9742..801539e 100644 --- a/src/main/java/modtweaker2/mods/mekanism/handlers/SolarNeutronActivator.java +++ b/src/main/java/modtweaker2/mods/mekanism/handlers/SolarNeutronActivator.java @@ -28,50 +28,56 @@ import stanhebben.zenscript.annotations.ZenMethod; public class SolarNeutronActivator { public static final String name = "Mekanism Solar Evaporation"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @SuppressWarnings("unchecked") @ZenMethod public static void addRecipe(IGasStack gasInput, IGasStack gasOutput) { - if(gasInput == null || gasOutput == null) { + if (gasInput == null || gasOutput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - + SolarNeutronRecipe recipe = new SolarNeutronRecipe(toGas(gasInput), toGas(gasOutput)); - + MineTweakerAPI.apply(new AddMekanismRecipe(name, Recipe.SOLAR_NEUTRON_ACTIVATOR.get(), recipe)); } - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @SuppressWarnings({ "unchecked", "rawtypes" }) @ZenMethod public static void removeRecipe(IIngredient gasInput, @Optional IIngredient gasOutput) { - if(gasInput == null) { + if (gasInput == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - - if(gasOutput == null) gasOutput = IngredientAny.INSTANCE; + + if (gasOutput == null) gasOutput = IngredientAny.INSTANCE; Map recipes = new HashMap(); - for(Entry entry : ((Map)Recipe.SOLAR_NEUTRON_ACTIVATOR.get()).entrySet() ) { + for (Entry entry : ((Map) Recipe.SOLAR_NEUTRON_ACTIVATOR + .get()).entrySet()) { IGasStack inputGas = new MCGasStack(entry.getKey().ingredient); IGasStack outputGas = new MCGasStack(entry.getValue().recipeOutput.output); - if(!StackHelper.matches(gasInput, inputGas)) continue; - if(!StackHelper.matches(gasOutput, outputGas)) continue; - + if (!StackHelper.matches(gasInput, inputGas)) continue; + if (!StackHelper.matches(gasOutput, outputGas)) continue; + recipes.put(entry.getKey(), entry.getValue()); } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new RemoveMekanismRecipe(name, Recipe.SOLAR_NEUTRON_ACTIVATOR.get(), recipes)); } else { - LogHelper.logWarning(String.format("No %s recipe found for %s and %s. Command ignored!", name, gasInput.toString(), gasOutput.toString())); + LogHelper.logWarning( + String.format( + "No %s recipe found for %s and %s. Command ignored!", + name, + gasInput.toString(), + gasOutput.toString())); } } } diff --git a/src/main/java/modtweaker2/mods/mekanism/util/AddMekanismRecipe.java b/src/main/java/modtweaker2/mods/mekanism/util/AddMekanismRecipe.java index aa6ac56..b077348 100644 --- a/src/main/java/modtweaker2/mods/mekanism/util/AddMekanismRecipe.java +++ b/src/main/java/modtweaker2/mods/mekanism/util/AddMekanismRecipe.java @@ -17,36 +17,42 @@ import modtweaker2.utils.BaseMapAddition; @SuppressWarnings("rawtypes") public class AddMekanismRecipe extends BaseMapAddition { - public AddMekanismRecipe(String name, Map map, Map recipes) { - super(name, map, recipes); - } - - public AddMekanismRecipe(String name, Map map, MachineRecipe recipe) { - super(name, map); - - recipes.put(recipe.getInput(), recipe); - } - - @Override - protected String getRecipeInfo(Entry recipe) { - MachineOutput output = recipe.getValue().recipeOutput; - - if(output instanceof ItemStackOutput) { - return LogHelper.getStackDescription(((ItemStackOutput)output).output); + + public AddMekanismRecipe(String name, Map map, + Map recipes) { + super(name, map, recipes); + } + + public AddMekanismRecipe(String name, Map map, MachineRecipe recipe) { + super(name, map); + + recipes.put(recipe.getInput(), recipe); + } + + @Override + protected String getRecipeInfo(Entry recipe) { + MachineOutput output = recipe.getValue().recipeOutput; + + if (output instanceof ItemStackOutput) { + return LogHelper.getStackDescription(((ItemStackOutput) output).output); } else if (output instanceof GasOutput) { - return LogHelper.getStackDescription(((GasOutput)output).output); + return LogHelper.getStackDescription(((GasOutput) output).output); } else if (output instanceof FluidOutput) { - return LogHelper.getStackDescription(((FluidOutput)output).output); + return LogHelper.getStackDescription(((FluidOutput) output).output); } else if (output instanceof ChemicalPairOutput) { - return "[" + LogHelper.getStackDescription(((ChemicalPairOutput)output).leftGas) + ", " + - LogHelper.getStackDescription(((ChemicalPairOutput)output).rightGas) + "]"; + return "[" + LogHelper.getStackDescription(((ChemicalPairOutput) output).leftGas) + + ", " + + LogHelper.getStackDescription(((ChemicalPairOutput) output).rightGas) + + "]"; } else if (output instanceof ChanceOutput) { - return LogHelper.getStackDescription(((ChanceOutput)output).primaryOutput); + return LogHelper.getStackDescription(((ChanceOutput) output).primaryOutput); } else if (output instanceof PressurizedOutput) { - return "[" + LogHelper.getStackDescription(((PressurizedOutput)output).getItemOutput()) + ", " + - LogHelper.getStackDescription(((PressurizedOutput)output).getGasOutput()) + "]"; + return "[" + LogHelper.getStackDescription(((PressurizedOutput) output).getItemOutput()) + + ", " + + LogHelper.getStackDescription(((PressurizedOutput) output).getGasOutput()) + + "]"; } - - return null; - } + + return null; + } } diff --git a/src/main/java/modtweaker2/mods/mekanism/util/RemoveMekanismRecipe.java b/src/main/java/modtweaker2/mods/mekanism/util/RemoveMekanismRecipe.java index 53880f2..88abbf0 100644 --- a/src/main/java/modtweaker2/mods/mekanism/util/RemoveMekanismRecipe.java +++ b/src/main/java/modtweaker2/mods/mekanism/util/RemoveMekanismRecipe.java @@ -17,30 +17,36 @@ import modtweaker2.utils.BaseMapRemoval; @SuppressWarnings("rawtypes") public class RemoveMekanismRecipe extends BaseMapRemoval { - public RemoveMekanismRecipe(String name, Map map, Map recipes) { - super(name, map, recipes); - } - + + public RemoveMekanismRecipe(String name, Map map, + Map recipes) { + super(name, map, recipes); + } + @Override protected String getRecipeInfo(Entry recipe) { MachineOutput output = recipe.getValue().recipeOutput; - - if(output instanceof ItemStackOutput) { - return LogHelper.getStackDescription(((ItemStackOutput)output).output); + + if (output instanceof ItemStackOutput) { + return LogHelper.getStackDescription(((ItemStackOutput) output).output); } else if (output instanceof GasOutput) { - return LogHelper.getStackDescription(((GasOutput)output).output); + return LogHelper.getStackDescription(((GasOutput) output).output); } else if (output instanceof FluidOutput) { - return LogHelper.getStackDescription(((FluidOutput)output).output); + return LogHelper.getStackDescription(((FluidOutput) output).output); } else if (output instanceof ChemicalPairOutput) { - return "[" + LogHelper.getStackDescription(((ChemicalPairOutput)output).leftGas) + ", " + - LogHelper.getStackDescription(((ChemicalPairOutput)output).rightGas) + "]"; + return "[" + LogHelper.getStackDescription(((ChemicalPairOutput) output).leftGas) + + ", " + + LogHelper.getStackDescription(((ChemicalPairOutput) output).rightGas) + + "]"; } else if (output instanceof ChanceOutput) { - return LogHelper.getStackDescription(((ChanceOutput)output).primaryOutput); + return LogHelper.getStackDescription(((ChanceOutput) output).primaryOutput); } else if (output instanceof PressurizedOutput) { - return "[" + LogHelper.getStackDescription(((PressurizedOutput)output).getItemOutput()) + ", " + - LogHelper.getStackDescription(((PressurizedOutput)output).getGasOutput()) + "]"; + return "[" + LogHelper.getStackDescription(((PressurizedOutput) output).getItemOutput()) + + ", " + + LogHelper.getStackDescription(((PressurizedOutput) output).getGasOutput()) + + "]"; } - + return null; } } diff --git a/src/main/java/modtweaker2/mods/metallurgy/Metallurgy.java b/src/main/java/modtweaker2/mods/metallurgy/Metallurgy.java index 77f7eac..0402c48 100644 --- a/src/main/java/modtweaker2/mods/metallurgy/Metallurgy.java +++ b/src/main/java/modtweaker2/mods/metallurgy/Metallurgy.java @@ -5,6 +5,7 @@ import modtweaker2.mods.metallurgy.handlers.Alloyer; import modtweaker2.mods.metallurgy.handlers.Crusher; public class Metallurgy { + public Metallurgy() { MineTweakerAPI.registerClass(Alloyer.class); MineTweakerAPI.registerClass(Crusher.class); diff --git a/src/main/java/modtweaker2/mods/metallurgy/MetallurgyHelper.java b/src/main/java/modtweaker2/mods/metallurgy/MetallurgyHelper.java index 52f2b5a..49847a6 100644 --- a/src/main/java/modtweaker2/mods/metallurgy/MetallurgyHelper.java +++ b/src/main/java/modtweaker2/mods/metallurgy/MetallurgyHelper.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.HashMap; import modtweaker2.helpers.ReflectionHelper; + import net.minecraft.item.ItemStack; import com.teammetallurgy.metallurgy.recipes.AlloyerRecipes; @@ -11,40 +12,39 @@ import com.teammetallurgy.metallurgy.recipes.AlloyerRecipes.AlloyRecipe; import com.teammetallurgy.metallurgy.recipes.CrusherRecipes; public class MetallurgyHelper { - public static ArrayList alloyerRecipes = null; - public static HashMap crusherMetaList = null; - public static HashMap crusherInputList = null; - static { - try { - alloyerRecipes = ReflectionHelper.getFinalObject(AlloyerRecipes.getInstance(), "recipes"); - crusherMetaList = ReflectionHelper.getFinalObject(CrusherRecipes.getInstance(), "metaList"); - crusherInputList = ReflectionHelper.getFinalObject(CrusherRecipes.getInstance(), "inputList"); - } catch (Exception e) { - } - } + public static ArrayList alloyerRecipes = null; + public static HashMap crusherMetaList = null; + public static HashMap crusherInputList = null; - private MetallurgyHelper() { - } + static { + try { + alloyerRecipes = ReflectionHelper.getFinalObject(AlloyerRecipes.getInstance(), "recipes"); + crusherMetaList = ReflectionHelper.getFinalObject(CrusherRecipes.getInstance(), "metaList"); + crusherInputList = ReflectionHelper.getFinalObject(CrusherRecipes.getInstance(), "inputList"); + } catch (Exception e) {} + } - public static String getCrusherKey(ItemStack input) { - return input.getUnlocalizedName(); - } + private MetallurgyHelper() {} - // Returns a Drying Recipe, using reflection as the constructor is not - // visible - public static AlloyRecipe getAlloyRecipe(ItemStack first, ItemStack base, ItemStack result) { - try { - // Constructor constructor = - // AlloyRecipe.class.getDeclaredConstructor(ItemStack.class, - // ItemStack.class, ItemStack.class); - // constructor.setAccessible(true); - // return (AlloyRecipe) constructor.newInstance(first, base, - // result); - return AlloyerRecipes.getInstance().new AlloyRecipe(first, base, result); - } catch (Exception e) { - e.printStackTrace(); - throw new NullPointerException("Failed to instantiate AlloyRecipe"); - } - } + public static String getCrusherKey(ItemStack input) { + return input.getUnlocalizedName(); + } + + // Returns a Drying Recipe, using reflection as the constructor is not + // visible + public static AlloyRecipe getAlloyRecipe(ItemStack first, ItemStack base, ItemStack result) { + try { + // Constructor constructor = + // AlloyRecipe.class.getDeclaredConstructor(ItemStack.class, + // ItemStack.class, ItemStack.class); + // constructor.setAccessible(true); + // return (AlloyRecipe) constructor.newInstance(first, base, + // result); + return AlloyerRecipes.getInstance().new AlloyRecipe(first, base, result); + } catch (Exception e) { + e.printStackTrace(); + throw new NullPointerException("Failed to instantiate AlloyRecipe"); + } + } } diff --git a/src/main/java/modtweaker2/mods/metallurgy/handlers/Alloyer.java b/src/main/java/modtweaker2/mods/metallurgy/handlers/Alloyer.java index 35db6b3..6b12dac 100644 --- a/src/main/java/modtweaker2/mods/metallurgy/handlers/Alloyer.java +++ b/src/main/java/modtweaker2/mods/metallurgy/handlers/Alloyer.java @@ -21,17 +21,18 @@ import com.teammetallurgy.metallurgy.recipes.AlloyerRecipes.AlloyRecipe; @ZenClass("mods.metallurgy.Alloyer") public class Alloyer { - + public static final String name = "Metallurgy Alloyer"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @ZenMethod public static void addRecipe(IItemStack first, IItemStack base, IItemStack result) { MineTweakerAPI.apply(new Add(MetallurgyHelper.getAlloyRecipe(toStack(first), toStack(base), toStack(result)))); } private static class Add extends BaseListAddition { + public Add(AlloyRecipe recipe) { super(Alloyer.name, MetallurgyHelper.alloyerRecipes); recipes.add(recipe); @@ -48,7 +49,7 @@ public class Alloyer { @ZenMethod public static void removeRecipe(IIngredient output) { List recipes = new LinkedList(); - + for (AlloyRecipe r : MetallurgyHelper.alloyerRecipes) { if (r != null && r.getCraftingResult() != null && matches(output, toIItemStack(r.getCraftingResult()))) { recipes.add(r); @@ -58,6 +59,7 @@ public class Alloyer { } private static class Remove extends BaseListRemoval { + public Remove(List recipes) { super(Alloyer.name, MetallurgyHelper.alloyerRecipes, recipes); } diff --git a/src/main/java/modtweaker2/mods/metallurgy/handlers/Crusher.java b/src/main/java/modtweaker2/mods/metallurgy/handlers/Crusher.java index d966083..32e358c 100644 --- a/src/main/java/modtweaker2/mods/metallurgy/handlers/Crusher.java +++ b/src/main/java/modtweaker2/mods/metallurgy/handlers/Crusher.java @@ -11,19 +11,23 @@ import modtweaker2.helpers.LogHelper; import modtweaker2.mods.metallurgy.MetallurgyHelper; import modtweaker2.utils.BaseMapAddition; import modtweaker2.utils.BaseMapRemoval; + import net.minecraft.item.ItemStack; + import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; @ZenClass("mods.metallurgy.Crusher") public class Crusher { - //Adding a Metallurgy Crusher Recipe + + // Adding a Metallurgy Crusher Recipe @ZenMethod public static void addRecipe(IItemStack input, IItemStack output) { MineTweakerAPI.apply(new Add(toStack(input), toStack(output))); } private static class Add extends BaseMapAddition { + private final ItemStack stack; public Add(ItemStack input, ItemStack output) { @@ -35,7 +39,7 @@ public class Crusher { @Override public void apply() { super.apply(); - for(Entry recipe : successful.entrySet()) { + for (Entry recipe : successful.entrySet()) { addToInput(stack, recipe.getValue()); } } @@ -43,11 +47,11 @@ public class Crusher { @Override public void undo() { super.undo(); - for(Entry recipe : successful.entrySet()) { + for (Entry recipe : successful.entrySet()) { removeFromInput(stack, recipe.getValue()); } } - + @Override protected String getRecipeInfo(Entry recipe) { return LogHelper.getStackDescription(stack); @@ -56,26 +60,29 @@ public class Crusher { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //Removing a Metallurgy Crusher recipe + // Removing a Metallurgy Crusher recipe @ZenMethod public static void removeRecipe(IItemStack input) { MineTweakerAPI.apply(new Remove(toStack(input))); } private static class Remove extends BaseMapRemoval { + private ItemStack stack; - + public Remove(ItemStack stack) { super("Metallurgy Crusher", MetallurgyHelper.crusherMetaList); - - recipes.put(MetallurgyHelper.getCrusherKey(stack), MetallurgyHelper.crusherMetaList.get(MetallurgyHelper.getCrusherKey(stack))); + + recipes.put( + MetallurgyHelper.getCrusherKey(stack), + MetallurgyHelper.crusherMetaList.get(MetallurgyHelper.getCrusherKey(stack))); this.stack = stack; } @Override public void apply() { super.apply(); - for(Entry recipe : successful.entrySet()) { + for (Entry recipe : successful.entrySet()) { removeFromInput(stack, recipe.getValue()); } } @@ -83,18 +90,18 @@ public class Crusher { @Override public void undo() { super.undo(); - for(Entry recipe : successful.entrySet()) { + for (Entry recipe : successful.entrySet()) { addToInput(stack, recipe.getValue()); } } - + @Override protected String getRecipeInfo(Entry recipe) { return LogHelper.getStackDescription(stack); } } - //Helper Methods + // Helper Methods private static void addToInput(ItemStack input, ItemStack output) { ItemStack[] inputList = MetallurgyHelper.crusherInputList.get(output.getUnlocalizedName()); if (inputList == null) { diff --git a/src/main/java/modtweaker2/mods/pneumaticcraft/PneumaticCraft.java b/src/main/java/modtweaker2/mods/pneumaticcraft/PneumaticCraft.java index b5bd5fb..40bc799 100644 --- a/src/main/java/modtweaker2/mods/pneumaticcraft/PneumaticCraft.java +++ b/src/main/java/modtweaker2/mods/pneumaticcraft/PneumaticCraft.java @@ -5,6 +5,7 @@ import modtweaker2.mods.pneumaticcraft.handlers.Assembly; import modtweaker2.mods.pneumaticcraft.handlers.Pressure; public class PneumaticCraft { + public PneumaticCraft() { MineTweakerAPI.registerClass(Assembly.class); MineTweakerAPI.registerClass(Pressure.class); diff --git a/src/main/java/modtweaker2/mods/pneumaticcraft/handlers/Assembly.java b/src/main/java/modtweaker2/mods/pneumaticcraft/handlers/Assembly.java index 529be79..7cbd968 100644 --- a/src/main/java/modtweaker2/mods/pneumaticcraft/handlers/Assembly.java +++ b/src/main/java/modtweaker2/mods/pneumaticcraft/handlers/Assembly.java @@ -14,18 +14,20 @@ import minetweaker.api.item.IItemStack; import modtweaker2.helpers.LogHelper; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; + import net.minecraft.item.ItemStack; + import pneumaticCraft.api.recipe.AssemblyRecipe; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; @ZenClass("mods.pneumaticcraft.Assembly") public class Assembly { - + public static final String name = "PneumaticCraft Assembly"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @ZenMethod public static void addDrillRecipe(IItemStack input, IItemStack output) { addRecipe(input, output, AssemblyRecipe.drillRecipes); @@ -40,26 +42,31 @@ public class Assembly { public static void addLaserDrillRecipe(IItemStack input, IItemStack output) { addRecipe(input, output, AssemblyRecipe.drillLaserRecipes); } - + public static void addRecipe(IItemStack input, IItemStack output, List list) { - if(input == null || output == null) { + if (input == null || output == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - + ItemStack in = toStack(input); - - for(AssemblyRecipe recipe : list) { - if(areEqual(recipe.getInput(), in)) { - LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s. Command ignored!", name, LogHelper.getStackDescription(in))); + + for (AssemblyRecipe recipe : list) { + if (areEqual(recipe.getInput(), in)) { + LogHelper.logWarning( + String.format( + "Duplicate %s Recipe found for %s. Command ignored!", + name, + LogHelper.getStackDescription(in))); return; } } - + MineTweakerAPI.apply(new Add(new AssemblyRecipe(toStack(input), toStack(output)), list)); } private static class Add extends BaseListAddition { + public Add(AssemblyRecipe recipe, List list) { super(Assembly.name, list); recipes.add(recipe); @@ -87,17 +94,17 @@ public class Assembly { public static void removeLaserDrillRecipe(IIngredient output) { removeRecipe(AssemblyRecipe.drillLaserRecipes, output); } - + public static void removeRecipe(List list, IIngredient output) { List recipes = new LinkedList(); - + for (AssemblyRecipe r : list) { if (r.getOutput() != null && matches(output, toIItemStack(r.getOutput()))) { recipes.add(r); } } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new Remove(list, recipes)); } else { LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", name, output.toString())); @@ -105,6 +112,7 @@ public class Assembly { } private static class Remove extends BaseListRemoval { + public Remove(List list, List recipes) { super(Assembly.name, list, recipes); } diff --git a/src/main/java/modtweaker2/mods/pneumaticcraft/handlers/Pressure.java b/src/main/java/modtweaker2/mods/pneumaticcraft/handlers/Pressure.java index 615fdd0..2488254 100644 --- a/src/main/java/modtweaker2/mods/pneumaticcraft/handlers/Pressure.java +++ b/src/main/java/modtweaker2/mods/pneumaticcraft/handlers/Pressure.java @@ -13,27 +13,31 @@ import minetweaker.api.item.IItemStack; import modtweaker2.helpers.LogHelper; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; + import net.minecraft.item.ItemStack; + import pneumaticCraft.api.recipe.PressureChamberRecipe; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; @ZenClass("mods.pneumaticcraft.Pressure") public class Pressure { - + public static final String name = "PneumaticCraft Pressure Chamber"; - + @ZenMethod public static void addRecipe(IItemStack[] input, double pressure, IItemStack[] output, boolean asBlock) { - if(input == null || output == null) { + if (input == null || output == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - - MineTweakerAPI.apply(new Add(new PressureChamberRecipe(toStacks(input), (float) pressure, toStacks(output), asBlock))); + + MineTweakerAPI.apply( + new Add(new PressureChamberRecipe(toStacks(input), (float) pressure, toStacks(output), asBlock))); } private static class Add extends BaseListAddition { + public Add(PressureChamberRecipe recipe) { super(Pressure.name, PressureChamberRecipe.chamberRecipes); recipes.add(recipe); @@ -50,12 +54,12 @@ public class Pressure { @ZenMethod public static void removeRecipe(IIngredient[] output) { List recipes = new LinkedList(); - + for (PressureChamberRecipe r : PressureChamberRecipe.chamberRecipes) { - if(r != null) { + if (r != null) { boolean matches = true; for (IIngredient ingredient : output) { - for(ItemStack stack : r.output) { + for (ItemStack stack : r.output) { if (!matches(ingredient, toIItemStack(stack))) { matches = false; break; @@ -73,10 +77,11 @@ public class Pressure { } private static class Remove extends BaseListRemoval { + public Remove(List recipes) { super(Pressure.name, PressureChamberRecipe.chamberRecipes, recipes); } - + @Override public String getRecipeInfo(PressureChamberRecipe recipe) { return LogHelper.getStackDescription(recipe.output[0]); diff --git a/src/main/java/modtweaker2/mods/railcraft/Railcraft.java b/src/main/java/modtweaker2/mods/railcraft/Railcraft.java index 15670d9..524f4a6 100644 --- a/src/main/java/modtweaker2/mods/railcraft/Railcraft.java +++ b/src/main/java/modtweaker2/mods/railcraft/Railcraft.java @@ -7,6 +7,7 @@ import modtweaker2.mods.railcraft.handlers.RockCrusher; import modtweaker2.mods.railcraft.handlers.RollingMachine; public class Railcraft { + public Railcraft() { MineTweakerAPI.registerClass(BlastFurnace.class); MineTweakerAPI.registerClass(CokeOven.class); diff --git a/src/main/java/modtweaker2/mods/railcraft/RailcraftHelper.java b/src/main/java/modtweaker2/mods/railcraft/RailcraftHelper.java index 8f829f7..fccc761 100644 --- a/src/main/java/modtweaker2/mods/railcraft/RailcraftHelper.java +++ b/src/main/java/modtweaker2/mods/railcraft/RailcraftHelper.java @@ -13,11 +13,13 @@ import mods.railcraft.common.util.crafting.CokeOvenCraftingManager.CokeOvenRecip import mods.railcraft.common.util.crafting.RockCrusherCraftingManager.CrusherRecipe; import modtweaker2.helpers.LogHelper; import modtweaker2.helpers.ReflectionHelper; + import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraftforge.fluids.FluidStack; public class RailcraftHelper { + public static List furnace = null; public static List oven = null; public static List crusher = null; @@ -29,17 +31,31 @@ public class RailcraftHelper { oven = RailcraftCraftingManager.cokeOven.getRecipes(); crusher = RailcraftCraftingManager.rockCrusher.getRecipes(); rolling = RailcraftCraftingManager.rollingMachine.getRecipeList(); - - fuels = new ArrayList(RailcraftCraftingManager.blastFurnace.getFuels()); - ReflectionHelper.setPrivateValue(BlastFurnaceCraftingManager.class, RailcraftCraftingManager.blastFurnace, "fuels", fuels); - } catch (Exception e) { LogHelper.logError("Error in RailcraftHelper", e); } + fuels = new ArrayList(RailcraftCraftingManager.blastFurnace.getFuels()); + ReflectionHelper.setPrivateValue( + BlastFurnaceCraftingManager.class, + RailcraftCraftingManager.blastFurnace, + "fuels", + fuels); + + } catch (Exception e) { + LogHelper.logError("Error in RailcraftHelper", e); + } } private RailcraftHelper() {} - public static IBlastFurnaceRecipe getBlastFurnaceRecipe(ItemStack input, boolean matchDamage, boolean matchNBT, int cookTime, ItemStack output) { - return ReflectionHelper.getInstance(ReflectionHelper.getConstructor(BlastFurnaceRecipe.class,ItemStack.class, boolean.class, boolean.class, int.class, ItemStack.class), + public static IBlastFurnaceRecipe getBlastFurnaceRecipe(ItemStack input, boolean matchDamage, boolean matchNBT, + int cookTime, ItemStack output) { + return ReflectionHelper.getInstance( + ReflectionHelper.getConstructor( + BlastFurnaceRecipe.class, + ItemStack.class, + boolean.class, + boolean.class, + int.class, + ItemStack.class), input, matchDamage, matchNBT, @@ -47,8 +63,17 @@ public class RailcraftHelper { output); } - public static ICokeOvenRecipe getCokeOvenRecipe(ItemStack input, boolean matchDamage, boolean matchNBT, ItemStack output, FluidStack fluidOutput, int cookTime) { - return ReflectionHelper.getInstance(ReflectionHelper.getConstructor(CokeOvenRecipe.class, ItemStack.class, boolean.class, boolean.class, ItemStack.class, FluidStack.class, int.class), + public static ICokeOvenRecipe getCokeOvenRecipe(ItemStack input, boolean matchDamage, boolean matchNBT, + ItemStack output, FluidStack fluidOutput, int cookTime) { + return ReflectionHelper.getInstance( + ReflectionHelper.getConstructor( + CokeOvenRecipe.class, + ItemStack.class, + boolean.class, + boolean.class, + ItemStack.class, + FluidStack.class, + int.class), input, matchDamage, matchNBT, @@ -58,7 +83,8 @@ public class RailcraftHelper { } public static IRockCrusherRecipe getRockCrusherRecipe(ItemStack stack, boolean matchDamage, boolean matchNBT) { - return ReflectionHelper.getInstance(ReflectionHelper.getConstructor(CrusherRecipe.class, ItemStack.class, boolean.class, boolean.class), + return ReflectionHelper.getInstance( + ReflectionHelper.getConstructor(CrusherRecipe.class, ItemStack.class, boolean.class, boolean.class), stack, matchDamage, matchNBT); diff --git a/src/main/java/modtweaker2/mods/railcraft/commands/RailcraftLogger.java b/src/main/java/modtweaker2/mods/railcraft/commands/RailcraftLogger.java index 183eb95..27fcafb 100644 --- a/src/main/java/modtweaker2/mods/railcraft/commands/RailcraftLogger.java +++ b/src/main/java/modtweaker2/mods/railcraft/commands/RailcraftLogger.java @@ -17,94 +17,108 @@ import modtweaker2.helpers.LogHelper; import modtweaker2.helpers.ReflectionHelper; import modtweaker2.helpers.StringHelper; import modtweaker2.mods.railcraft.RailcraftHelper; + import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; public class RailcraftLogger implements ICommandFunction { private static final List validArguments = new LinkedList(); - + static { validArguments.add("BlastFurnace"); validArguments.add("CokeOven"); validArguments.add("RockCrusher"); validArguments.add("RollingMachine"); } - + @Override public void execute(String[] arguments, IPlayer player) { List args = StringHelper.toLowerCase(Arrays.asList(arguments)); - - if(!validArguments.containsAll(args)) { - if(player != null) { - player.sendChat(MineTweakerImplementationAPI.platform.getMessage("Invalid arguments for command. Valid arguments: " + StringHelper.join(validArguments, ", "))); + + if (!validArguments.containsAll(args)) { + if (player != null) { + player.sendChat( + MineTweakerImplementationAPI.platform.getMessage( + "Invalid arguments for command. Valid arguments: " + + StringHelper.join(validArguments, ", "))); } } else { - if(args.isEmpty() || args.contains("BlastFurnace")) { - for(IBlastFurnaceRecipe recipe : RailcraftHelper.furnace) { - MineTweakerAPI.logCommand(String.format("mods.railcraft.BlastFurnace.addRecipe(%s, %s, %s, %d, %s);", - LogHelper.getStackDescription(recipe.getInput()), - ReflectionHelper.getObject(recipe, "matchDamage"), - ReflectionHelper.getObject(recipe, "matchNBT"), - recipe.getCookTime(), - LogHelper.getStackDescription(recipe.getOutput()))); + if (args.isEmpty() || args.contains("BlastFurnace")) { + for (IBlastFurnaceRecipe recipe : RailcraftHelper.furnace) { + MineTweakerAPI.logCommand( + String.format( + "mods.railcraft.BlastFurnace.addRecipe(%s, %s, %s, %d, %s);", + LogHelper.getStackDescription(recipe.getInput()), + ReflectionHelper.getObject(recipe, "matchDamage"), + ReflectionHelper.getObject(recipe, "matchNBT"), + recipe.getCookTime(), + LogHelper.getStackDescription(recipe.getOutput()))); } } - - if(args.isEmpty() || args.contains("CokeOven")) { - for(ICokeOvenRecipe recipe : RailcraftCraftingManager.cokeOven.getRecipes()) { - MineTweakerAPI.logCommand(String.format("mods.railcraft.CokeOven.addRecipe(%s, %s, %s, %s, %s, %d);", - LogHelper.getStackDescription(recipe.getInput()), - ReflectionHelper.getObject(recipe, "matchDamage"), - ReflectionHelper.getObject(recipe, "matchNBT"), - LogHelper.getStackDescription(recipe.getOutput()), - LogHelper.getStackDescription(recipe.getFluidOutput()), - recipe.getCookTime())); + + if (args.isEmpty() || args.contains("CokeOven")) { + for (ICokeOvenRecipe recipe : RailcraftCraftingManager.cokeOven.getRecipes()) { + MineTweakerAPI.logCommand( + String.format( + "mods.railcraft.CokeOven.addRecipe(%s, %s, %s, %s, %s, %d);", + LogHelper.getStackDescription(recipe.getInput()), + ReflectionHelper.getObject(recipe, "matchDamage"), + ReflectionHelper.getObject(recipe, "matchNBT"), + LogHelper.getStackDescription(recipe.getOutput()), + LogHelper.getStackDescription(recipe.getFluidOutput()), + recipe.getCookTime())); } } - - if(args.isEmpty() || args.contains("RockCrusher")) { - for(IRockCrusherRecipe recipe : RailcraftHelper.crusher) { - MineTweakerAPI.logCommand(String.format("mods.railcraft.RockCrusher.addRecipe(%s, %s, %s, %s);", - LogHelper.getStackDescription(recipe.getInput()), - ReflectionHelper.getObject(recipe, "matchDamage"), - ReflectionHelper.getObject(recipe, "matchNBT"), - getRockCrusherOutputDescription(recipe.getOutputs()))); + + if (args.isEmpty() || args.contains("RockCrusher")) { + for (IRockCrusherRecipe recipe : RailcraftHelper.crusher) { + MineTweakerAPI.logCommand( + String.format( + "mods.railcraft.RockCrusher.addRecipe(%s, %s, %s, %s);", + LogHelper.getStackDescription(recipe.getInput()), + ReflectionHelper.getObject(recipe, "matchDamage"), + ReflectionHelper.getObject(recipe, "matchNBT"), + getRockCrusherOutputDescription(recipe.getOutputs()))); } } - - if(args.isEmpty() || args.contains("RollingMachine")) { - for(IRecipe recipe : RailcraftHelper.rolling) { - MineTweakerAPI.logCommand(String.format("mods.railcraft.RollingMachine.addRecipe(%s, %s);", - LogHelper.getStackDescription(recipe.getRecipeOutput()), - LogHelper.getCraftingDescription(recipe))); + + if (args.isEmpty() || args.contains("RollingMachine")) { + for (IRecipe recipe : RailcraftHelper.rolling) { + MineTweakerAPI.logCommand( + String.format( + "mods.railcraft.RollingMachine.addRecipe(%s, %s);", + LogHelper.getStackDescription(recipe.getRecipeOutput()), + LogHelper.getCraftingDescription(recipe))); } } - + if (player != null) { - player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir")); + player.sendChat( + MineTweakerImplementationAPI.platform + .getMessage("List generated; see minetweaker.log in your minecraft dir")); } } } private Object getRockCrusherOutputDescription(List> outputs) { - if(outputs.isEmpty()) { + if (outputs.isEmpty()) { return "[], []"; } - + StringBuilder sb = new StringBuilder(); sb.append('['); - for(Entry entry : outputs) { + for (Entry entry : outputs) { sb.append(LogHelper.getStackDescription(entry.getKey())).append(", "); } sb.setLength(sb.length() - 2); sb.append("], ["); - for(Entry entry : outputs) { + for (Entry entry : outputs) { sb.append(entry.getValue()).append(", "); } sb.setLength(sb.length() - 2); sb.append("]"); - + return sb.toString(); } } diff --git a/src/main/java/modtweaker2/mods/railcraft/handlers/BlastFurnace.java b/src/main/java/modtweaker2/mods/railcraft/handlers/BlastFurnace.java index c9f709d..850071f 100644 --- a/src/main/java/modtweaker2/mods/railcraft/handlers/BlastFurnace.java +++ b/src/main/java/modtweaker2/mods/railcraft/handlers/BlastFurnace.java @@ -1,5 +1,12 @@ package modtweaker2.mods.railcraft.handlers; +import static modtweaker2.helpers.InputHelper.toIItemStack; +import static modtweaker2.helpers.InputHelper.toStack; +import static modtweaker2.helpers.StackHelper.matches; + +import java.util.LinkedList; +import java.util.List; + import minetweaker.MineTweakerAPI; import minetweaker.api.item.IIngredient; import minetweaker.api.item.IItemStack; @@ -10,182 +17,199 @@ import modtweaker2.helpers.StackHelper; import modtweaker2.mods.railcraft.RailcraftHelper; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; + import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntityFurnace; import net.minecraftforge.oredict.OreDictionary; + import stanhebben.zenscript.annotations.Optional; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; -import java.util.LinkedList; -import java.util.List; - -import static modtweaker2.helpers.InputHelper.toIItemStack; -import static modtweaker2.helpers.InputHelper.toStack; -import static modtweaker2.helpers.StackHelper.matches; - @ZenClass("mods.railcraft.BlastFurnace") public class BlastFurnace { - public static final String name = "Railcraft Blast Furnace"; - public static final String nameFuel = "Railcraft Blast Furnace (Fuel)"; + public static final String name = "Railcraft Blast Furnace"; + public static final String nameFuel = "Railcraft Blast Furnace (Fuel)"; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /** - * Add a recipe for the Blast Furnace - * - * @param output ItemStack result - * @param input ItemStack input - * @param cookTime time per item to process - * @param matchEmptyNBT Set this to true, if you want to match only input items strictly without NBT Data) - */ - @ZenMethod - public static void addRecipe(IItemStack output, IItemStack input, int cookTime, @Optional Boolean matchEmptyNBT) { - if (matchEmptyNBT == null) - if (toStack(input).stackTagCompound == null) - matchEmptyNBT = false; - else - matchEmptyNBT = true; + /** + * Add a recipe for the Blast Furnace + * + * @param output ItemStack result + * @param input ItemStack input + * @param cookTime time per item to process + * @param matchEmptyNBT Set this to true, if you want to match only input items strictly without NBT Data) + */ + @ZenMethod + public static void addRecipe(IItemStack output, IItemStack input, int cookTime, @Optional Boolean matchEmptyNBT) { + if (matchEmptyNBT == null) if (toStack(input).stackTagCompound == null) matchEmptyNBT = false; + else matchEmptyNBT = true; - if (input.getDamage() == OreDictionary.WILDCARD_VALUE) - MineTweakerAPI.apply(new Add(RailcraftHelper.getBlastFurnaceRecipe(toStack(input), false, matchEmptyNBT, cookTime, toStack(output)))); - else - MineTweakerAPI.apply(new Add(RailcraftHelper.getBlastFurnaceRecipe(toStack(input), true, matchEmptyNBT, cookTime, toStack(output)))); - } + if (input.getDamage() == OreDictionary.WILDCARD_VALUE) MineTweakerAPI.apply( + new Add( + RailcraftHelper.getBlastFurnaceRecipe( + toStack(input), + false, + matchEmptyNBT, + cookTime, + toStack(output)))); + else MineTweakerAPI.apply( + new Add( + RailcraftHelper.getBlastFurnaceRecipe( + toStack(input), + true, + matchEmptyNBT, + cookTime, + toStack(output)))); + } - @Deprecated - @ZenMethod - public static void addRecipe(IItemStack input, boolean matchDamage, boolean matchNBT, int cookTime, IItemStack output) { - if (input == null || output == null) { - LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); - return; - } + @Deprecated + @ZenMethod + public static void addRecipe(IItemStack input, boolean matchDamage, boolean matchNBT, int cookTime, + IItemStack output) { + if (input == null || output == null) { + LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); + return; + } - MineTweakerAPI.apply(new Add(RailcraftHelper.getBlastFurnaceRecipe(toStack(input), matchDamage, matchNBT, cookTime, toStack(output)))); - } + MineTweakerAPI.apply( + new Add( + RailcraftHelper.getBlastFurnaceRecipe( + toStack(input), + matchDamage, + matchNBT, + cookTime, + toStack(output)))); + } - private static class Add extends BaseListAddition { - @SuppressWarnings("unchecked") - public Add(IBlastFurnaceRecipe recipe) { - super(BlastFurnace.name, (List) RailcraftHelper.furnace); - recipes.add(recipe); - } + private static class Add extends BaseListAddition { - @Override - public String getRecipeInfo(IBlastFurnaceRecipe recipe) { - return LogHelper.getStackDescription(recipe.getOutput()); - } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + @SuppressWarnings("unchecked") + public Add(IBlastFurnaceRecipe recipe) { + super(BlastFurnace.name, (List) RailcraftHelper.furnace); + recipes.add(recipe); + } - @ZenMethod - public static void removeRecipe(IIngredient output) { - if (output == null) { - LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); - return; - } + @Override + public String getRecipeInfo(IBlastFurnaceRecipe recipe) { + return LogHelper.getStackDescription(recipe.getOutput()); + } + } - List recipes = new LinkedList(); + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - for (IBlastFurnaceRecipe r : RailcraftHelper.furnace) { - if (r != null && r.getOutput() != null && matches(output, toIItemStack(r.getOutput()))) { - recipes.add(r); - } - } + @ZenMethod + public static void removeRecipe(IIngredient output) { + if (output == null) { + LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); + return; + } - if (!recipes.isEmpty()) { - MineTweakerAPI.apply(new Remove(recipes)); - } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", BlastFurnace.name, output.toString())); - } - } + List recipes = new LinkedList(); - private static class Remove extends BaseListRemoval { - @SuppressWarnings("unchecked") - public Remove(List recipes) { - super(BlastFurnace.name, (List) RailcraftHelper.furnace, recipes); - } + for (IBlastFurnaceRecipe r : RailcraftHelper.furnace) { + if (r != null && r.getOutput() != null && matches(output, toIItemStack(r.getOutput()))) { + recipes.add(r); + } + } - @Override - public String getRecipeInfo(IBlastFurnaceRecipe recipe) { - return LogHelper.getStackDescription(recipe.getOutput()); - } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - @ZenMethod - public static void addFuel(IIngredient itemInput) { - if (itemInput == null) { - LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); - return; - } + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new Remove(recipes)); + } else { + LogHelper.logWarning( + String.format("No %s Recipe found for %s. Command ignored!", BlastFurnace.name, output.toString())); + } + } - List fuels = new LinkedList(); + private static class Remove extends BaseListRemoval { - for (IItemStack item : itemInput.getItems()) { + @SuppressWarnings("unchecked") + public Remove(List recipes) { + super(BlastFurnace.name, (List) RailcraftHelper.furnace, recipes); + } - boolean match = false; + @Override + public String getRecipeInfo(IBlastFurnaceRecipe recipe) { + return LogHelper.getStackDescription(recipe.getOutput()); + } + } - for (ItemStack fuel : RailcraftHelper.fuels) { - if (StackHelper.matches(item, InputHelper.toIItemStack(fuel))) { - match = true; - break; - } - } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - if (!match && TileEntityFurnace.isItemFuel(InputHelper.toStack(item))) { - fuels.add(InputHelper.toStack(item)); - } - } + @ZenMethod + public static void addFuel(IIngredient itemInput) { + if (itemInput == null) { + LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); + return; + } - if (!fuels.isEmpty()) { - MineTweakerAPI.apply(new AddFuels(fuels)); - } else { - LogHelper.logWarning(String.format("No %s added.", nameFuel)); - } - } - - private static class AddFuels extends BaseListAddition { - public AddFuels(List fuels) { - super(BlastFurnace.nameFuel, RailcraftHelper.fuels, fuels); - } + List fuels = new LinkedList(); - @Override - protected String getRecipeInfo(ItemStack recipe) { - return LogHelper.getStackDescription(recipe); - } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - @ZenMethod - public static void removeFuel(IIngredient itemInput) { - List fuels = new LinkedList(); + for (IItemStack item : itemInput.getItems()) { - for (ItemStack fuel : RailcraftHelper.fuels) { - if (StackHelper.matches(itemInput, InputHelper.toIItemStack(fuel))) { - fuels.add(fuel); - } - } + boolean match = false; - if (!fuels.isEmpty()) { - MineTweakerAPI.apply(new RemoveFuels(fuels)); - } else { - LogHelper.logWarning(String.format("No %s found for argument %s.", nameFuel, itemInput.toString())); - } - } - - private static class RemoveFuels extends BaseListRemoval { - public RemoveFuels(List fuels) { - super(BlastFurnace.nameFuel, RailcraftHelper.fuels, fuels); - } + for (ItemStack fuel : RailcraftHelper.fuels) { + if (StackHelper.matches(item, InputHelper.toIItemStack(fuel))) { + match = true; + break; + } + } - @Override - protected String getRecipeInfo(ItemStack recipe) { - return LogHelper.getStackDescription(recipe); - } - } + if (!match && TileEntityFurnace.isItemFuel(InputHelper.toStack(item))) { + fuels.add(InputHelper.toStack(item)); + } + } + + if (!fuels.isEmpty()) { + MineTweakerAPI.apply(new AddFuels(fuels)); + } else { + LogHelper.logWarning(String.format("No %s added.", nameFuel)); + } + } + + private static class AddFuels extends BaseListAddition { + + public AddFuels(List fuels) { + super(BlastFurnace.nameFuel, RailcraftHelper.fuels, fuels); + } + + @Override + protected String getRecipeInfo(ItemStack recipe) { + return LogHelper.getStackDescription(recipe); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + @ZenMethod + public static void removeFuel(IIngredient itemInput) { + List fuels = new LinkedList(); + + for (ItemStack fuel : RailcraftHelper.fuels) { + if (StackHelper.matches(itemInput, InputHelper.toIItemStack(fuel))) { + fuels.add(fuel); + } + } + + if (!fuels.isEmpty()) { + MineTweakerAPI.apply(new RemoveFuels(fuels)); + } else { + LogHelper.logWarning(String.format("No %s found for argument %s.", nameFuel, itemInput.toString())); + } + } + + private static class RemoveFuels extends BaseListRemoval { + + public RemoveFuels(List fuels) { + super(BlastFurnace.nameFuel, RailcraftHelper.fuels, fuels); + } + + @Override + protected String getRecipeInfo(ItemStack recipe) { + return LogHelper.getStackDescription(recipe); + } + } } diff --git a/src/main/java/modtweaker2/mods/railcraft/handlers/CokeOven.java b/src/main/java/modtweaker2/mods/railcraft/handlers/CokeOven.java index 5ff8859..6464ee1 100644 --- a/src/main/java/modtweaker2/mods/railcraft/handlers/CokeOven.java +++ b/src/main/java/modtweaker2/mods/railcraft/handlers/CokeOven.java @@ -19,114 +19,155 @@ import modtweaker2.helpers.LogHelper; import modtweaker2.mods.railcraft.RailcraftHelper; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; + import net.minecraftforge.oredict.OreDictionary; + import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; @ZenClass("mods.railcraft.CokeOven") public class CokeOven { - public static final String name = "Railcraft Coke Oven"; - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - /** - * Adds a recipe for the Coke Oven - * - * @param itemOutput ItemStack result - * @param fluidOutput FluidStack result - * @param ingredient item input - * @param timePerItem time per item to process - */ - @ZenMethod - public static void addRecipe(IItemStack itemOutput, ILiquidStack fluidOutput, IItemStack ingredient, int timePerItem) { - boolean matchEmptyNBT; - if (toStack(ingredient).stackTagCompound == null) - matchEmptyNBT = false; - else - matchEmptyNBT = true; - - if (ingredient.getDamage() == OreDictionary.WILDCARD_VALUE) - MineTweakerAPI.apply(new Add( new CokeOvenRecipe(toStack(ingredient), false, matchEmptyNBT, toStack(itemOutput), toFluid(fluidOutput), timePerItem) )); - else - MineTweakerAPI.apply(new Add( new CokeOvenRecipe(toStack(ingredient), true, matchEmptyNBT, toStack(itemOutput), toFluid(fluidOutput), timePerItem) )); - } - /** - * Adds a recipe for the Coke Oven (Use this, if you want to have an Input strictly without NBT Data) - * - * @param itemOutput ItemStack result - * @param fluidOutput FluidStack result - * @param ingredient item input - * @param matchEmptyNBT should the input only match an item with no NBT Data - * @param timePerItem time per item to process - */ - @ZenMethod - public static void addRecipe(IItemStack itemOutput, ILiquidStack fluidOutput, IItemStack ingredient, boolean matchEmptyNBT, int timePerItem) { - if (ingredient.getDamage() == OreDictionary.WILDCARD_VALUE) - MineTweakerAPI.apply(new Add( new CokeOvenRecipe(toStack(ingredient), false, matchEmptyNBT, toStack(itemOutput), toFluid(fluidOutput), timePerItem) )); - else - MineTweakerAPI.apply(new Add( new CokeOvenRecipe(toStack(ingredient), true, matchEmptyNBT, toStack(itemOutput), toFluid(fluidOutput), timePerItem) )); - } + public static final String name = "Railcraft Coke Oven"; - /** - * Adds a recipe for the Coke Oven - * - * @param ingredient item input - * @param matchDamage should the recipe compare NBT Data - * @param matchNBT should the recipe compare NBT Data - * @param itemOutput ItemStack result - * @param fluidOutput FluidStack result - * @param cookTime time per item to process - */ - @Deprecated - @ZenMethod - public static void addRecipe(IItemStack input, boolean matchDamage, boolean matchNBT, IItemStack output, ILiquidStack fluidOutput, int cookTime) { - MineTweakerAPI.apply(new Add( new CokeOvenRecipe(toStack(input), matchDamage, matchNBT, toStack(output), toFluid(fluidOutput), cookTime) )); - } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - private static class Add extends BaseListAddition { + /** + * Adds a recipe for the Coke Oven + * + * @param itemOutput ItemStack result + * @param fluidOutput FluidStack result + * @param ingredient item input + * @param timePerItem time per item to process + */ + @ZenMethod + public static void addRecipe(IItemStack itemOutput, ILiquidStack fluidOutput, IItemStack ingredient, + int timePerItem) { + boolean matchEmptyNBT; + if (toStack(ingredient).stackTagCompound == null) matchEmptyNBT = false; + else matchEmptyNBT = true; - @SuppressWarnings("unchecked") + if (ingredient.getDamage() == OreDictionary.WILDCARD_VALUE) MineTweakerAPI.apply( + new Add( + new CokeOvenRecipe( + toStack(ingredient), + false, + matchEmptyNBT, + toStack(itemOutput), + toFluid(fluidOutput), + timePerItem))); + else MineTweakerAPI.apply( + new Add( + new CokeOvenRecipe( + toStack(ingredient), + true, + matchEmptyNBT, + toStack(itemOutput), + toFluid(fluidOutput), + timePerItem))); + } + + /** + * Adds a recipe for the Coke Oven (Use this, if you want to have an Input strictly without NBT Data) + * + * @param itemOutput ItemStack result + * @param fluidOutput FluidStack result + * @param ingredient item input + * @param matchEmptyNBT should the input only match an item with no NBT Data + * @param timePerItem time per item to process + */ + @ZenMethod + public static void addRecipe(IItemStack itemOutput, ILiquidStack fluidOutput, IItemStack ingredient, + boolean matchEmptyNBT, int timePerItem) { + if (ingredient.getDamage() == OreDictionary.WILDCARD_VALUE) MineTweakerAPI.apply( + new Add( + new CokeOvenRecipe( + toStack(ingredient), + false, + matchEmptyNBT, + toStack(itemOutput), + toFluid(fluidOutput), + timePerItem))); + else MineTweakerAPI.apply( + new Add( + new CokeOvenRecipe( + toStack(ingredient), + true, + matchEmptyNBT, + toStack(itemOutput), + toFluid(fluidOutput), + timePerItem))); + } + + /** + * Adds a recipe for the Coke Oven + * + * @param ingredient item input + * @param matchDamage should the recipe compare NBT Data + * @param matchNBT should the recipe compare NBT Data + * @param itemOutput ItemStack result + * @param fluidOutput FluidStack result + * @param cookTime time per item to process + */ + @Deprecated + @ZenMethod + public static void addRecipe(IItemStack input, boolean matchDamage, boolean matchNBT, IItemStack output, + ILiquidStack fluidOutput, int cookTime) { + MineTweakerAPI.apply( + new Add( + new CokeOvenRecipe( + toStack(input), + matchDamage, + matchNBT, + toStack(output), + toFluid(fluidOutput), + cookTime))); + } + + private static class Add extends BaseListAddition { + + @SuppressWarnings("unchecked") public Add(ICokeOvenRecipe recipe) { - super(CokeOven.name, (List)RailcraftCraftingManager.cokeOven.getRecipes()); - recipes.add(recipe); - } - - @Override - public String getRecipeInfo(ICokeOvenRecipe recipe) { - return LogHelper.getStackDescription(recipe.getInput()); - } - } + super(CokeOven.name, (List) RailcraftCraftingManager.cokeOven.getRecipes()); + recipes.add(recipe); + } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + @Override + public String getRecipeInfo(ICokeOvenRecipe recipe) { + return LogHelper.getStackDescription(recipe.getInput()); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + @ZenMethod + public static void removeRecipe(IIngredient output) { + List recipes = new LinkedList(); - @ZenMethod - public static void removeRecipe(IIngredient output) { - List recipes = new LinkedList(); - for (ICokeOvenRecipe r : RailcraftHelper.oven) { if (r.getOutput() != null && matches(output, toIItemStack(r.getOutput()))) { recipes.add(r); } } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new Remove(recipes)); } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", CokeOven.name, output.toString())); + LogHelper.logWarning( + String.format("No %s Recipe found for %s. Command ignored!", CokeOven.name, output.toString())); } - } + } - private static class Remove extends BaseListRemoval { - - @SuppressWarnings("unchecked") - public Remove(List recipes) { - super(CokeOven.name, (List)RailcraftHelper.oven, recipes); - } + private static class Remove extends BaseListRemoval { - @Override - public String getRecipeInfo(ICokeOvenRecipe recipe) { - return LogHelper.getStackDescription(recipe.getInput()); - } - } + @SuppressWarnings("unchecked") + public Remove(List recipes) { + super(CokeOven.name, (List) RailcraftHelper.oven, recipes); + } + + @Override + public String getRecipeInfo(ICokeOvenRecipe recipe) { + return LogHelper.getStackDescription(recipe.getInput()); + } + } } diff --git a/src/main/java/modtweaker2/mods/railcraft/handlers/RockCrusher.java b/src/main/java/modtweaker2/mods/railcraft/handlers/RockCrusher.java index 7a97319..71ecb3d 100644 --- a/src/main/java/modtweaker2/mods/railcraft/handlers/RockCrusher.java +++ b/src/main/java/modtweaker2/mods/railcraft/handlers/RockCrusher.java @@ -1,5 +1,12 @@ package modtweaker2.mods.railcraft.handlers; +import static modtweaker2.helpers.InputHelper.toIItemStack; +import static modtweaker2.helpers.InputHelper.toStack; +import static modtweaker2.helpers.StackHelper.matches; + +import java.util.LinkedList; +import java.util.List; + import minetweaker.MineTweakerAPI; import minetweaker.api.item.IIngredient; import minetweaker.api.item.IItemStack; @@ -9,108 +16,101 @@ import modtweaker2.helpers.LogHelper; import modtweaker2.mods.railcraft.RailcraftHelper; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; + import net.minecraftforge.oredict.OreDictionary; + import stanhebben.zenscript.annotations.Optional; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; -import java.util.LinkedList; -import java.util.List; - -import static modtweaker2.helpers.InputHelper.toIItemStack; -import static modtweaker2.helpers.InputHelper.toStack; -import static modtweaker2.helpers.StackHelper.matches; - @ZenClass("mods.railcraft.RockCrusher") public class RockCrusher { - public static final String name = "Railcraft Rock Crusher"; + public static final String name = "Railcraft Rock Crusher"; - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /** - * Add a recipe for the Rock Crusher - * - * @param output WeightedItemStack Array of outputs - * @param input ItemStack input - * @param matchEmptyNBT Set this to true, if you want to match only input items strictly without NBT Data) - */ - @ZenMethod - public static void addRecipe(WeightedItemStack[] output, IItemStack input, @Optional Boolean matchEmptyNBT) { - if (matchEmptyNBT == null) - if (toStack(input).stackTagCompound == null) - matchEmptyNBT = false; - else - matchEmptyNBT = true; + /** + * Add a recipe for the Rock Crusher + * + * @param output WeightedItemStack Array of outputs + * @param input ItemStack input + * @param matchEmptyNBT Set this to true, if you want to match only input items strictly without NBT Data) + */ + @ZenMethod + public static void addRecipe(WeightedItemStack[] output, IItemStack input, @Optional Boolean matchEmptyNBT) { + if (matchEmptyNBT == null) if (toStack(input).stackTagCompound == null) matchEmptyNBT = false; + else matchEmptyNBT = true; - IRockCrusherRecipe recipe; - if (input.getDamage() == OreDictionary.WILDCARD_VALUE) - recipe = RailcraftHelper.getRockCrusherRecipe(toStack(input), false, matchEmptyNBT); - else - recipe = RailcraftHelper.getRockCrusherRecipe(toStack(input), true, matchEmptyNBT); + IRockCrusherRecipe recipe; + if (input.getDamage() == OreDictionary.WILDCARD_VALUE) + recipe = RailcraftHelper.getRockCrusherRecipe(toStack(input), false, matchEmptyNBT); + else recipe = RailcraftHelper.getRockCrusherRecipe(toStack(input), true, matchEmptyNBT); - for (int i = 0; i < output.length; i++) { - recipe.addOutput(toStack(output[i].getStack()), output[i].getChance()); - } + for (int i = 0; i < output.length; i++) { + recipe.addOutput(toStack(output[i].getStack()), output[i].getChance()); + } - MineTweakerAPI.apply(new Add(recipe)); - } + MineTweakerAPI.apply(new Add(recipe)); + } - @Deprecated - @ZenMethod - public static void addRecipe(IItemStack input, boolean matchDamage, boolean matchNBT, IItemStack[] output, double[] chances) { - IRockCrusherRecipe recipe = RailcraftHelper.getRockCrusherRecipe(toStack(input), matchDamage, matchNBT); + @Deprecated + @ZenMethod + public static void addRecipe(IItemStack input, boolean matchDamage, boolean matchNBT, IItemStack[] output, + double[] chances) { + IRockCrusherRecipe recipe = RailcraftHelper.getRockCrusherRecipe(toStack(input), matchDamage, matchNBT); - for (int i = 0; i < output.length; i++) { - recipe.addOutput(toStack(output[i]), (float) chances[i]); - } + for (int i = 0; i < output.length; i++) { + recipe.addOutput(toStack(output[i]), (float) chances[i]); + } - MineTweakerAPI.apply(new Add(recipe)); - } + MineTweakerAPI.apply(new Add(recipe)); + } - private static class Add extends BaseListAddition { + private static class Add extends BaseListAddition { - @SuppressWarnings("unchecked") - public Add(IRockCrusherRecipe recipe) { - super(RockCrusher.name, (List) RailcraftHelper.crusher); - recipes.add(recipe); - } + @SuppressWarnings("unchecked") + public Add(IRockCrusherRecipe recipe) { + super(RockCrusher.name, (List) RailcraftHelper.crusher); + recipes.add(recipe); + } - @Override - public String getRecipeInfo(IRockCrusherRecipe recipe) { - return LogHelper.getStackDescription(recipe.getInput()); - } - } + @Override + public String getRecipeInfo(IRockCrusherRecipe recipe) { + return LogHelper.getStackDescription(recipe.getInput()); + } + } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - @ZenMethod - public static void removeRecipe(IIngredient input) { - List recipes = new LinkedList(); + @ZenMethod + public static void removeRecipe(IIngredient input) { + List recipes = new LinkedList(); - for (IRockCrusherRecipe r : RailcraftHelper.crusher) { - if (r.getInput() != null && matches(input, toIItemStack(r.getInput()))) { - recipes.add(r); - } - } + for (IRockCrusherRecipe r : RailcraftHelper.crusher) { + if (r.getInput() != null && matches(input, toIItemStack(r.getInput()))) { + recipes.add(r); + } + } - if (!recipes.isEmpty()) { - MineTweakerAPI.apply(new Remove(recipes)); - } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", RockCrusher.name, input.toString())); - } - } + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new Remove(recipes)); + } else { + LogHelper.logWarning( + String.format("No %s Recipe found for %s. Command ignored!", RockCrusher.name, input.toString())); + } + } - private static class Remove extends BaseListRemoval { + private static class Remove extends BaseListRemoval { - @SuppressWarnings("unchecked") - public Remove(List recipes) { - super("Rock Crusher", (List) RailcraftHelper.crusher, recipes); - } + @SuppressWarnings("unchecked") + public Remove(List recipes) { + super("Rock Crusher", (List) RailcraftHelper.crusher, recipes); + } - @Override - public String getRecipeInfo(IRockCrusherRecipe recipe) { - return LogHelper.getStackDescription(recipe.getInput()); - } - } + @Override + public String getRecipeInfo(IRockCrusherRecipe recipe) { + return LogHelper.getStackDescription(recipe.getInput()); + } + } } diff --git a/src/main/java/modtweaker2/mods/railcraft/handlers/RollingMachine.java b/src/main/java/modtweaker2/mods/railcraft/handlers/RollingMachine.java index bf45c75..9a45eaf 100644 --- a/src/main/java/modtweaker2/mods/railcraft/handlers/RollingMachine.java +++ b/src/main/java/modtweaker2/mods/railcraft/handlers/RollingMachine.java @@ -13,19 +13,21 @@ import modtweaker2.helpers.LogHelper; import modtweaker2.mods.railcraft.RailcraftHelper; import modtweaker2.utils.BaseCraftingAddition; import modtweaker2.utils.BaseCraftingRemoval; + import net.minecraft.item.crafting.IRecipe; import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; + import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; @ZenClass("mods.railcraft.Rolling") public class RollingMachine { - + public static final String name = "Railcraft Rolling Machine"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @ZenMethod public static void addShaped(IItemStack output, IIngredient[][] ingredients) { MineTweakerAPI.apply(new Add(new ShapedOreRecipe(toStack(output), toShapedObjects(ingredients)))); @@ -37,6 +39,7 @@ public class RollingMachine { } private static class Add extends BaseCraftingAddition { + public Add(IRecipe recipe) { super(RollingMachine.name, RailcraftHelper.rolling); recipes.add(recipe); @@ -49,14 +52,19 @@ public class RollingMachine { public static void removeRecipe(IIngredient ingredient) { List recipes = BaseCraftingRemoval.getRecipes(RailcraftHelper.rolling, ingredient); - if(!recipes.isEmpty()) { + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new Remove(recipes)); } else { - LogHelper.logWarning(String.format("No %s Recipes found for %s. Command ignored!", RollingMachine.name, ingredient.toString())); + LogHelper.logWarning( + String.format( + "No %s Recipes found for %s. Command ignored!", + RollingMachine.name, + ingredient.toString())); } } private static class Remove extends BaseCraftingRemoval { + public Remove(List recipes) { super(RollingMachine.name, RailcraftHelper.rolling, recipes); } diff --git a/src/main/java/modtweaker2/mods/tconstruct/TConstruct.java b/src/main/java/modtweaker2/mods/tconstruct/TConstruct.java index 45b888f..5566416 100644 --- a/src/main/java/modtweaker2/mods/tconstruct/TConstruct.java +++ b/src/main/java/modtweaker2/mods/tconstruct/TConstruct.java @@ -9,6 +9,7 @@ import modtweaker2.mods.tconstruct.handlers.TiCTweaks; import modtweaker2.mods.tconstruct.handlers.ToolStats; public class TConstruct { + public TConstruct() { MineTweakerAPI.registerClass(Casting.class); MineTweakerAPI.registerClass(Drying.class); diff --git a/src/main/java/modtweaker2/mods/tconstruct/TConstructHelper.java b/src/main/java/modtweaker2/mods/tconstruct/TConstructHelper.java index 8bc028c..21db3d5 100644 --- a/src/main/java/modtweaker2/mods/tconstruct/TConstructHelper.java +++ b/src/main/java/modtweaker2/mods/tconstruct/TConstructHelper.java @@ -7,20 +7,21 @@ import java.util.Map; import mantle.utils.ItemMetaWrapper; import modtweaker2.helpers.ReflectionHelper; -import net.minecraft.item.Item; + import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; + import tconstruct.library.TConstructRegistry; import tconstruct.library.crafting.AlloyMix; import tconstruct.library.crafting.CastingRecipe; import tconstruct.library.crafting.DryingRackRecipes.DryingRecipe; import tconstruct.library.crafting.ModifyBuilder; -import tconstruct.library.crafting.PatternBuilder.ItemKey; import tconstruct.library.modifier.ItemModifier; import tconstruct.library.tools.ToolMaterial; public class TConstructHelper { + public static HashMap mappings = new HashMap(); public static List alloys = null; public static ArrayList basinCasting = null; @@ -46,7 +47,7 @@ public class TConstructHelper { for (Map.Entry entry : TConstructRegistry.toolMaterials.entrySet()) { mappings.put(entry.getValue().materialName, entry.getKey()); } - + fuelList = ReflectionHelper.getObject(tconstruct.library.crafting.Smeltery.instance, "smelteryFuels"); } catch (Exception e) {} } @@ -59,9 +60,10 @@ public class TConstructHelper { } else return mappings.get(material); } - //Returns a Drying Recipe, using reflection as the constructor is not visible + // Returns a Drying Recipe, using reflection as the constructor is not visible public static DryingRecipe getDryingRecipe(ItemStack input, int time, ItemStack output) { - return ReflectionHelper.getInstance(ReflectionHelper.getConstructor(DryingRecipe.class, ItemStack.class, int.class, ItemStack.class), + return ReflectionHelper.getInstance( + ReflectionHelper.getConstructor(DryingRecipe.class, ItemStack.class, int.class, ItemStack.class), input, time, output); diff --git a/src/main/java/modtweaker2/mods/tconstruct/commands/MaterialLogger.java b/src/main/java/modtweaker2/mods/tconstruct/commands/MaterialLogger.java index 788b5b9..78b293a 100644 --- a/src/main/java/modtweaker2/mods/tconstruct/commands/MaterialLogger.java +++ b/src/main/java/modtweaker2/mods/tconstruct/commands/MaterialLogger.java @@ -1,22 +1,23 @@ package modtweaker2.mods.tconstruct.commands; +import static modtweaker2.helpers.LogHelper.logPrinted; + +import java.util.Map; + import minetweaker.MineTweakerAPI; import minetweaker.api.player.IPlayer; import minetweaker.api.server.ICommandFunction; import tconstruct.library.TConstructRegistry; import tconstruct.library.tools.ToolMaterial; -import java.util.Map; - -import static modtweaker2.helpers.LogHelper.logPrinted; - public class MaterialLogger implements ICommandFunction { - @Override - public void execute(String[] arguments, IPlayer player) { - MineTweakerAPI.logCommand(TConstructRegistry.toolMaterialStrings.entrySet().size() + " Materials:"); - for (Map.Entry entry : TConstructRegistry.toolMaterialStrings.entrySet()) { - MineTweakerAPI.logCommand(entry.getKey()); - } - logPrinted(player); - } + + @Override + public void execute(String[] arguments, IPlayer player) { + MineTweakerAPI.logCommand(TConstructRegistry.toolMaterialStrings.entrySet().size() + " Materials:"); + for (Map.Entry entry : TConstructRegistry.toolMaterialStrings.entrySet()) { + MineTweakerAPI.logCommand(entry.getKey()); + } + logPrinted(player); + } } diff --git a/src/main/java/modtweaker2/mods/tconstruct/commands/ModifierLogger.java b/src/main/java/modtweaker2/mods/tconstruct/commands/ModifierLogger.java index d6b772c..2b81d5b 100644 --- a/src/main/java/modtweaker2/mods/tconstruct/commands/ModifierLogger.java +++ b/src/main/java/modtweaker2/mods/tconstruct/commands/ModifierLogger.java @@ -1,21 +1,21 @@ package modtweaker2.mods.tconstruct.commands; +import static modtweaker2.helpers.LogHelper.logPrinted; + import minetweaker.MineTweakerAPI; import minetweaker.api.player.IPlayer; import minetweaker.api.server.ICommandFunction; import modtweaker2.mods.tconstruct.TConstructHelper; import tconstruct.library.modifier.ItemModifier; -import static modtweaker2.helpers.LogHelper.logPrinted; +public class ModifierLogger implements ICommandFunction { -public class ModifierLogger implements ICommandFunction{ - @Override - public void execute(String[] arguments, IPlayer player) { - MineTweakerAPI.logCommand(TConstructHelper.modifiers.size() + " Tinker's Construct modifiers:"); - for (ItemModifier modifier : TConstructHelper.modifiers) { - if (!modifier.key.equals("")) - MineTweakerAPI.logCommand(modifier.key); - } - logPrinted(player); - } + @Override + public void execute(String[] arguments, IPlayer player) { + MineTweakerAPI.logCommand(TConstructHelper.modifiers.size() + " Tinker's Construct modifiers:"); + for (ItemModifier modifier : TConstructHelper.modifiers) { + if (!modifier.key.equals("")) MineTweakerAPI.logCommand(modifier.key); + } + logPrinted(player); + } } diff --git a/src/main/java/modtweaker2/mods/tconstruct/commands/TConstructLogger.java b/src/main/java/modtweaker2/mods/tconstruct/commands/TConstructLogger.java index 58fff47..77c93b4 100644 --- a/src/main/java/modtweaker2/mods/tconstruct/commands/TConstructLogger.java +++ b/src/main/java/modtweaker2/mods/tconstruct/commands/TConstructLogger.java @@ -13,90 +13,111 @@ import minetweaker.api.server.ICommandFunction; import modtweaker2.helpers.LogHelper; import modtweaker2.helpers.StringHelper; import modtweaker2.mods.tconstruct.TConstructHelper; + import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; + import tconstruct.library.crafting.AlloyMix; import tconstruct.library.crafting.CastingRecipe; import tconstruct.library.crafting.DryingRackRecipes; import tconstruct.library.crafting.DryingRackRecipes.DryingRecipe; public class TConstructLogger implements ICommandFunction { + private static final List validArguments = new LinkedList(); - + static { validArguments.add("Casting"); validArguments.add("Drying"); validArguments.add("Smeltery"); } - + @Override public void execute(String[] arguments, IPlayer player) { List args = StringHelper.toLowerCase(Arrays.asList(arguments)); - - if(!validArguments.containsAll(args)) { - if(player != null) { - player.sendChat(MineTweakerImplementationAPI.platform.getMessage("Invalid arguments for command. Valid arguments: " + StringHelper.join(validArguments, ", "))); + + if (!validArguments.containsAll(args)) { + if (player != null) { + player.sendChat( + MineTweakerImplementationAPI.platform.getMessage( + "Invalid arguments for command. Valid arguments: " + + StringHelper.join(validArguments, ", "))); } } else { - if(args.isEmpty() || args.contains("Casting")) { - for(CastingRecipe recipe : TConstructHelper.basinCasting) { - MineTweakerAPI.logCommand(String.format("mods.tconstruct.Casting.addBasinRecipe(%s, %s, %s, %s, %d);", - LogHelper.getStackDescription(recipe.output), - LogHelper.getStackDescription(recipe.castingMetal), - LogHelper.getStackDescription(recipe.cast), - recipe.consumeCast, - recipe.coolTime)); + if (args.isEmpty() || args.contains("Casting")) { + for (CastingRecipe recipe : TConstructHelper.basinCasting) { + MineTweakerAPI.logCommand( + String.format( + "mods.tconstruct.Casting.addBasinRecipe(%s, %s, %s, %s, %d);", + LogHelper.getStackDescription(recipe.output), + LogHelper.getStackDescription(recipe.castingMetal), + LogHelper.getStackDescription(recipe.cast), + recipe.consumeCast, + recipe.coolTime)); } - - for(CastingRecipe recipe : TConstructHelper.tableCasting) { - MineTweakerAPI.logCommand(String.format("mods.tconstruct.Casting.addTableRecipe(%s, %s, %s, %s, %d);", - LogHelper.getStackDescription(recipe.output), - LogHelper.getStackDescription(recipe.castingMetal), - LogHelper.getStackDescription(recipe.cast), - recipe.consumeCast, - recipe.coolTime)); + + for (CastingRecipe recipe : TConstructHelper.tableCasting) { + MineTweakerAPI.logCommand( + String.format( + "mods.tconstruct.Casting.addTableRecipe(%s, %s, %s, %s, %d);", + LogHelper.getStackDescription(recipe.output), + LogHelper.getStackDescription(recipe.castingMetal), + LogHelper.getStackDescription(recipe.cast), + recipe.consumeCast, + recipe.coolTime)); } } - - if(args.isEmpty() || args.contains("Drying")) { - for(DryingRecipe recipe : DryingRackRecipes.recipes) { - MineTweakerAPI.logCommand(String.format("mods.tconstruct.Drying.addRecipe(%s, %s, %d);", - LogHelper.getStackDescription(recipe.input), - LogHelper.getStackDescription(recipe.result), - recipe.time)); + + if (args.isEmpty() || args.contains("Drying")) { + for (DryingRecipe recipe : DryingRackRecipes.recipes) { + MineTweakerAPI.logCommand( + String.format( + "mods.tconstruct.Drying.addRecipe(%s, %s, %d);", + LogHelper.getStackDescription(recipe.input), + LogHelper.getStackDescription(recipe.result), + recipe.time)); } } - - if(args.isEmpty() || args.contains("Smeltery")) { - - for(Entry recipe : TConstructHelper.smeltingList.entrySet()) { + + if (args.isEmpty() || args.contains("Smeltery")) { + + for (Entry recipe : TConstructHelper.smeltingList.entrySet()) { int temperature = TConstructHelper.temperatureList.get(recipe.getKey()); ItemStack renderItem = TConstructHelper.renderIndex.get(recipe.getKey()); - - MineTweakerAPI.logCommand(String.format("mods.tconstruct.Smeltery.addMelting(%s, %s, %d, %s);", - LogHelper.getStackDescription(new ItemStack(recipe.getKey().item, 1, recipe.getKey().meta)), - LogHelper.getStackDescription(recipe.getValue()), - temperature, - LogHelper.getStackDescription(renderItem))); + + MineTweakerAPI.logCommand( + String.format( + "mods.tconstruct.Smeltery.addMelting(%s, %s, %d, %s);", + LogHelper.getStackDescription( + new ItemStack(recipe.getKey().item, 1, recipe.getKey().meta)), + LogHelper.getStackDescription(recipe.getValue()), + temperature, + LogHelper.getStackDescription(renderItem))); } - - for(AlloyMix recipe : TConstructHelper.alloys) { - MineTweakerAPI.logCommand(String.format("mods.tconstruct.Smeltery.addAlloy(%s, %s);", - LogHelper.getStackDescription(recipe.result), - LogHelper.getListDescription(recipe.mixers))); + + for (AlloyMix recipe : TConstructHelper.alloys) { + MineTweakerAPI.logCommand( + String.format( + "mods.tconstruct.Smeltery.addAlloy(%s, %s);", + LogHelper.getStackDescription(recipe.result), + LogHelper.getListDescription(recipe.mixers))); } - - for(Entry fuel : TConstructHelper.fuelList.entrySet()) { - MineTweakerAPI.logCommand(String.format("mods.tconstruct.Smeltery.addFuel(%s, %d, %d);", - LogHelper.getStackDescription(new FluidStack(fuel.getKey(), 1)), - fuel.getValue()[0], - fuel.getValue()[1])); + + for (Entry fuel : TConstructHelper.fuelList.entrySet()) { + MineTweakerAPI.logCommand( + String.format( + "mods.tconstruct.Smeltery.addFuel(%s, %d, %d);", + LogHelper.getStackDescription(new FluidStack(fuel.getKey(), 1)), + fuel.getValue()[0], + fuel.getValue()[1])); } } - + if (player != null) { - player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir")); + player.sendChat( + MineTweakerImplementationAPI.platform + .getMessage("List generated; see minetweaker.log in your minecraft dir")); } } } diff --git a/src/main/java/modtweaker2/mods/tconstruct/handlers/Casting.java b/src/main/java/modtweaker2/mods/tconstruct/handlers/Casting.java index 62b656e..b6bdd70 100644 --- a/src/main/java/modtweaker2/mods/tconstruct/handlers/Casting.java +++ b/src/main/java/modtweaker2/mods/tconstruct/handlers/Casting.java @@ -26,36 +26,45 @@ import tconstruct.library.crafting.CastingRecipe; @ZenClass("mods.tconstruct.Casting") public class Casting { - + protected static final String name = "TConstruct Casting"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @ZenMethod - public static void addBasinRecipe(IItemStack output, ILiquidStack metal, @Optional IItemStack cast, @Optional boolean consume, int delay) { - if(metal == null || output == null) { + public static void addBasinRecipe(IItemStack output, ILiquidStack metal, @Optional IItemStack cast, + @Optional boolean consume, int delay) { + if (metal == null || output == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - - MineTweakerAPI.apply(new Add(new CastingRecipe(toStack(output), toFluid(metal), toStack(cast), consume, delay, null), TConstructHelper.basinCasting)); + + MineTweakerAPI.apply( + new Add( + new CastingRecipe(toStack(output), toFluid(metal), toStack(cast), consume, delay, null), + TConstructHelper.basinCasting)); } @ZenMethod - public static void addTableRecipe(IItemStack output, ILiquidStack metal, @Optional IItemStack cast, @Optional boolean consume, int delay) { - if(metal == null || output == null) { + public static void addTableRecipe(IItemStack output, ILiquidStack metal, @Optional IItemStack cast, + @Optional boolean consume, int delay) { + if (metal == null || output == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - - MineTweakerAPI.apply(new Add(new CastingRecipe(toStack(output), toFluid(metal), toStack(cast), consume, delay, null), TConstructHelper.tableCasting)); + + MineTweakerAPI.apply( + new Add( + new CastingRecipe(toStack(output), toFluid(metal), toStack(cast), consume, delay, null), + TConstructHelper.tableCasting)); } - //Passes the list to the base list implementation, and adds the recipe + // Passes the list to the base list implementation, and adds the recipe private static class Add extends BaseListAddition { + public Add(CastingRecipe recipe, ArrayList list) { super(Casting.name, list); - + this.recipes.add(recipe); } @@ -68,62 +77,72 @@ public class Casting { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @ZenMethod - public static void removeTableRecipe(IIngredient output, @Optional IIngredient material, @Optional IIngredient cast) { + public static void removeTableRecipe(IIngredient output, @Optional IIngredient material, + @Optional IIngredient cast) { removeRecipe(output, material, cast, TConstructHelper.tableCasting); } - + @ZenMethod - public static void removeBasinRecipe(IIngredient output, @Optional IIngredient material, @Optional IIngredient cast) { + public static void removeBasinRecipe(IIngredient output, @Optional IIngredient material, + @Optional IIngredient cast) { removeRecipe(output, material, cast, TConstructHelper.basinCasting); } - - public static void removeRecipe(IIngredient output, IIngredient material, IIngredient cast, List list) { - if(output == null) { + + public static void removeRecipe(IIngredient output, IIngredient material, IIngredient cast, + List list) { + if (output == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - - if(material == null) { + + if (material == null) { material = IngredientAny.INSTANCE; } - - if(cast == null) { + + if (cast == null) { cast = IngredientAny.INSTANCE; } - + List recipes = new LinkedList(); - - for(CastingRecipe recipe : list) { - if(recipe != null) { + + for (CastingRecipe recipe : list) { + if (recipe != null) { if (!matches(output, toIItemStack(recipe.output))) { continue; } - + if (!matches(material, toILiquidStack(recipe.castingMetal))) { continue; } - - if(!matches(cast, toIItemStack(recipe.cast))) { + + if (!matches(cast, toIItemStack(recipe.cast))) { continue; } - + recipes.add(recipe); } } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new Remove(list, recipes)); } else { - LogHelper.logWarning(String.format("No %s Recipe found for output %s, material %s and cast %s. Command ignored!", Casting.name, output.toString(), material.toString(), cast.toString())); + LogHelper.logWarning( + String.format( + "No %s Recipe found for output %s, material %s and cast %s. Command ignored!", + Casting.name, + output.toString(), + material.toString(), + cast.toString())); } } // Removes all matching recipes, apply is never the same for anything, so will always need to override it private static class Remove extends BaseListRemoval { + public Remove(List list, List recipes) { super(Casting.name, list, recipes); - } + } @Override protected String getRecipeInfo(CastingRecipe recipe) { diff --git a/src/main/java/modtweaker2/mods/tconstruct/handlers/Drying.java b/src/main/java/modtweaker2/mods/tconstruct/handlers/Drying.java index de8baff..65d7507 100644 --- a/src/main/java/modtweaker2/mods/tconstruct/handlers/Drying.java +++ b/src/main/java/modtweaker2/mods/tconstruct/handlers/Drying.java @@ -20,23 +20,24 @@ import tconstruct.library.crafting.DryingRackRecipes.DryingRecipe; @ZenClass("mods.tconstruct.Drying") public class Drying { - + protected static final String name = "TConstruct Drying Rack"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @ZenMethod public static void addRecipe(IItemStack input, IItemStack output, int time) { - if(input == null || output == null) { + if (input == null || output == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - + MineTweakerAPI.apply(new Add(TConstructHelper.getDryingRecipe(toStack(input), time, toStack(output)))); } - //Passes the list to the base list implementation, and adds the recipe + // Passes the list to the base list implementation, and adds the recipe private static class Add extends BaseListAddition { + public Add(DryingRecipe recipe) { super(Drying.name, DryingRackRecipes.recipes); this.recipes.add(recipe); @@ -50,26 +51,28 @@ public class Drying { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //Removing a TConstruct Drying Rack recipe + // Removing a TConstruct Drying Rack recipe @ZenMethod public static void removeRecipe(IIngredient ingredient) { List recipes = new LinkedList(); - + for (DryingRecipe recipe : DryingRackRecipes.recipes) { if (recipe != null && recipe.result != null && ingredient.matches(toIItemStack(recipe.result))) { recipes.add(recipe); } } - if(!recipes.isEmpty()) { + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new Remove(recipes)); } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Drying.name, ingredient.toString())); + LogHelper.logWarning( + String.format("No %s Recipe found for %s. Command ignored!", Drying.name, ingredient.toString())); } } - //Removes a recipe, apply is never the same for anything, so will always need to override it + // Removes a recipe, apply is never the same for anything, so will always need to override it private static class Remove extends BaseListRemoval { + public Remove(List list) { super(Drying.name, DryingRackRecipes.recipes, list); } diff --git a/src/main/java/modtweaker2/mods/tconstruct/handlers/Modifiers.java b/src/main/java/modtweaker2/mods/tconstruct/handlers/Modifiers.java index 3778718..a149649 100644 --- a/src/main/java/modtweaker2/mods/tconstruct/handlers/Modifiers.java +++ b/src/main/java/modtweaker2/mods/tconstruct/handlers/Modifiers.java @@ -13,29 +13,30 @@ import tconstruct.library.modifier.ItemModifier; @ZenClass("mods.tconstruct.Modifiers") public class Modifiers { - + protected static final String name = "TConstruct Modifier"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + @ZenMethod public static void remove(String mod) { List recipes = new LinkedList(); - + for (ItemModifier recipe : TConstructHelper.modifiers) { if (recipe.key.equals(mod)) { recipes.add(recipe); } } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new Remove(recipes)); } else { LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Modifiers.name, mod)); } } - private static class Remove extends BaseListRemoval{ + private static class Remove extends BaseListRemoval { + public Remove(List recipes) { super(Modifiers.name, TConstructHelper.modifiers, recipes); } diff --git a/src/main/java/modtweaker2/mods/tconstruct/handlers/Smeltery.java b/src/main/java/modtweaker2/mods/tconstruct/handlers/Smeltery.java index 09db6e4..a259f92 100644 --- a/src/main/java/modtweaker2/mods/tconstruct/handlers/Smeltery.java +++ b/src/main/java/modtweaker2/mods/tconstruct/handlers/Smeltery.java @@ -27,10 +27,12 @@ import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; import modtweaker2.utils.BaseMapAddition; import modtweaker2.utils.BaseMapRemoval; + import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; + import stanhebben.zenscript.annotations.Optional; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; @@ -38,263 +40,300 @@ import tconstruct.library.crafting.AlloyMix; @ZenClass("mods.tconstruct.Smeltery") public class Smeltery { - + public static final String nameFuel = "TConstruct Smeltery - Fuel"; public static final String nameMelting = "TConstruct Smeltery - Melting"; public static final String nameAlloy = "TConstruct Smeltery - Alloy"; - /********************************************** TConstruct Alloy Recipes **********************************************/ + /********************************************** + * TConstruct Alloy Recipes + **********************************************/ - // Adding a TConstruct Alloy recipe - @ZenMethod - public static void addAlloy(ILiquidStack output, ILiquidStack[] input) { - if(input == null || output == null) { + // Adding a TConstruct Alloy recipe + @ZenMethod + public static void addAlloy(ILiquidStack output, ILiquidStack[] input) { + if (input == null || output == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", nameAlloy)); return; } - - MineTweakerAPI.apply(new AddAlloy(new AlloyMix(toFluid(output), new ArrayList(Arrays.asList(toFluids(input)))))); - } - // Passes the list to the base list implementation, and adds the recipe - private static class AddAlloy extends BaseListAddition { - public AddAlloy(AlloyMix recipe) { - super("TConstruct Smeltery - Alloy", TConstructHelper.alloys); - this.recipes.add(recipe); - } + MineTweakerAPI.apply( + new AddAlloy(new AlloyMix(toFluid(output), new ArrayList(Arrays.asList(toFluids(input)))))); + } - @Override - protected String getRecipeInfo(AlloyMix recipe) { - return LogHelper.getStackDescription(recipe.result); - } - } + // Passes the list to the base list implementation, and adds the recipe + private static class AddAlloy extends BaseListAddition { - // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - // Removing a TConstruct Alloy recipe - @ZenMethod - public static void removeAlloy(IIngredient output) { - List recipes = new LinkedList(); - - for(AlloyMix r : TConstructHelper.alloys) { - if(r != null && matches(output, toILiquidStack(r.result))) { - recipes.add(r); - } - } - - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new RemoveAlloy(recipes)); - } else { - LogHelper.logError(String.format("No %s recipes found for %s. Command ignored!", nameAlloy, output.toString())); - } - - } - - // Removes a recipe, apply is never the same for anything, so will always - // need to override it - private static class RemoveAlloy extends BaseListRemoval { - public RemoveAlloy(List recipes) { - super(nameAlloy, TConstructHelper.alloys, recipes); - } + public AddAlloy(AlloyMix recipe) { + super("TConstruct Smeltery - Alloy", TConstructHelper.alloys); + this.recipes.add(recipe); + } @Override protected String getRecipeInfo(AlloyMix recipe) { return LogHelper.getStackDescription(recipe.result); } - } + } - /********************************************** TConstruct Melting Recipes **********************************************/ + // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Adding a TConstruct Melting recipe - @ZenMethod - public static void addMelting(IIngredient input, ILiquidStack output, int temp, @Optional IItemStack block) { - - if(input == null || output == null) { + // Removing a TConstruct Alloy recipe + @ZenMethod + public static void removeAlloy(IIngredient output) { + List recipes = new LinkedList(); + + for (AlloyMix r : TConstructHelper.alloys) { + if (r != null && matches(output, toILiquidStack(r.result))) { + recipes.add(r); + } + } + + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new RemoveAlloy(recipes)); + } else { + LogHelper.logError( + String.format("No %s recipes found for %s. Command ignored!", nameAlloy, output.toString())); + } + + } + + // Removes a recipe, apply is never the same for anything, so will always + // need to override it + private static class RemoveAlloy extends BaseListRemoval { + + public RemoveAlloy(List recipes) { + super(nameAlloy, TConstructHelper.alloys, recipes); + } + + @Override + protected String getRecipeInfo(AlloyMix recipe) { + return LogHelper.getStackDescription(recipe.result); + } + } + + /********************************************** + * TConstruct Melting Recipes + **********************************************/ + + // Adding a TConstruct Melting recipe + @ZenMethod + public static void addMelting(IIngredient input, ILiquidStack output, int temp, @Optional IItemStack block) { + + if (input == null || output == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", nameMelting)); return; } - - List recipes = new LinkedList(); - for(IItemStack in : input.getItems()) { - if(block == null && !isABlock(toStack(in))) { - LogHelper.logWarning(String.format("Item %s is not a block and no block renderer is provided for %s recipe. Input ignored!", in.toString(), nameMelting)); - } else { - recipes.add(new MeltingRecipe(toStack(in), toFluid(output), temp, block == null ? toStack(in) : toStack(block))); - } - } - - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new AddMelting(recipes)); - } else { - LogHelper.logError(String.format("No %s recipes could be added for input %s.", nameMelting, input.toString())); - } - } + List recipes = new LinkedList(); - private static class AddMelting extends BaseListAddition { + for (IItemStack in : input.getItems()) { + if (block == null && !isABlock(toStack(in))) { + LogHelper.logWarning( + String.format( + "Item %s is not a block and no block renderer is provided for %s recipe. Input ignored!", + in.toString(), + nameMelting)); + } else { + recipes.add( + new MeltingRecipe( + toStack(in), + toFluid(output), + temp, + block == null ? toStack(in) : toStack(block))); + } + } - public AddMelting(List recipes) { - super(nameMelting, null, recipes); - } + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new AddMelting(recipes)); + } else { + LogHelper.logError( + String.format("No %s recipes could be added for input %s.", nameMelting, input.toString())); + } + } - @Override - public void apply() { - for(MeltingRecipe recipe : recipes) { - tconstruct.library.crafting.Smeltery.addMelting(recipe.input, recipe.getRendererBlock(), recipe.getRendererMeta(), recipe.temperature, recipe.fluid); + private static class AddMelting extends BaseListAddition { + + public AddMelting(List recipes) { + super(nameMelting, null, recipes); + } + + @Override + public void apply() { + for (MeltingRecipe recipe : recipes) { + tconstruct.library.crafting.Smeltery.addMelting( + recipe.input, + recipe.getRendererBlock(), + recipe.getRendererMeta(), + recipe.temperature, + recipe.fluid); successful.add(recipe); } - } + } + + @Override + public void undo() { + for (MeltingRecipe recipe : successful) { + TConstructHelper.smeltingList.remove(recipe.meta); + TConstructHelper.temperatureList.remove(recipe.meta); + TConstructHelper.renderIndex.remove(recipe.meta); + } + } - @Override - public void undo() { - for(MeltingRecipe recipe : successful) { - TConstructHelper.smeltingList.remove(recipe.meta); - TConstructHelper.temperatureList.remove(recipe.meta); - TConstructHelper.renderIndex.remove(recipe.meta); - } - } - @Override public String getRecipeInfo(MeltingRecipe recipe) { return LogHelper.getStackDescription(recipe.input); } - } + } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Removing a TConstruct Melting recipe - @ZenMethod - public static void removeMelting(IIngredient input) { - List recipes = new LinkedList(); - - for(ItemMetaWrapper meta : TConstructHelper.smeltingList.keySet()) { - ItemStack in = new ItemStack(meta.item, 1, meta.meta); - if(matches(input, toIItemStack(in))) { - recipes.add(new MeltingRecipe( - in, - TConstructHelper.smeltingList.get(meta), - TConstructHelper.temperatureList.get(meta), - TConstructHelper.renderIndex.get(meta))); - } - } - - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new RemoveMelting(recipes)); - } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", nameMelting, input.toString())); - } - } + // Removing a TConstruct Melting recipe + @ZenMethod + public static void removeMelting(IIngredient input) { + List recipes = new LinkedList(); - private static class RemoveMelting extends BaseListRemoval { - - public RemoveMelting(List recipes) { - super(nameMelting, null, recipes); - } + for (ItemMetaWrapper meta : TConstructHelper.smeltingList.keySet()) { + ItemStack in = new ItemStack(meta.item, 1, meta.meta); + if (matches(input, toIItemStack(in))) { + recipes.add( + new MeltingRecipe( + in, + TConstructHelper.smeltingList.get(meta), + TConstructHelper.temperatureList.get(meta), + TConstructHelper.renderIndex.get(meta))); + } + } - @Override - public void apply() { - for(MeltingRecipe recipe : recipes) { - TConstructHelper.smeltingList.remove(recipe.meta); - TConstructHelper.temperatureList.remove(recipe.meta); - TConstructHelper.renderIndex.remove(recipe.meta); - - successful.add(recipe); - } - } + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new RemoveMelting(recipes)); + } else { + LogHelper.logWarning( + String.format("No %s Recipe found for %s. Command ignored!", nameMelting, input.toString())); + } + } + + private static class RemoveMelting extends BaseListRemoval { + + public RemoveMelting(List recipes) { + super(nameMelting, null, recipes); + } @Override - public void undo() { - for(MeltingRecipe recipe : successful) { - tconstruct.library.crafting.Smeltery.addMelting(recipe.input, recipe.getRendererBlock(), recipe.getRendererMeta(), recipe.temperature, recipe.fluid); - } - } + public void apply() { + for (MeltingRecipe recipe : recipes) { + TConstructHelper.smeltingList.remove(recipe.meta); + TConstructHelper.temperatureList.remove(recipe.meta); + TConstructHelper.renderIndex.remove(recipe.meta); - @Override - public String getRecipeInfo(MeltingRecipe recipe) { - return LogHelper.getStackDescription(recipe.input); - } - } - - protected static class MeltingRecipe { - public final ItemMetaWrapper meta; - public final ItemStack input; - public final FluidStack fluid; - public final Integer temperature; - public final ItemStack renderer; - - protected MeltingRecipe(ItemStack input, FluidStack fluid, int temperature, ItemStack renderer) { - this.input = input; - this.fluid = fluid; - this.temperature = temperature; - this.renderer = renderer; - this.meta = new ItemMetaWrapper(input); - } - - public Block getRendererBlock() { - return Block.getBlockFromItem(renderer.getItem()); - } - - public int getRendererMeta() { - return renderer.getItemDamage(); - } - } - - /********************************************** TConstruct Fuel Recipes **********************************************/ - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - @ZenMethod - public static void removeFuel(IIngredient input) { - Map recipes = new HashMap(); - - for(Entry fuel : TConstructHelper.fuelList.entrySet()) { - if(fuel != null && fuel.getKey() != null && matches(input, toILiquidStack(new FluidStack(fuel.getKey(), 1)))) { - recipes.put(fuel.getKey(), fuel.getValue()); - } - } - - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new RemoveFuel(recipes)); - } else { - LogHelper.logWarning(String.format("No %s Recipe for %s found. Command ignored!", Smeltery.nameFuel, input.toString())); - } + successful.add(recipe); + } + } + + @Override + public void undo() { + for (MeltingRecipe recipe : successful) { + tconstruct.library.crafting.Smeltery.addMelting( + recipe.input, + recipe.getRendererBlock(), + recipe.getRendererMeta(), + recipe.temperature, + recipe.fluid); + } + } + + @Override + public String getRecipeInfo(MeltingRecipe recipe) { + return LogHelper.getStackDescription(recipe.input); + } } - - public static class RemoveFuel extends BaseMapRemoval { - public RemoveFuel(Map recipes) { - super(Smeltery.nameFuel, TConstructHelper.fuelList, recipes); + + protected static class MeltingRecipe { + + public final ItemMetaWrapper meta; + public final ItemStack input; + public final FluidStack fluid; + public final Integer temperature; + public final ItemStack renderer; + + protected MeltingRecipe(ItemStack input, FluidStack fluid, int temperature, ItemStack renderer) { + this.input = input; + this.fluid = fluid; + this.temperature = temperature; + this.renderer = renderer; + this.meta = new ItemMetaWrapper(input); } - - @Override - public String getRecipeInfo(Entry recipe) { - return LogHelper.getStackDescription(new FluidStack(recipe.getKey(), 1)); - } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - @ZenMethod - public static void addFuel(ILiquidStack liquid, int power, int duration) { - if(liquid == null) { - LogHelper.logError(String.format("Required parameters missing for %s Recipe.", nameFuel)); - return; + + public Block getRendererBlock() { + return Block.getBlockFromItem(renderer.getItem()); } - - Map recipes = new HashMap(); - - recipes.put(toFluid(liquid).getFluid(), new Integer[] {power, duration}); - - MineTweakerAPI.apply(new AddFuel(recipes)); - } - - public static class AddFuel extends BaseMapAddition { - public AddFuel(Map recipes) { - super(Smeltery.nameFuel, TConstructHelper.fuelList, recipes); - } - + + public int getRendererMeta() { + return renderer.getItemDamage(); + } + } + + /********************************************** + * TConstruct Fuel Recipes + **********************************************/ + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + @ZenMethod + public static void removeFuel(IIngredient input) { + Map recipes = new HashMap(); + + for (Entry fuel : TConstructHelper.fuelList.entrySet()) { + if (fuel != null && fuel.getKey() != null + && matches(input, toILiquidStack(new FluidStack(fuel.getKey(), 1)))) { + recipes.put(fuel.getKey(), fuel.getValue()); + } + } + + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new RemoveFuel(recipes)); + } else { + LogHelper.logWarning( + String.format("No %s Recipe for %s found. Command ignored!", Smeltery.nameFuel, input.toString())); + } + } + + public static class RemoveFuel extends BaseMapRemoval { + + public RemoveFuel(Map recipes) { + super(Smeltery.nameFuel, TConstructHelper.fuelList, recipes); + } + @Override public String getRecipeInfo(Entry recipe) { return LogHelper.getStackDescription(new FluidStack(recipe.getKey(), 1)); } - } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + @ZenMethod + public static void addFuel(ILiquidStack liquid, int power, int duration) { + if (liquid == null) { + LogHelper.logError(String.format("Required parameters missing for %s Recipe.", nameFuel)); + return; + } + + Map recipes = new HashMap(); + + recipes.put(toFluid(liquid).getFluid(), new Integer[] { power, duration }); + + MineTweakerAPI.apply(new AddFuel(recipes)); + } + + public static class AddFuel extends BaseMapAddition { + + public AddFuel(Map recipes) { + super(Smeltery.nameFuel, TConstructHelper.fuelList, recipes); + } + + @Override + public String getRecipeInfo(Entry recipe) { + return LogHelper.getStackDescription(new FluidStack(recipe.getKey(), 1)); + } + } } diff --git a/src/main/java/modtweaker2/mods/tconstruct/handlers/TiCTweaks.java b/src/main/java/modtweaker2/mods/tconstruct/handlers/TiCTweaks.java index 4cd4eff..23481a6 100644 --- a/src/main/java/modtweaker2/mods/tconstruct/handlers/TiCTweaks.java +++ b/src/main/java/modtweaker2/mods/tconstruct/handlers/TiCTweaks.java @@ -10,10 +10,11 @@ import minetweaker.MineTweakerAPI; import minetweaker.api.item.IIngredient; import minetweaker.api.item.IItemStack; import modtweaker2.helpers.LogHelper; -import modtweaker2.mods.tconstruct.TConstructHelper; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; + import net.minecraft.item.ItemStack; + import stanhebben.zenscript.annotations.Optional; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; @@ -23,72 +24,59 @@ import tconstruct.library.crafting.PatternBuilder.ItemKey; @ZenClass("mods.tconstruct.Tweaks") public class TiCTweaks { - // ////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /** Disabling for 0.5, will do this properly for 0.6 **/ - // Tweaks for enabling / disabling Patterns - /* - * @ZenMethod public static void removePattern(IItemStack stack) { - * MineTweakerAPI.apply(new DisablePattern(toStack(stack))); } - * - * private static class DisablePattern implements IUndoableAction { private - * String key; private MaterialSet set; private List list; private ItemStack - * stack; private final ItemStack disable; - * - * public DisablePattern(ItemStack disable) { this.disable = disable; } - * - * //Loops through the pattern mappings to find an entry with the same - * material name - * - * @Override public void apply() { for (Entry entry : - * TConstructRegistry.patternPartMapping.entrySet()) { ItemStack check = - * entry.getValue(); if (check.isItemEqual(disable)) { list = - * entry.getKey(); stack = entry.getValue(); break; } } - * - * TConstructRegistry.patternPartMapping.remove(list); } - * - * @Override public boolean canUndo() { return true; } - * - * @Override public void undo() { - * TConstructRegistry.patternPartMapping.put(list, stack); } - * - * @Override public String describe() { return - * "Disabling creation of the pattern for: " + disable.getDisplayName(); } - * - * @Override public String describeUndo() { return - * "Enabling creation of the pattern for: " + disable.getDisplayName(); } - * - * @Override public Object getOverrideKey() { return null; } } - */ + /** Disabling for 0.5, will do this properly for 0.6 **/ + // Tweaks for enabling / disabling Patterns + /* + * @ZenMethod public static void removePattern(IItemStack stack) { MineTweakerAPI.apply(new + * DisablePattern(toStack(stack))); } private static class DisablePattern implements IUndoableAction { private + * String key; private MaterialSet set; private List list; private ItemStack stack; private final ItemStack disable; + * public DisablePattern(ItemStack disable) { this.disable = disable; } //Loops through the pattern mappings to find + * an entry with the same material name + * @Override public void apply() { for (Entry entry : + * TConstructRegistry.patternPartMapping.entrySet()) { ItemStack check = entry.getValue(); if + * (check.isItemEqual(disable)) { list = entry.getKey(); stack = entry.getValue(); break; } } + * TConstructRegistry.patternPartMapping.remove(list); } + * @Override public boolean canUndo() { return true; } + * @Override public void undo() { TConstructRegistry.patternPartMapping.put(list, stack); } + * @Override public String describe() { return "Disabling creation of the pattern for: " + disable.getDisplayName(); + * } + * @Override public String describeUndo() { return "Enabling creation of the pattern for: " + + * disable.getDisplayName(); } + * @Override public Object getOverrideKey() { return null; } } + */ - // ////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////////////////////////////////////////// - @ZenMethod - public static void addRepairMaterial(IItemStack stack, String material, int value) { - ItemStack input = toStack(stack); - MineTweakerAPI.apply(new Add(PatternBuilder.instance.new ItemKey(input.getItem(), input.getItemDamage(), value, material))); - } + @ZenMethod + public static void addRepairMaterial(IItemStack stack, String material, int value) { + ItemStack input = toStack(stack); + MineTweakerAPI.apply( + new Add(PatternBuilder.instance.new ItemKey(input.getItem(), input.getItemDamage(), value, material))); + } - // Tweaks for setting repair materials - private static class Add extends BaseListAddition { - public Add(ItemKey recipe) { - super("Repair Material", PatternBuilder.instance.materials); - recipes.add(recipe); - } + // Tweaks for setting repair materials + private static class Add extends BaseListAddition { - @Override - protected String getRecipeInfo(ItemKey recipe) { - return LogHelper.getStackDescription(new ItemStack(recipe.item, 1, recipe.damage)); - } - } + public Add(ItemKey recipe) { + super("Repair Material", PatternBuilder.instance.materials); + recipes.add(recipe); + } + + @Override + protected String getRecipeInfo(ItemKey recipe) { + return LogHelper.getStackDescription(new ItemStack(recipe.item, 1, recipe.damage)); + } + } + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + @ZenMethod + public static void removeRepairMaterial(IIngredient output, @Optional String material) { + + List recipes = new LinkedList(); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - @ZenMethod - public static void removeRepairMaterial(IIngredient output, @Optional String material) { - - List recipes = new LinkedList(); - for (ItemKey recipe : PatternBuilder.instance.materials) { IItemStack clone = toIItemStack(new ItemStack(recipe.item, 1, recipe.damage)); if ((material != null && material.equalsIgnoreCase(recipe.key)) || (material == null)) { @@ -97,22 +85,23 @@ public class TiCTweaks { } } } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new Remove(recipes)); } - } + } - // Removes a recipe, apply is never the same for anything, so will always - // need to override it - private static class Remove extends BaseListRemoval { - public Remove(List recipes) { - super("Repair Material", PatternBuilder.instance.materials, recipes); - } + // Removes a recipe, apply is never the same for anything, so will always + // need to override it + private static class Remove extends BaseListRemoval { - @Override - protected String getRecipeInfo(ItemKey recipe) { - return LogHelper.getStackDescription(new ItemStack(recipe.item, 1, recipe.damage)); - } - } + public Remove(List recipes) { + super("Repair Material", PatternBuilder.instance.materials, recipes); + } + + @Override + protected String getRecipeInfo(ItemKey recipe) { + return LogHelper.getStackDescription(new ItemStack(recipe.item, 1, recipe.damage)); + } + } } diff --git a/src/main/java/modtweaker2/mods/tconstruct/handlers/ToolStats.java b/src/main/java/modtweaker2/mods/tconstruct/handlers/ToolStats.java index a84f006..b1a4d37 100644 --- a/src/main/java/modtweaker2/mods/tconstruct/handlers/ToolStats.java +++ b/src/main/java/modtweaker2/mods/tconstruct/handlers/ToolStats.java @@ -14,14 +14,31 @@ import tconstruct.library.tools.ToolMaterial; @ZenClass("mods.tconstruct.ToolStats") public class ToolStats { + /** * @deprecated */ @java.lang.Deprecated @ZenMethod - public static void set(String material, @Optional String name, int level, int durability, int speed, int damage, double handle, int reinforced, double stonebound, String style, String ability) { + public static void set(String material, @Optional String name, int level, int durability, int speed, int damage, + double handle, int reinforced, double stonebound, String style, String ability) { if (name == null) name = material + " "; - MineTweakerAPI.apply(new SetToolStats(material, "", new ToolMaterial(material, name, level, durability, speed, damage, (float) handle, reinforced, (float) stonebound, style, 0xFFFFFF))); + MineTweakerAPI.apply( + new SetToolStats( + material, + "", + new ToolMaterial( + material, + name, + level, + durability, + speed, + damage, + (float) handle, + reinforced, + (float) stonebound, + style, + 0xFFFFFF))); } /** @@ -29,15 +46,47 @@ public class ToolStats { */ @java.lang.Deprecated @ZenMethod - public static void set(String material, @Optional String name, int level, int durability, int speed, int damage, double handle, int reinforced, double stonebound, String style, int primaryColor) { + public static void set(String material, @Optional String name, int level, int durability, int speed, int damage, + double handle, int reinforced, double stonebound, String style, int primaryColor) { if (name == null) name = material + " "; - MineTweakerAPI.apply(new SetToolStats(material, "", new ToolMaterial(material, name, level, durability, speed, damage, (float) handle, reinforced, (float) stonebound, style, primaryColor))); + MineTweakerAPI.apply( + new SetToolStats( + material, + "", + new ToolMaterial( + material, + name, + level, + durability, + speed, + damage, + (float) handle, + reinforced, + (float) stonebound, + style, + primaryColor))); } - + @ZenMethod - public static void setStats(String material, @Optional String name, int level, int durability, int speed, int damage, double handle, int reinforced, double stonebound, String style, int primaryColor) { + public static void setStats(String material, @Optional String name, int level, int durability, int speed, + int damage, double handle, int reinforced, double stonebound, String style, int primaryColor) { if (name == null) name = material + " "; - MineTweakerAPI.apply(new SetToolStats(material, "", new ToolMaterial(material, name, level, durability, speed, damage, (float) handle, reinforced, (float) stonebound, style, primaryColor))); + MineTweakerAPI.apply( + new SetToolStats( + material, + "", + new ToolMaterial( + material, + name, + level, + durability, + speed, + damage, + (float) handle, + reinforced, + (float) stonebound, + style, + primaryColor))); } @ZenMethod @@ -90,8 +139,9 @@ public class ToolStats { MineTweakerAPI.apply(new SetToolStats(material, "ability", name)); } - //Sets various variables with reflection, making my life partially easier :D + // Sets various variables with reflection, making my life partially easier :D private static class SetToolStats implements IUndoableAction { + protected int id; protected Object old; protected Object fresh; @@ -114,7 +164,18 @@ public class ToolStats { fresh = (ToolMaterial) value; } else { ToolMaterial t = (ToolMaterial) old; - fresh = new ToolMaterial(t.materialName, t.localizationString, t.harvestLevel, t.durability, t.miningspeed, t.attack, t.handleModifier, t.reinforced, t.stonebound, t.tipStyle, t.primaryColor); + fresh = new ToolMaterial( + t.materialName, + t.localizationString, + t.harvestLevel, + t.durability, + t.miningspeed, + t.attack, + t.handleModifier, + t.reinforced, + t.stonebound, + t.tipStyle, + t.primaryColor); ReflectionHelper.setPrivateValue(ToolMaterial.class, fresh, field, value); } @@ -152,10 +213,11 @@ public class ToolStats { ////////////////////////////////////////////////////////////////////////////////////////////////////// - //Bow Stats + // Bow Stats @ZenMethod public static void setBowStats(String material, int durability, int drawspeed, double flightspeed) { - MineTweakerAPI.apply(new SetBowStats(material, "", new BowMaterial(durability, drawspeed, (float) flightspeed))); + MineTweakerAPI + .apply(new SetBowStats(material, "", new BowMaterial(durability, drawspeed, (float) flightspeed))); } @ZenMethod @@ -175,6 +237,7 @@ public class ToolStats { // Bow Stats private static class SetBowStats extends SetToolStats { + public SetBowStats(String material, String field, Object value) { super(material, field, value); } @@ -209,10 +272,14 @@ public class ToolStats { ////////////////////////////////////////////////////////////////////////////////////////////////////// - //Arrow Stats + // Arrow Stats @ZenMethod public static void setArrowStats(String material, double mass, double breakChance, double accuracy) { - MineTweakerAPI.apply(new SetArrowStats(material, "", new ArrowMaterial((float) mass, (float) breakChance, (float) accuracy))); + MineTweakerAPI.apply( + new SetArrowStats( + material, + "", + new ArrowMaterial((float) mass, (float) breakChance, (float) accuracy))); } @ZenMethod @@ -232,6 +299,7 @@ public class ToolStats { // Bow Stats private static class SetArrowStats extends SetToolStats { + public SetArrowStats(String material, String field, Object value) { super(material, field, value); } diff --git a/src/main/java/modtweaker2/mods/thaumcraft/Thaumcraft.java b/src/main/java/modtweaker2/mods/thaumcraft/Thaumcraft.java index 01eb419..2da6342 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/Thaumcraft.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/Thaumcraft.java @@ -11,14 +11,15 @@ import modtweaker2.mods.thaumcraft.handlers.Research; import modtweaker2.mods.thaumcraft.handlers.Warp; public class Thaumcraft { - public Thaumcraft() { - MineTweakerAPI.registerBracketHandler(new AspectBracketHandler()); - MineTweakerAPI.registerClass(Arcane.class); - MineTweakerAPI.registerClass(Aspects.class); - MineTweakerAPI.registerClass(Crucible.class); - MineTweakerAPI.registerClass(Infusion.class); - MineTweakerAPI.registerClass(Research.class); - MineTweakerAPI.registerClass(Warp.class); - MineTweakerAPI.registerClass(Loot.class); - } + + public Thaumcraft() { + MineTweakerAPI.registerBracketHandler(new AspectBracketHandler()); + MineTweakerAPI.registerClass(Arcane.class); + MineTweakerAPI.registerClass(Aspects.class); + MineTweakerAPI.registerClass(Crucible.class); + MineTweakerAPI.registerClass(Infusion.class); + MineTweakerAPI.registerClass(Research.class); + MineTweakerAPI.registerClass(Warp.class); + MineTweakerAPI.registerClass(Loot.class); + } } diff --git a/src/main/java/modtweaker2/mods/thaumcraft/ThaumcraftHelper.java b/src/main/java/modtweaker2/mods/thaumcraft/ThaumcraftHelper.java index 38a97cc..2d4c931 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/ThaumcraftHelper.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/ThaumcraftHelper.java @@ -1,5 +1,11 @@ package modtweaker2.mods.thaumcraft; +import static modtweaker2.ModTweaker2.logger; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + import modtweaker2.helpers.LogHelper; import modtweaker2.helpers.ReflectionHelper; import modtweaker2.mods.thaumcraft.aspect.AspectStack; @@ -12,13 +18,8 @@ import thaumcraft.api.research.ResearchCategories; import thaumcraft.api.research.ResearchCategoryList; import thaumcraft.api.research.ResearchItem; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import static modtweaker2.ModTweaker2.logger; - public class ThaumcraftHelper { + public static HashMap warpList; static { @@ -34,13 +35,10 @@ public class ThaumcraftHelper { } public static AspectList parseAspects(AspectList list, String str) { - AspectList output=new AspectList(); - if (list != null) - for(Aspect aspect : list.getAspectsSortedAmount()) - { - if(aspect!=null) - output.add(aspect, list.getAmount(aspect)); - } + AspectList output = new AspectList(); + if (list != null) for (Aspect aspect : list.getAspectsSortedAmount()) { + if (aspect != null) output.add(aspect, list.getAmount(aspect)); + } if (str == null || str.equals("")) return list; String[] aspects = str.split(","); for (String aspect : aspects) { @@ -53,19 +51,16 @@ public class ThaumcraftHelper { } public static AspectList removeAspects(AspectList list, String str) { - AspectList output=new AspectList(); - if (list != null) - for(Aspect aspect : list.getAspectsSortedAmount()) - { - if(aspect!=null) - output.add(aspect, list.getAmount(aspect)); - } + AspectList output = new AspectList(); + if (list != null) for (Aspect aspect : list.getAspectsSortedAmount()) { + if (aspect != null) output.add(aspect, list.getAmount(aspect)); + } String[] aspects = str.split(","); for (String aspect : aspects) { if (aspect.startsWith(" ")) aspect = aspect.replaceFirst(" ", ""); String[] aspct = aspect.split("\\s+"); if (aspct.length == 2) { - output.remove(Aspect.aspects.get(aspct[0]), Integer.parseInt(aspct[1])); + output.remove(Aspect.aspects.get(aspct[0]), Integer.parseInt(aspct[1])); } } @@ -81,36 +76,29 @@ public class ThaumcraftHelper { return null; } - public static AspectList getEntityAspects(String name) { - for(EntityTags tag : ThaumcraftApi.scanEntities) - { - if(tag.entityName==name && tag.nbts.length==0) - return tag.aspects; - } - return null; - } + public static AspectList getEntityAspects(String name) { + for (EntityTags tag : ThaumcraftApi.scanEntities) { + if (tag.entityName == name && tag.nbts.length == 0) return tag.aspects; + } + return null; + } + + public static void removeEntityAspects(String name) { + List tags = new ArrayList(ThaumcraftApi.scanEntities); + for (EntityTags tag : tags) { + if (tag.entityName == name && tag.nbts.length == 0) ThaumcraftApi.scanEntities.remove(tag); + } + } + + public static String aspectsToString(AspectList aspects) { + System.out.println(aspects); + String output = ""; + for (Aspect aspect : aspects.getAspectsSortedAmount()) { + if (aspect != null) output += aspect.getName() + " " + aspects.getAmount(aspect) + ","; + } + return output; + } - public static void removeEntityAspects(String name) { - List tags = new ArrayList(ThaumcraftApi.scanEntities); - for(EntityTags tag : tags) - { - if(tag.entityName==name && tag.nbts.length==0) - ThaumcraftApi.scanEntities.remove(tag); - } - } - - public static String aspectsToString(AspectList aspects) - { - System.out.println(aspects); - String output=""; - for(Aspect aspect : aspects.getAspectsSortedAmount()) - { - if(aspect!=null) - output+=aspect.getName()+" "+aspects.getAmount(aspect)+","; - } - return output; - } - public static AspectStack[] toStacks(IAspectStack[] iStack) { if (iStack == null) { return null; @@ -123,7 +111,7 @@ public class ThaumcraftHelper { return output; } } - + public static AspectStack toStack(IAspectStack iStack) { if (iStack == null) { return null; @@ -136,15 +124,15 @@ public class ThaumcraftHelper { return (AspectStack) internal; } } - + public static ResearchItem getResearchSafe(String tab, String key) { final ResearchCategoryList cat = ResearchCategories.researchCategories.get(tab); - if(cat == null) { + if (cat == null) { logger.error("SCRIPT ERROR: Error, research tab {} doesn't exist", tab); return null; } final ResearchItem research = cat.research.get(key); - if(research == null) { + if (research == null) { logger.error("SCRIPT ERROR: Research {} doesn't exist.", key); return null; } diff --git a/src/main/java/modtweaker2/mods/thaumcraft/aspect/AspectBracketHandler.java b/src/main/java/modtweaker2/mods/thaumcraft/aspect/AspectBracketHandler.java index 456c49f..db261e5 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/aspect/AspectBracketHandler.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/aspect/AspectBracketHandler.java @@ -21,12 +21,12 @@ public class AspectBracketHandler implements IBracketHandler { private final IZenSymbol symbolAny; private final IJavaMethod method; - + public AspectBracketHandler() { this.symbolAny = MineTweakerAPI.getJavaStaticFieldSymbol(IngredientAny.class, "INSTANCE"); this.method = MineTweakerAPI.getJavaMethod(AspectBracketHandler.class, "getAspect", String.class); } - + public static IAspectStack getAspect(String name) { Aspect aspect = Aspect.getAspect(name.toLowerCase()); if (aspect != null) { @@ -35,13 +35,13 @@ public class AspectBracketHandler implements IBracketHandler { return null; } } - + @Override public IZenSymbol resolve(IEnvironmentGlobal environment, List tokens) { if (tokens.size() == 1 && tokens.get(0).getValue().equals("*")) { return symbolAny; } - + if (tokens.size() > 2) { if (tokens.get(0).getValue().equals("aspect") && tokens.get(1).getValue().equals(":")) { return find(environment, tokens, 2, tokens.size()); @@ -60,8 +60,8 @@ public class AspectBracketHandler implements IBracketHandler { } Aspect aspect = Aspect.getAspect(value.toString().toLowerCase()); - - if(aspect != null) { + + if (aspect != null) { return new AspectReferenceSymbol(environment, value.toString()); } @@ -69,6 +69,7 @@ public class AspectBracketHandler implements IBracketHandler { } private class AspectReferenceSymbol implements IZenSymbol { + private final IEnvironmentGlobal environment; private final String name; diff --git a/src/main/java/modtweaker2/mods/thaumcraft/aspect/AspectStack.java b/src/main/java/modtweaker2/mods/thaumcraft/aspect/AspectStack.java index a12d9cf..e07dd81 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/aspect/AspectStack.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/aspect/AspectStack.java @@ -4,41 +4,42 @@ import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; public class AspectStack { + public Aspect aspect; public int amount; - + public AspectStack(Aspect aspect, int amount) { this.aspect = aspect; this.amount = amount; } - + public Aspect getAspect() { return aspect; } - + public AspectList getAspectList() { AspectList aspectList = new AspectList(); aspectList.add(aspect, amount); return aspectList; } - + public static AspectList join(AspectList... aspectLists) { AspectList result = new AspectList(); - - for(AspectList aspectList : aspectLists) { + + for (AspectList aspectList : aspectLists) { result.add(aspectList); } - + return result; } - + public static AspectList join(AspectStack... aspectStacks) { AspectList result = new AspectList(); - - for(AspectStack stack : aspectStacks) { + + for (AspectStack stack : aspectStacks) { result.add(stack.getAspectList()); } - + return result; } } diff --git a/src/main/java/modtweaker2/mods/thaumcraft/aspect/IAspectStack.java b/src/main/java/modtweaker2/mods/thaumcraft/aspect/IAspectStack.java index 842fc05..913e0a6 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/aspect/IAspectStack.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/aspect/IAspectStack.java @@ -11,22 +11,22 @@ import stanhebben.zenscript.annotations.ZenOperator; @ZenClass("modtweaker.aspect.IAspectStack") public interface IAspectStack extends IIngredient { - + @ZenGetter("definition") public abstract IAspectDefinition getDefinition(); - + @ZenGetter("name") public abstract String getName(); - + @ZenGetter("displayName") public abstract String getDisplayName(); - + @ZenOperator(OperatorType.MUL) @ZenMethod public abstract IAspectStack amount(int amount); - + @ZenMethod public abstract IAspectStack withAmount(int amount); - + public abstract List getAspects(); } diff --git a/src/main/java/modtweaker2/mods/thaumcraft/aspect/MCAspectDefinition.java b/src/main/java/modtweaker2/mods/thaumcraft/aspect/MCAspectDefinition.java index e476cb8..bf4b02f 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/aspect/MCAspectDefinition.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/aspect/MCAspectDefinition.java @@ -1,7 +1,5 @@ package modtweaker2.mods.thaumcraft.aspect; - - public class MCAspectDefinition implements IAspectDefinition { public MCAspectDefinition(AspectStack stack) { diff --git a/src/main/java/modtweaker2/mods/thaumcraft/aspect/MCAspectStack.java b/src/main/java/modtweaker2/mods/thaumcraft/aspect/MCAspectStack.java index 8df48bf..a78f53b 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/aspect/MCAspectStack.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/aspect/MCAspectStack.java @@ -11,22 +11,23 @@ import minetweaker.api.item.IngredientOr; import minetweaker.api.liquid.ILiquidStack; import minetweaker.api.minecraft.MineTweakerMC; import minetweaker.api.player.IPlayer; + import net.minecraft.item.ItemStack; + import thaumcraft.api.aspects.AspectList; - public class MCAspectStack implements IAspectStack { - + private final AspectStack stack; private final List aspects; - + public MCAspectStack(AspectStack stack) { - if(stack == null) throw new IllegalArgumentException("stack cannot be null"); - + if (stack == null) throw new IllegalArgumentException("stack cannot be null"); + this.stack = stack; this.aspects = Collections.singletonList(this); } - + @Override public IItemStack applyTransform(IItemStack arg0, IPlayer arg1) { return null; @@ -34,20 +35,20 @@ public class MCAspectStack implements IAspectStack { @Override public boolean contains(IIngredient ingredient) { - if(ingredient instanceof MCAspectStack) { - List aspects = ((MCAspectStack)ingredient).getAspects(); - - if((aspects == null) || (aspects.size() != 1)) { + if (ingredient instanceof MCAspectStack) { + List aspects = ((MCAspectStack) ingredient).getAspects(); + + if ((aspects == null) || (aspects.size() != 1)) { return false; } - + return matches(aspects.get(0)); } else { List iitems = ingredient.getItems(); if ((iitems == null) || (iitems.size() != 1)) { - return false; + return false; } - return matches((IItemStack)iitems.get(0)); + return matches((IItemStack) iitems.get(0)); } } @@ -65,7 +66,7 @@ public class MCAspectStack implements IAspectStack { public List getItems() { return null; } - + @Override public List getAspects() { return this.aspects; @@ -94,29 +95,29 @@ public class MCAspectStack implements IAspectStack { @Override public boolean matches(IItemStack item) { ItemStack internal = MineTweakerMC.getItemStack(item); - - if(internal != null) { + + if (internal != null) { AspectList itemAspectList = new AspectList(internal); - - if(itemAspectList.aspects.keySet().contains(stack.aspect.getTag())) { + + if (itemAspectList.aspects.keySet().contains(stack.aspect.getTag())) { return true; } } - + return false; } - + public boolean matches(IAspectStack aspect) { - if(aspect != null) { + if (aspect != null) { Object internal = aspect.getInternal(); - - if(internal != null && internal instanceof AspectStack) { - if(this.stack.aspect.getTag().equals(((AspectStack)internal).aspect.getTag())) { + + if (internal != null && internal instanceof AspectStack) { + if (this.stack.aspect.getTag().equals(((AspectStack) internal).aspect.getTag())) { return true; } } } - + return false; } @@ -167,17 +168,17 @@ public class MCAspectStack implements IAspectStack { AspectStack result = new AspectStack(this.stack.aspect, amount); return new MCAspectStack(result); } - + @Override public String toString() { StringBuilder sb = new StringBuilder(); - + sb.append("'); - - if(stack.amount > 1) { + + if (stack.amount > 1) { sb.append(" * ").append(stack.amount); } - + return sb.toString(); } } diff --git a/src/main/java/modtweaker2/mods/thaumcraft/commands/AspectLogger.java b/src/main/java/modtweaker2/mods/thaumcraft/commands/AspectLogger.java index 490c08a..c60ee3c 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/commands/AspectLogger.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/commands/AspectLogger.java @@ -6,21 +6,31 @@ import minetweaker.api.player.IPlayer; import minetweaker.api.server.ICommandFunction; import thaumcraft.api.aspects.Aspect; -public class AspectLogger implements ICommandFunction{ +public class AspectLogger implements ICommandFunction { @Override public void execute(String[] arguments, IPlayer player) { - - for(Aspect aspect : Aspect.getPrimalAspects()) { - MineTweakerAPI.logCommand(" // " + aspect.getLocalizedDescription()); - } - - for(Aspect aspect : Aspect.getCompoundAspects()) { - MineTweakerAPI.logCommand(" // " + aspect.getLocalizedDescription() + " [, ]"); - } - + + for (Aspect aspect : Aspect.getPrimalAspects()) { + MineTweakerAPI.logCommand(" // " + aspect.getLocalizedDescription()); + } + + for (Aspect aspect : Aspect.getCompoundAspects()) { + MineTweakerAPI.logCommand( + " // " + + aspect.getLocalizedDescription() + + " [, ]"); + } + if (player != null) { - player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir")); + player.sendChat( + MineTweakerImplementationAPI.platform + .getMessage("List generated; see minetweaker.log in your minecraft dir")); } } } diff --git a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Arcane.java b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Arcane.java index 09d35df..1575b2b 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Arcane.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Arcane.java @@ -16,7 +16,9 @@ import modtweaker2.helpers.LogHelper; import modtweaker2.mods.thaumcraft.ThaumcraftHelper; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; + import net.minecraft.item.ItemStack; + import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; import thaumcraft.api.ThaumcraftApi; @@ -26,74 +28,85 @@ import thaumcraft.api.crafting.ShapelessArcaneRecipe; @ZenClass("mods.thaumcraft.Arcane") public class Arcane { - + public static final String name = "Thaumcraft Arcane Worktable"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - @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)))); - } - @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)))); - } + @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)))); + } - private static class Add extends BaseListAddition { - public Add(IArcaneRecipe recipe) { - super(Arcane.name, ThaumcraftApi.getCraftingRecipes()); - recipes.add(recipe); - } + @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)))); + } - @Override - protected String getRecipeInfo(IArcaneRecipe recipe) { - ItemStack stack = recipe.getRecipeOutput(); - - if(stack instanceof ItemStack) - return LogHelper.getStackDescription(stack); - else - return "Unknown output"; - } - } + private static class Add extends BaseListAddition { - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - @ZenMethod - public static void removeRecipe(IIngredient output) { - List recipes = new LinkedList(); - - for(Object o : ThaumcraftApi.getCraftingRecipes()) { - if(o != null && o instanceof IArcaneRecipe) { - IArcaneRecipe recipe = (IArcaneRecipe)o; - - if(recipe.getRecipeOutput() != null && matches(output, toIItemStack(recipe.getRecipeOutput()))) { - recipes.add(recipe); - } - } - } - - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new Remove(recipes)); - } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command Ignored", Arcane.name, output.toString())); - } - } - - private static class Remove extends BaseListRemoval { - public Remove(List recipes) { - super(Arcane.name, ThaumcraftApi.getCraftingRecipes(), recipes); - } + public Add(IArcaneRecipe recipe) { + super(Arcane.name, ThaumcraftApi.getCraftingRecipes()); + recipes.add(recipe); + } @Override protected String getRecipeInfo(IArcaneRecipe recipe) { ItemStack stack = recipe.getRecipeOutput(); - - if(stack instanceof ItemStack) - return LogHelper.getStackDescription(stack); - else - return "Unknown output"; + + if (stack instanceof ItemStack) return LogHelper.getStackDescription(stack); + else return "Unknown output"; } - } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + @ZenMethod + public static void removeRecipe(IIngredient output) { + List recipes = new LinkedList(); + + for (Object o : ThaumcraftApi.getCraftingRecipes()) { + if (o != null && o instanceof IArcaneRecipe) { + IArcaneRecipe recipe = (IArcaneRecipe) o; + + if (recipe.getRecipeOutput() != null && matches(output, toIItemStack(recipe.getRecipeOutput()))) { + recipes.add(recipe); + } + } + } + + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new Remove(recipes)); + } else { + LogHelper.logWarning( + String.format("No %s Recipe found for %s. Command Ignored", Arcane.name, output.toString())); + } + } + + private static class Remove extends BaseListRemoval { + + public Remove(List recipes) { + super(Arcane.name, ThaumcraftApi.getCraftingRecipes(), recipes); + } + + @Override + protected String getRecipeInfo(IArcaneRecipe recipe) { + ItemStack stack = recipe.getRecipeOutput(); + + if (stack instanceof ItemStack) return LogHelper.getStackDescription(stack); + else return "Unknown output"; + } + } } diff --git a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Aspects.java b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Aspects.java index 2c5968c..a6b98f4 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Aspects.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Aspects.java @@ -8,8 +8,10 @@ import minetweaker.MineTweakerAPI; import minetweaker.api.item.IItemStack; import modtweaker2.mods.thaumcraft.ThaumcraftHelper; import modtweaker2.utils.BaseUndoable; + import net.minecraft.entity.EntityList; import net.minecraft.item.ItemStack; + import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; import thaumcraft.api.ThaumcraftApi; @@ -18,229 +20,229 @@ 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)); - } - @ZenMethod - public static void set(IItemStack stack, String aspects) { - - MineTweakerAPI.apply(new Add(toStack(stack), aspects, true)); - } + /** Add/Remove/Set Aspects for items **/ + @ZenMethod + public static void add(IItemStack stack, String aspects) { - // Adds or sets Aspects - private static class Add extends BaseUndoable { - private final ItemStack stack; - private final String aspects; - private final boolean replace; - private AspectList oldList; + MineTweakerAPI.apply(new Add(toStack(stack), aspects, false)); + } - public Add(ItemStack stack, String aspects, boolean replace) { - super("Aspects"); - this.stack = stack; - this.aspects = aspects; - this.replace = replace; - } + @ZenMethod + public static void set(IItemStack stack, String aspects) { - @Override - public void apply() { - AspectList newList; - if (replace) { - newList = ThaumcraftHelper.parseAspects(aspects); - } else { - oldList = ThaumcraftApiHelper.getObjectAspects(stack); - newList = ThaumcraftHelper.parseAspects(oldList, aspects); - } + MineTweakerAPI.apply(new Add(toStack(stack), aspects, true)); + } - ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), newList); - - success = true; - } + // Adds or sets Aspects + private static class Add extends BaseUndoable { - @Override - public boolean canUndo() { - return !replace; - } + private final ItemStack stack; + private final String aspects; + private final boolean replace; + private AspectList oldList; - @Override - public void undo() { - if (replace) - return; - if (oldList == null) { - ThaumcraftApi.objectTags.remove(Arrays.asList(stack.getItem(), stack.getItemDamage())); - } else - ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), oldList); - } + public Add(ItemStack stack, String aspects, boolean replace) { + super("Aspects"); + this.stack = stack; + this.aspects = aspects; + this.replace = replace; + } - @Override - public String getRecipeInfo() { - return stack.getDisplayName(); - } - } + @Override + public void apply() { + AspectList newList; + if (replace) { + newList = ThaumcraftHelper.parseAspects(aspects); + } else { + oldList = ThaumcraftApiHelper.getObjectAspects(stack); + newList = ThaumcraftHelper.parseAspects(oldList, aspects); + } - // //////////////////////////////////////////////////////////////////////////// + ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), newList); - @ZenMethod - public static void remove(IItemStack stack, String aspects) { - - MineTweakerAPI.apply(new Remove(toStack(stack), aspects)); - } + success = true; + } - private static class Remove extends BaseUndoable { - private final ItemStack stack; - private final String aspects; - private AspectList oldList; - private AspectList newList; + @Override + public boolean canUndo() { + return !replace; + } - public Remove(ItemStack stack, String aspects) { - super("Aspects"); - this.stack = stack; - this.aspects = aspects; - } + @Override + public void undo() { + if (replace) return; + 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 apply() { - oldList = ThaumcraftApiHelper.getObjectAspects(stack); - if (oldList != null) { - newList = ThaumcraftHelper.removeAspects(oldList, aspects); - ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), newList); - } - - success = true; - } + @Override + public String getRecipeInfo() { + return stack.getDisplayName(); + } + } - @Override - public boolean canUndo() { - return oldList != null; - } + // //////////////////////////////////////////////////////////////////////////// - @Override - public void undo() { - ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), oldList); - } + @ZenMethod + public static void remove(IItemStack stack, String aspects) { - @Override - public String getRecipeInfo() { - return stack.getDisplayName(); - } - } + MineTweakerAPI.apply(new Remove(toStack(stack), aspects)); + } - /** 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)); - } + private static class Remove extends BaseUndoable { - @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)); - } + private final ItemStack stack; + private final String aspects; + private AspectList oldList; + private AspectList newList; - // Adds or sets Aspects - private static class AddEntity extends BaseUndoable { - private final String entityName; - private final String aspects; - private final boolean replace; - private AspectList oldList; - private AspectList newList; + public Remove(ItemStack stack, String aspects) { + super("Aspects"); + this.stack = stack; + this.aspects = aspects; + } - public AddEntity(String entityName, String aspects, boolean replace) { - super("Aspects"); - this.entityName = entityName; - this.aspects = aspects; - this.replace = replace; - } + @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 = ThaumcraftHelper.getEntityAspects(entityName); - if (!replace) - newList = ThaumcraftHelper.parseAspects(oldList, aspects); - else - newList = ThaumcraftHelper.parseAspects(aspects); - ThaumcraftHelper.removeEntityAspects(entityName); - ThaumcraftApi.registerEntityTag(entityName, newList); - - success = true; - } + success = true; + } - @Override - public void undo() { - ThaumcraftHelper.removeEntityAspects(entityName); - if (oldList != null) - ThaumcraftApi.registerEntityTag(entityName, oldList); - } + @Override + public boolean canUndo() { + return oldList != null; + } - @Override - public String getRecipeInfo() { - return entityName; - } - } + @Override + public void undo() { + ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), oldList); + } - // //////////////////////////////////////////////////////////////////////////// + @Override + public String getRecipeInfo() { + return stack.getDisplayName(); + } + } - @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)); - } + /** 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; + } - private static class RemoveEntity extends BaseUndoable { - private final String entityName; - private final String aspects; - private AspectList oldList; - private AspectList newList; + MineTweakerAPI.apply(new AddEntity(entityName, aspects, false)); + } - public RemoveEntity(String entityName, String aspects) { - super("Aspects"); - this.entityName = entityName; - this.aspects = aspects; - } + @ZenMethod + public static void setEntity(String entityName, String aspects) { + if (!EntityList.stringToClassMapping.containsKey(entityName)) { + MineTweakerAPI.getLogger().logError("No such entity " + entityName); + return; + } - @Override - public void apply() { - oldList = ThaumcraftHelper.getEntityAspects(entityName); - if (oldList != null) { - newList = ThaumcraftHelper.removeAspects(oldList, aspects); - ThaumcraftHelper.removeEntityAspects(entityName); - ThaumcraftApi.registerEntityTag(entityName, newList); - } - - success = true; - } + MineTweakerAPI.apply(new AddEntity(entityName, aspects, true)); + } - @Override - public boolean canUndo() { - return oldList != null; - } + // Adds or sets Aspects + private static class AddEntity extends BaseUndoable { - @Override - public void undo() { - ThaumcraftHelper.removeEntityAspects(entityName); - ThaumcraftApi.registerEntityTag(entityName, oldList); - } + private final String entityName; + private final String aspects; + private final boolean replace; + private AspectList oldList; + private AspectList newList; - @Override - public String getRecipeInfo() { - return entityName; - } - } + 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); + + success = true; + } + + @Override + public void undo() { + ThaumcraftHelper.removeEntityAspects(entityName); + if (oldList != null) ThaumcraftApi.registerEntityTag(entityName, oldList); + } + + @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)); + } + + private static class RemoveEntity extends BaseUndoable { + + 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; + } + + @Override + public void apply() { + oldList = ThaumcraftHelper.getEntityAspects(entityName); + if (oldList != null) { + newList = ThaumcraftHelper.removeAspects(oldList, aspects); + ThaumcraftHelper.removeEntityAspects(entityName); + ThaumcraftApi.registerEntityTag(entityName, newList); + } + + success = true; + } + + @Override + public boolean canUndo() { + return oldList != null; + } + + @Override + public void undo() { + ThaumcraftHelper.removeEntityAspects(entityName); + ThaumcraftApi.registerEntityTag(entityName, oldList); + } + + @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 f362ab0..9d30f07 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Crucible.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Crucible.java @@ -22,32 +22,39 @@ import thaumcraft.api.crafting.CrucibleRecipe; @ZenClass("mods.thaumcraft.Crucible") public class Crucible { - + public static final String name = "Thaumcraft 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)))); - } - - private static class Add extends BaseListAddition { - public Add(CrucibleRecipe recipe) { - super(Crucible.name, ThaumcraftApi.getCraftingRecipes()); - recipes.add(recipe); - } - - @Override - protected String getRecipeInfo(CrucibleRecipe recipe) { - return LogHelper.getStackDescription(recipe.getRecipeOutput()); - } - } - // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + @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)))); + } + + private static class Add extends BaseListAddition { + + public Add(CrucibleRecipe recipe) { + super(Crucible.name, ThaumcraftApi.getCraftingRecipes()); + recipes.add(recipe); + } + + @Override + protected String getRecipeInfo(CrucibleRecipe recipe) { + return LogHelper.getStackDescription(recipe.getRecipeOutput()); + } + } + + // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + @ZenMethod + public static void removeRecipe(IIngredient output) { + List recipes = new LinkedList(); - @ZenMethod - public static void removeRecipe(IIngredient output) { - List recipes = new LinkedList(); - for (Object o : ThaumcraftApi.getCraftingRecipes()) { if (o instanceof CrucibleRecipe) { CrucibleRecipe r = (CrucibleRecipe) o; @@ -56,22 +63,24 @@ public class Crucible { } } } - - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new Remove(recipes)); - } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Crucible.name, output.toString())); - } - } - private static class Remove extends BaseListRemoval { - public Remove(List recipes) { - super(Crucible.name, ThaumcraftApi.getCraftingRecipes(), recipes); - } + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new Remove(recipes)); + } else { + LogHelper.logWarning( + String.format("No %s Recipe found for %s. Command ignored!", Crucible.name, output.toString())); + } + } + + private static class Remove extends BaseListRemoval { + + public Remove(List recipes) { + super(Crucible.name, ThaumcraftApi.getCraftingRecipes(), recipes); + } @Override protected String getRecipeInfo(CrucibleRecipe recipe) { return LogHelper.getStackDescription(recipe.getRecipeOutput()); } - } + } } diff --git a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Infusion.java b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Infusion.java index f242d4e..2c65e37 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Infusion.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Infusion.java @@ -16,8 +16,10 @@ import modtweaker2.mods.thaumcraft.ThaumcraftHelper; import modtweaker2.mods.thaumcraft.recipe.MTInfusionRecipe; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; + import net.minecraft.enchantment.Enchantment; import net.minecraft.item.ItemStack; + import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; import thaumcraft.api.ThaumcraftApi; @@ -26,83 +28,113 @@ import thaumcraft.api.crafting.InfusionRecipe; @ZenClass("mods.thaumcraft.Infusion") public class Infusion { - + public static final String name = "Thaumcraft Infusion"; public static final String enchName = name + " Enchantment"; - - @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)))); - } - // 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))); - } + @ZenMethod + public static void addRecipe(String key, IItemStack input, IItemStack[] recipe, String aspects, IItemStack result, + int instability) { - @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)))); - } + MineTweakerAPI.apply( + new Add( + new InfusionRecipe( + key, + toStack(result), + instability, + ThaumcraftHelper.parseAspects(aspects), + toStack(input), + toStacks(recipe)))); + } - private static class Add extends BaseListAddition { - public Add(InfusionRecipe recipe) { - super(Infusion.name, ThaumcraftApi.getCraftingRecipes()); - recipes.add(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))); + } - @Override - protected String getRecipeInfo(InfusionRecipe recipe) { + @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)))); + } + + private static class Add extends BaseListAddition { + + public Add(InfusionRecipe recipe) { + super(Infusion.name, ThaumcraftApi.getCraftingRecipes()); + recipes.add(recipe); + } + + @Override + protected String getRecipeInfo(InfusionRecipe recipe) { Object out = ((InfusionRecipe) recipe).getRecipeOutput(); if (out instanceof ItemStack) { return ((ItemStack) out).getDisplayName(); - } else - return "Unknown item"; - } - } + } else return "Unknown item"; + } + } + + private static class AddEnchant extends BaseListAddition { + + public AddEnchant(InfusionEnchantmentRecipe inp) { + super(Infusion.enchName, ThaumcraftApi.getCraftingRecipes()); + recipes.add(inp); + } - private static class AddEnchant extends BaseListAddition { - public AddEnchant(InfusionEnchantmentRecipe inp) { - super(Infusion.enchName, ThaumcraftApi.getCraftingRecipes()); - recipes.add(inp); - } - @Override protected String getRecipeInfo(InfusionEnchantmentRecipe recipe) { return recipe.getEnchantment().getName(); } - } + } - // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - @ZenMethod - public static void removeRecipe(IIngredient output) { - List recipes = new LinkedList(); + @ZenMethod + public static void removeRecipe(IIngredient output) { + List recipes = new LinkedList(); - for (Object o : ThaumcraftApi.getCraftingRecipes()) { + for (Object o : ThaumcraftApi.getCraftingRecipes()) { if (o instanceof InfusionRecipe) { InfusionRecipe r = (InfusionRecipe) o; - if (r.getRecipeOutput() != null && r.getRecipeOutput() instanceof ItemStack && matches(output, toIItemStack((ItemStack)r.getRecipeOutput()))) { + if (r.getRecipeOutput() != null && r.getRecipeOutput() instanceof ItemStack + && matches(output, toIItemStack((ItemStack) r.getRecipeOutput()))) { recipes.add(r); } } } - - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new Remove(recipes)); - } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Infusion.name, output.toString())); - } - } - @ZenMethod - public static void removeEnchant(int id) { - List recipes = new LinkedList(); - Enchantment ench = Enchantment.enchantmentsList[id]; - + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new Remove(recipes)); + } else { + LogHelper.logWarning( + String.format("No %s Recipe found for %s. Command ignored!", Infusion.name, output.toString())); + } + } + + @ZenMethod + public static void removeEnchant(int id) { + List recipes = new LinkedList(); + Enchantment ench = Enchantment.enchantmentsList[id]; + for (Object recipe : ThaumcraftApi.getCraftingRecipes()) { if (recipe instanceof InfusionEnchantmentRecipe) { InfusionEnchantmentRecipe enchRecipe = (InfusionEnchantmentRecipe) recipe; @@ -111,41 +143,46 @@ public class Infusion { } } } - - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new RemoveEnchant(recipes)); + + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new RemoveEnchant(recipes)); } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Infusion.enchName + " Enchantment", ench.getName())); + LogHelper.logWarning( + String.format( + "No %s Recipe found for %s. Command ignored!", + Infusion.enchName + " Enchantment", + ench.getName())); } - } + } - private static class Remove extends BaseListRemoval { - public Remove(List recipes) { - super(Infusion.name, ThaumcraftApi.getCraftingRecipes(), recipes); - } + private static class Remove extends BaseListRemoval { - @Override - protected String getRecipeInfo(InfusionRecipe recipe) { - - Object o = recipe.getRecipeOutput(); - - if(o instanceof ItemStack) { - return LogHelper.getStackDescription((ItemStack)o); - } else { - return "Unknown Item"; - } - } - } + public Remove(List recipes) { + super(Infusion.name, ThaumcraftApi.getCraftingRecipes(), recipes); + } - private static class RemoveEnchant extends BaseListRemoval { - public RemoveEnchant(List recipes) { - super(Infusion.enchName, ThaumcraftApi.getCraftingRecipes(), recipes); - } - - @Override - protected String getRecipeInfo(InfusionEnchantmentRecipe recipe) { - return recipe.getEnchantment().getName(); - } - } + @Override + protected String getRecipeInfo(InfusionRecipe recipe) { + + Object o = recipe.getRecipeOutput(); + + if (o instanceof ItemStack) { + return LogHelper.getStackDescription((ItemStack) o); + } else { + return "Unknown Item"; + } + } + } + + private static class RemoveEnchant extends BaseListRemoval { + + public RemoveEnchant(List recipes) { + super(Infusion.enchName, ThaumcraftApi.getCraftingRecipes(), recipes); + } + + @Override + protected String getRecipeInfo(InfusionEnchantmentRecipe recipe) { + return recipe.getEnchantment().getName(); + } + } } - diff --git a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Loot.java b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Loot.java index 4a67908..31c4aae 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Loot.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Loot.java @@ -19,79 +19,87 @@ import thaumcraft.api.internal.WeightedRandomLoot; @ZenClass("mods.thaumcraft.Loot") public class Loot { - + public static final String name = "Thaumcraft LootBag"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - @ZenMethod - public static void addCommonLoot(IItemStack stack, int weight) { - MineTweakerAPI.apply(new Add(WeightedRandomLoot.lootBagCommon, new WeightedRandomLoot(InputHelper.toStack(stack), weight))); - } + @ZenMethod + public static void addCommonLoot(IItemStack stack, int weight) { + MineTweakerAPI.apply( + new Add(WeightedRandomLoot.lootBagCommon, new WeightedRandomLoot(InputHelper.toStack(stack), weight))); + } - @ZenMethod - public static void addUncommonLoot(IItemStack stack, int weight) { - MineTweakerAPI.apply(new Add(WeightedRandomLoot.lootBagUncommon, new WeightedRandomLoot(InputHelper.toStack(stack), weight))); - } + @ZenMethod + public static void addUncommonLoot(IItemStack stack, int weight) { + MineTweakerAPI.apply( + new Add( + WeightedRandomLoot.lootBagUncommon, + new WeightedRandomLoot(InputHelper.toStack(stack), weight))); + } - @ZenMethod - public static void addRareLoot(IItemStack stack, int weight) { - MineTweakerAPI.apply(new Add(WeightedRandomLoot.lootBagRare, new WeightedRandomLoot(InputHelper.toStack(stack), weight))); - } + @ZenMethod + public static void addRareLoot(IItemStack stack, int weight) { + MineTweakerAPI.apply( + new Add(WeightedRandomLoot.lootBagRare, new WeightedRandomLoot(InputHelper.toStack(stack), weight))); + } + + public static class Add extends BaseListAddition { + + public Add(List list, WeightedRandomLoot recipe) { + super(Loot.name, list); + recipes.add(recipe); + } - public static class Add extends BaseListAddition { - public Add(List list, WeightedRandomLoot recipe) { - super(Loot.name, list); - recipes.add(recipe); - } - @Override protected String getRecipeInfo(WeightedRandomLoot recipe) { return LogHelper.getStackDescription(recipe.item); } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + } - @ZenMethod - public static void removeCommonLoot(IIngredient stack) { - removeLoot(WeightedRandomLoot.lootBagCommon, stack); - } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - @ZenMethod - public static void removeUncommonLoot(IIngredient stack) { - removeLoot(WeightedRandomLoot.lootBagUncommon, stack); - } + @ZenMethod + public static void removeCommonLoot(IIngredient stack) { + removeLoot(WeightedRandomLoot.lootBagCommon, stack); + } - @ZenMethod - public static void removeRareLoot(IIngredient stack) { - removeLoot(WeightedRandomLoot.lootBagRare, stack); - } - - public static void removeLoot(List list, IIngredient ingredient) { - List recipes = new LinkedList(); - - for (WeightedRandomLoot loot : list) { - if (matches(ingredient, toIItemStack(loot.item))) { - recipes.add(loot); - } - } - - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new Remove(list, recipes)); - } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored.", Loot.name, ingredient.toString())); - } - } + @ZenMethod + public static void removeUncommonLoot(IIngredient stack) { + removeLoot(WeightedRandomLoot.lootBagUncommon, stack); + } - public static class Remove extends BaseListRemoval { - public Remove(List list, List recipes) { - super(Loot.name, list, recipes); - } - - @Override - protected String getRecipeInfo(WeightedRandomLoot recipe) { - return LogHelper.getStackDescription(recipe.item); - } - } + @ZenMethod + public static void removeRareLoot(IIngredient stack) { + removeLoot(WeightedRandomLoot.lootBagRare, stack); + } + + public static void removeLoot(List list, IIngredient ingredient) { + List recipes = new LinkedList(); + + for (WeightedRandomLoot loot : list) { + if (matches(ingredient, toIItemStack(loot.item))) { + recipes.add(loot); + } + } + + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new Remove(list, recipes)); + } else { + LogHelper.logWarning( + String.format("No %s Recipe found for %s. Command ignored.", Loot.name, ingredient.toString())); + } + } + + public static class Remove extends BaseListRemoval { + + public Remove(List list, List recipes) { + super(Loot.name, list, recipes); + } + + @Override + protected String getRecipeInfo(WeightedRandomLoot recipe) { + return LogHelper.getStackDescription(recipe.item); + } + } } diff --git a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Research.java b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Research.java index 402e3b4..45d8e07 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Research.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Research.java @@ -1,6 +1,7 @@ package modtweaker2.mods.thaumcraft.handlers; import static modtweaker2.helpers.InputHelper.toStack; + import minetweaker.MineTweakerAPI; import minetweaker.api.item.IItemStack; import minetweaker.api.player.IPlayer; @@ -22,8 +23,10 @@ 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 net.minecraft.enchantment.Enchantment; import net.minecraft.util.ResourceLocation; + import stanhebben.zenscript.annotations.Optional; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; @@ -33,210 +36,256 @@ 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"); - @ZenMethod - public static void addTab(String key, String iconDomain, String iconPath) { - addTab(key, iconDomain, iconPath, null, null); - } + private static final ResourceLocation defaultBackground = new ResourceLocation( + "thaumcraft", + "textures/gui/gui_researchback.png"); - @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)); - } - - @ZenMethod - public static void removeTab(String tab) { - - - MineTweakerAPI.apply(new RemoveTab(tab)); - } - - @ZenMethod - public static void removeResearch(String research) { - - MineTweakerAPI.apply(new RemoveResearch(research)); - } - - @ZenMethod - public static void orphanResearch(String research) { - - MineTweakerAPI.apply(new OrphanResearch(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)), null, null, null)); - } - - @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)),null, null, null)); - } - - @ZenMethod - public static void addResearch(String key, String tab, @Optional String aspects, int x, int y, int difficulty, IItemStack item, IItemStack[] triggers, String[] entTriggers, String aspectsTrigger) { - - MineTweakerAPI.apply(new AddResearch(new ResearchItem(key, tab, ThaumcraftHelper.parseAspects(aspects), x, y, difficulty, toStack(item)), InputHelper.toStacks(triggers), entTriggers, ThaumcraftHelper.parseAspects(aspectsTrigger))); + @ZenMethod + public static void addTab(String key, String iconDomain, String iconPath) { + addTab(key, iconDomain, iconPath, null, null); } - @ZenMethod - public static void addPage(String key, String unlocalized) { - - MineTweakerAPI.apply(new AddPage(key, PageType.TEXT, unlocalized)); - } + @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 addCraftingPage(String key, IItemStack item) { - - MineTweakerAPI.apply(new AddPage(key, PageType.NORMAL_CRAFTING, toStack(item))); - } + private static void addTab(String key, ResourceLocation icon, ResourceLocation background) { - @ZenMethod - public static void addCruciblePage(String key, IItemStack item) { - - MineTweakerAPI.apply(new AddPage(key, PageType.CRUCIBLE_CRAFTING, toStack(item))); - } + MineTweakerAPI.apply(new AddTab(key, icon, background)); + } - @ZenMethod - public static void addArcanePage(String key, IItemStack item) { - - MineTweakerAPI.apply(new AddPage(key, PageType.ARCANE_CRAFTING, toStack(item))); - } + @ZenMethod + public static void removeTab(String tab) { - @ZenMethod - public static void addInfusionPage(String key, IItemStack item) { - - MineTweakerAPI.apply(new AddPage(key, PageType.INFUSION_CRAFTING, toStack(item))); - } + MineTweakerAPI.apply(new RemoveTab(tab)); + } - @ZenMethod - public static void addEnchantmentPage(String key, int i) { - - MineTweakerAPI.apply(new AddPage(key, PageType.INFUSION_ENCHANTMENT, Enchantment.enchantmentsList[i])); - } + @ZenMethod + public static void removeResearch(String research) { - @ZenMethod - public static void clearPages(String key) { - - MineTweakerAPI.apply(new ClearPages(key)); - } + MineTweakerAPI.apply(new RemoveResearch(research)); + } - @ZenMethod - public static void addPrereq(String key, String req, @Optional boolean hidden) { - - MineTweakerAPI.apply(new AddPrereq(key, req, hidden)); - } + @ZenMethod + public static void orphanResearch(String research) { - @ZenMethod - public static void clearPrereqs(String key) { - - MineTweakerAPI.apply(new ClearPrereqs(key)); - } + MineTweakerAPI.apply(new OrphanResearch(research)); + } - @ZenMethod - public static void addSibling(String key, String sibling) { - - MineTweakerAPI.apply(new AddSibling(key, sibling)); - } + @ZenMethod + public static void addResearch(String key, String tab, @Optional String aspects, int x, int y, int difficulty, + String domain, String path) { - @ZenMethod - public static void clearSiblings(String key) { - - MineTweakerAPI.apply(new ClearSiblings(key)); - } + MineTweakerAPI.apply( + new AddResearch( + new ResearchItem( + key, + tab, + ThaumcraftHelper.parseAspects(aspects), + x, + y, + difficulty, + new ResourceLocation(domain, path)), + null, + null, + null)); + } - @ZenMethod - public static void setRound(String key, boolean flag) { - - MineTweakerAPI.apply(new SetResearch(key, flag, SetType.ROUND)); - } + @ZenMethod + public static void addResearch(String key, String tab, @Optional String aspects, int x, int y, int difficulty, + IItemStack item) { - @ZenMethod - public static void setSpikey(String key, boolean flag) { - - MineTweakerAPI.apply(new SetResearch(key, flag, SetType.SPIKE)); - } + MineTweakerAPI.apply( + new AddResearch( + new ResearchItem( + key, + tab, + ThaumcraftHelper.parseAspects(aspects), + x, + y, + difficulty, + toStack(item)), + null, + null, + null)); + } - @ZenMethod - public static void setStub(String key, boolean flag) { - - MineTweakerAPI.apply(new SetResearch(key, flag, SetType.STUB)); - } + @ZenMethod + public static void addResearch(String key, String tab, @Optional String aspects, int x, int y, int difficulty, + IItemStack item, IItemStack[] triggers, String[] entTriggers, String aspectsTrigger) { - @ZenMethod - public static void setSecondary(String key, boolean flag) { - - MineTweakerAPI.apply(new SetResearch(key, flag, SetType.SECONDARY)); - } + MineTweakerAPI.apply( + new AddResearch( + new ResearchItem( + key, + tab, + ThaumcraftHelper.parseAspects(aspects), + x, + y, + difficulty, + toStack(item)), + InputHelper.toStacks(triggers), + entTriggers, + ThaumcraftHelper.parseAspects(aspectsTrigger))); + } - @ZenMethod - public static void setVirtual(String key, boolean flag) { - - MineTweakerAPI.apply(new SetResearch(key, flag, SetType.VIRTUAL)); - } + @ZenMethod + public static void addPage(String key, String unlocalized) { - @ZenMethod - public static void setAutoUnlock(String key, boolean flag) { - - MineTweakerAPI.apply(new SetResearch(key, flag, SetType.AUTO)); - } + MineTweakerAPI.apply(new AddPage(key, PageType.TEXT, unlocalized)); + } - @ZenMethod - public static void setConcealed(String key, boolean flag) { - - MineTweakerAPI.apply(new SetResearch(key, flag, SetType.CONCEAL)); - } + @ZenMethod + public static void addCraftingPage(String key, IItemStack item) { - @ZenMethod - public static void setHidden(String key, boolean flag) { - MineTweakerAPI.apply(new SetResearch(key, flag, SetType.HIDDEN)); - } + MineTweakerAPI.apply(new AddPage(key, PageType.NORMAL_CRAFTING, toStack(item))); + } - @ZenMethod - public static void setAspects(String key, String aspects) { - - MineTweakerAPI.apply(new SetAspects(key, ThaumcraftHelper.parseAspects(aspects))); - } + @ZenMethod + public static void addCruciblePage(String key, IItemStack item) { - @ZenMethod - public static void setComplexity(String key, int complexity) { - - MineTweakerAPI.apply(new Difficulty(key, complexity)); - } + MineTweakerAPI.apply(new AddPage(key, PageType.CRUCIBLE_CRAFTING, toStack(item))); + } - @ZenMethod - public static void refreshResearchRecipe(String key) { - - MineTweakerAPI.apply(new RefreshResearch(key)); - } + @ZenMethod + public static void addArcanePage(String key, IItemStack item) { - @ZenMethod - public static void moveResearch(String key, String destination, int x, int y) { - - MineTweakerAPI.apply(new MoveResearch(key, destination, x, y)); - } + MineTweakerAPI.apply(new AddPage(key, PageType.ARCANE_CRAFTING, toStack(item))); + } - @ZenMethod - public static boolean hasResearched(IPlayer player, String key) { + @ZenMethod + public static void addInfusionPage(String key, IItemStack item) { - return ThaumcraftApiHelper.isResearchComplete(player.getName(), key); - } + MineTweakerAPI.apply(new AddPage(key, PageType.INFUSION_CRAFTING, toStack(item))); + } - public enum SetType { - AUTO, ROUND, SPIKE, SECONDARY, STUB, VIRTUAL, CONCEAL, HIDDEN - } + @ZenMethod + public static void addEnchantmentPage(String key, int i) { + + MineTweakerAPI.apply(new AddPage(key, PageType.INFUSION_ENCHANTMENT, Enchantment.enchantmentsList[i])); + } + + @ZenMethod + public static void clearPages(String key) { + + MineTweakerAPI.apply(new ClearPages(key)); + } + + @ZenMethod + public static void addPrereq(String key, String req, @Optional boolean hidden) { + + MineTweakerAPI.apply(new AddPrereq(key, req, hidden)); + } + + @ZenMethod + public static void clearPrereqs(String key) { + + MineTweakerAPI.apply(new ClearPrereqs(key)); + } + + @ZenMethod + public static void addSibling(String key, String sibling) { + + MineTweakerAPI.apply(new AddSibling(key, sibling)); + } + + @ZenMethod + public static void clearSiblings(String key) { + + MineTweakerAPI.apply(new ClearSiblings(key)); + } + + @ZenMethod + public static void setRound(String key, boolean flag) { + + MineTweakerAPI.apply(new SetResearch(key, flag, SetType.ROUND)); + } + + @ZenMethod + public static void setSpikey(String key, boolean flag) { + + MineTweakerAPI.apply(new SetResearch(key, flag, SetType.SPIKE)); + } + + @ZenMethod + public static void setStub(String key, boolean flag) { + + MineTweakerAPI.apply(new SetResearch(key, flag, SetType.STUB)); + } + + @ZenMethod + public static void setSecondary(String key, boolean flag) { + + MineTweakerAPI.apply(new SetResearch(key, flag, SetType.SECONDARY)); + } + + @ZenMethod + public static void setVirtual(String key, boolean flag) { + + MineTweakerAPI.apply(new SetResearch(key, flag, SetType.VIRTUAL)); + } + + @ZenMethod + public static void setAutoUnlock(String key, boolean flag) { + + MineTweakerAPI.apply(new SetResearch(key, flag, SetType.AUTO)); + } + + @ZenMethod + public static void setConcealed(String key, boolean flag) { + + MineTweakerAPI.apply(new SetResearch(key, flag, SetType.CONCEAL)); + } + + @ZenMethod + public static void setHidden(String key, boolean flag) { + MineTweakerAPI.apply(new SetResearch(key, flag, SetType.HIDDEN)); + } + + @ZenMethod + public static void setAspects(String key, String aspects) { + + MineTweakerAPI.apply(new SetAspects(key, ThaumcraftHelper.parseAspects(aspects))); + } + + @ZenMethod + public static void setComplexity(String key, int complexity) { + + MineTweakerAPI.apply(new Difficulty(key, complexity)); + } + + @ZenMethod + public static void refreshResearchRecipe(String key) { + + MineTweakerAPI.apply(new RefreshResearch(key)); + } + + @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 enum SetType { + AUTO, + ROUND, + SPIKE, + SECONDARY, + STUB, + VIRTUAL, + CONCEAL, + HIDDEN + } } diff --git a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Warp.java b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Warp.java index fb82247..0f90368 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Warp.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Warp.java @@ -10,7 +10,9 @@ import minetweaker.IUndoableAction; import minetweaker.MineTweakerAPI; import minetweaker.api.item.IItemStack; import modtweaker2.mods.thaumcraft.ThaumcraftHelper; + import net.minecraft.item.ItemStack; + import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; import thaumcraft.api.ThaumcraftApi; @@ -18,214 +20,199 @@ 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) { + 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) { + MineTweakerAPI.apply(new Add(toStack(stack), warp)); + } - private static class Add implements IUndoableAction { - Object target; - int warp; + private static class Add implements IUndoableAction { - public Add(Object targ, int amount) { - target = targ; - warp = amount; - } + Object target; + int warp; - public void apply() { - if (target instanceof String) - ThaumcraftApi.addWarpToResearch((String) target, warp); - else if (target instanceof ItemStack) - ThaumcraftApi.addWarpToItem((ItemStack) target, warp); - } + public Add(Object targ, int amount) { + target = targ; + warp = amount; + } - public boolean canUndo() { - return ThaumcraftApi.getWarp(target) > 0; - } + public void apply() { + if (target instanceof String) ThaumcraftApi.addWarpToResearch((String) target, warp); + else if (target instanceof ItemStack) ThaumcraftApi.addWarpToItem((ItemStack) target, warp); + } - 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 boolean canUndo() { + return ThaumcraftApi.getWarp(target) > 0; + } - 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 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 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 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 Object getOverrideKey() { - return null; - } + 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; + } - // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + } - @ZenMethod - public static void removeFromResearch(String key) { - MineTweakerAPI.apply(new Remove(key)); - } + // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - @ZenMethod - public static void removeFromItem(IItemStack stack) { - MineTweakerAPI.apply(new Remove(toStack(stack))); - } + @ZenMethod + public static void removeFromResearch(String key) { + MineTweakerAPI.apply(new Remove(key)); + } - @ZenMethod - public static void removeAll() { - MineTweakerAPI.apply(new MassRemove(RemoveType.BOTH)); - } + @ZenMethod + public static void removeFromItem(IItemStack stack) { + MineTweakerAPI.apply(new Remove(toStack(stack))); + } - @ZenMethod - public static void removeAllResearch() { - MineTweakerAPI.apply(new MassRemove(RemoveType.RESEARCH)); - } + @ZenMethod + public static void removeAll() { + MineTweakerAPI.apply(new MassRemove(RemoveType.BOTH)); + } - @ZenMethod - public static void removeAllItems() { - MineTweakerAPI.apply(new MassRemove(RemoveType.ITEMS)); - } + @ZenMethod + public static void removeAllResearch() { + MineTweakerAPI.apply(new MassRemove(RemoveType.RESEARCH)); + } - private static class Remove implements IUndoableAction { - Object target; - int warp; + @ZenMethod + public static void removeAllItems() { + MineTweakerAPI.apply(new MassRemove(RemoveType.ITEMS)); + } - public Remove(Object targ) { - target = targ; - } + private static class Remove implements IUndoableAction { - 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())); - } + Object target; + int warp; - public boolean canUndo() { - return warp > 0; - } + public Remove(Object targ) { + target = targ; + } - 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 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 undo() { - if (target instanceof String) - ThaumcraftApi.addWarpToResearch((String) target, warp); - else if (target instanceof ItemStack) - ThaumcraftApi.addWarpToItem((ItemStack) target, warp); - } + public boolean canUndo() { + return warp > 0; + } - 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 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 Object getOverrideKey() { - return null; - } + 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 static enum RemoveType { - RESEARCH, ITEMS, BOTH - } + public Object getOverrideKey() { + return null; + } - private static class MassRemove implements IUndoableAction { - HashMap oldMap = new HashMap(); - RemoveType type; + } - public MassRemove(RemoveType typ) { - type = typ; - } + public static enum RemoveType { + RESEARCH, + ITEMS, + BOTH + } - 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); - } - } - } + private static class MassRemove implements IUndoableAction { - public boolean canUndo() { - return oldMap.size() > 0; - } + HashMap oldMap = new HashMap(); + RemoveType type; - 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 MassRemove(RemoveType typ) { + type = typ; + } - public void undo() { - for (Object key : oldMap.keySet()) { - ThaumcraftHelper.warpList.put(key, oldMap.get(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 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 boolean canUndo() { + return oldMap.size() > 0; + } - public Object getOverrideKey() { - return null; - } + 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 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; + } + + } } diff --git a/src/main/java/modtweaker2/mods/thaumcraft/recipe/MTInfusionRecipe.java b/src/main/java/modtweaker2/mods/thaumcraft/recipe/MTInfusionRecipe.java index f617085..2c2a74d 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/recipe/MTInfusionRecipe.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/recipe/MTInfusionRecipe.java @@ -6,15 +6,18 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.oredict.OreDictionary; + import thaumcraft.api.ThaumcraftApiHelper; import thaumcraft.api.aspects.AspectList; import thaumcraft.api.crafting.InfusionRecipe; public class MTInfusionRecipe extends InfusionRecipe { + private final boolean fuzzyCentre; private final boolean[] fuzzyRecipe; - public MTInfusionRecipe(String research, Object output, int inst, AspectList aspects2, ItemStack input, ItemStack[] recipe, boolean fuzzyCentre, boolean[] fuzzyRecipe) { + public MTInfusionRecipe(String research, Object output, int inst, AspectList aspects2, ItemStack input, + ItemStack[] recipe, boolean fuzzyCentre, boolean[] fuzzyRecipe) { super(research, output, inst, aspects2, input, recipe); this.fuzzyCentre = fuzzyCentre; this.fuzzyRecipe = fuzzyRecipe; diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/AddPage.java b/src/main/java/modtweaker2/mods/thaumcraft/research/AddPage.java index 2faaaf2..0977c51 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/AddPage.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/research/AddPage.java @@ -1,12 +1,16 @@ package modtweaker2.mods.thaumcraft.research; import static modtweaker2.helpers.StackHelper.areEqual; +import static modtweaker2.mods.thaumcraft.ThaumcraftHelper.getResearchSafe; + import minetweaker.IUndoableAction; import modtweaker2.mods.thaumcraft.ThaumcraftHelper; + import net.minecraft.enchantment.Enchantment; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.IRecipe; + import thaumcraft.api.ThaumcraftApi; import thaumcraft.api.crafting.CrucibleRecipe; import thaumcraft.api.crafting.IArcaneRecipe; @@ -16,9 +20,9 @@ import thaumcraft.api.research.ResearchCategories; import thaumcraft.api.research.ResearchItem; import thaumcraft.api.research.ResearchPage; import thaumcraft.api.research.ResearchPage.PageType; -import static modtweaker2.mods.thaumcraft.ThaumcraftHelper.getResearchSafe; public class AddPage implements IUndoableAction { + String key; String tab; ResearchPage page; @@ -72,7 +76,8 @@ public class AddPage implements IUndoableAction { for (Object craft : ThaumcraftApi.getCraftingRecipes()) { if (craft instanceof InfusionRecipe) { InfusionRecipe theCraft = (InfusionRecipe) craft; - if (theCraft.getRecipeOutput() != null && theCraft.getRecipeOutput() instanceof ItemStack && areEqual(((ItemStack) (theCraft.getRecipeOutput())), target)) { + if (theCraft.getRecipeOutput() != null && theCraft.getRecipeOutput() instanceof ItemStack + && areEqual(((ItemStack) (theCraft.getRecipeOutput())), target)) { page = new ResearchPage(theCraft); break; } @@ -113,7 +118,7 @@ public class AddPage implements IUndoableAction { @Override public void undo() { final ResearchItem research = getResearchSafe(tab, key); - if(research == null) { + if (research == null) { return; } @@ -130,4 +135,4 @@ public class AddPage implements IUndoableAction { return null; } -} \ No newline at end of file +} diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/AddPrereq.java b/src/main/java/modtweaker2/mods/thaumcraft/research/AddPrereq.java index 76c39b9..3d4c79f 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/AddPrereq.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/research/AddPrereq.java @@ -1,13 +1,14 @@ package modtweaker2.mods.thaumcraft.research; +import static modtweaker2.mods.thaumcraft.ThaumcraftHelper.getResearchSafe; + import minetweaker.IUndoableAction; import modtweaker2.mods.thaumcraft.ThaumcraftHelper; import thaumcraft.api.research.ResearchCategories; import thaumcraft.api.research.ResearchItem; -import static modtweaker2.mods.thaumcraft.ThaumcraftHelper.getResearchSafe; - public class AddPrereq implements IUndoableAction { + String key; String tab; String prereq; @@ -57,10 +58,10 @@ public class AddPrereq implements IUndoableAction { @Override public void undo() { final ResearchItem research = getResearchSafe(tab, key); - if(research == null) { + if (research == null) { return; } - + if (!hidden) research.setParents(oldPrereqs); else research.setParentsHidden(oldPrereqs); } diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/AddResearch.java b/src/main/java/modtweaker2/mods/thaumcraft/research/AddResearch.java index 3f29edd..675c4bd 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/AddResearch.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/research/AddResearch.java @@ -1,71 +1,71 @@ package modtweaker2.mods.thaumcraft.research; -import net.minecraft.item.ItemStack; import minetweaker.IUndoableAction; -import thaumcraft.api.aspects.Aspect; + +import net.minecraft.item.ItemStack; + import thaumcraft.api.aspects.AspectList; import thaumcraft.api.research.ResearchCategories; import thaumcraft.api.research.ResearchItem; public class AddResearch implements IUndoableAction { - String key; - String tab; - ResearchItem research; - ResearchItem oldResearch; - ItemStack[] itemTriggers; - String[] entityTriggers; - AspectList aspectTriggers; - public AddResearch(ResearchItem res, ItemStack[] itemTriggers, String[] entityTriggers, AspectList aspectTriggers) { - research = res; - tab = research.category; - key = research.key; - this.itemTriggers = itemTriggers; - this.entityTriggers = entityTriggers; - this.aspectTriggers = aspectTriggers; - } + String key; + String tab; + ResearchItem research; + ResearchItem oldResearch; + ItemStack[] itemTriggers; + String[] entityTriggers; + AspectList aspectTriggers; - @Override - public void apply() { - oldResearch = ResearchCategories.getResearch(research.key); - if (itemTriggers != null) { - research = research.setItemTriggers(itemTriggers); - } - if (entityTriggers != null) { - research = research.setEntityTriggers(entityTriggers); - } - if (aspectTriggers != null) { - research = research.setAspectTriggers(aspectTriggers.getAspects()); - } - research.registerResearchItem(); - } + public AddResearch(ResearchItem res, ItemStack[] itemTriggers, String[] entityTriggers, AspectList aspectTriggers) { + research = res; + tab = research.category; + key = research.key; + this.itemTriggers = itemTriggers; + this.entityTriggers = entityTriggers; + this.aspectTriggers = aspectTriggers; + } - @Override - public String describe() { - return "Registering Research: " + key; - } + @Override + public void apply() { + oldResearch = ResearchCategories.getResearch(research.key); + if (itemTriggers != null) { + research = research.setItemTriggers(itemTriggers); + } + if (entityTriggers != null) { + research = research.setEntityTriggers(entityTriggers); + } + if (aspectTriggers != null) { + research = research.setAspectTriggers(aspectTriggers.getAspects()); + } + research.registerResearchItem(); + } - @Override - public boolean canUndo() { - return tab != null && key != null; - } + @Override + public String describe() { + return "Registering Research: " + key; + } - @Override - public void undo() { - if (oldResearch == null) - ResearchCategories.researchCategories.get(tab).research.remove(key); - else - ResearchCategories.researchCategories.get(tab).research.put(key, oldResearch); - } + @Override + public boolean canUndo() { + return tab != null && key != null; + } - @Override - public String describeUndo() { - return "Removing Research: " + key; - } + @Override + public void undo() { + if (oldResearch == null) ResearchCategories.researchCategories.get(tab).research.remove(key); + else ResearchCategories.researchCategories.get(tab).research.put(key, oldResearch); + } - @Override - public String getOverrideKey() { - return null; - } + @Override + public String describeUndo() { + return "Removing Research: " + key; + } -} \ No newline at end of file + @Override + public String getOverrideKey() { + return null; + } + +} diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/AddSibling.java b/src/main/java/modtweaker2/mods/thaumcraft/research/AddSibling.java index 719eb6a..115f77e 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/AddSibling.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/research/AddSibling.java @@ -1,13 +1,14 @@ package modtweaker2.mods.thaumcraft.research; +import static modtweaker2.mods.thaumcraft.ThaumcraftHelper.getResearchSafe; + import minetweaker.IUndoableAction; import modtweaker2.mods.thaumcraft.ThaumcraftHelper; import thaumcraft.api.research.ResearchCategories; import thaumcraft.api.research.ResearchItem; -import static modtweaker2.mods.thaumcraft.ThaumcraftHelper.getResearchSafe; - public class AddSibling implements IUndoableAction { + String key; String tab; String sibling; @@ -44,7 +45,7 @@ public class AddSibling implements IUndoableAction { @Override public void undo() { final ResearchItem research = getResearchSafe(tab, key); - if(research == null) { + if (research == null) { return; } @@ -61,4 +62,4 @@ public class AddSibling implements IUndoableAction { return null; } -} \ No newline at end of file +} diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/AddTab.java b/src/main/java/modtweaker2/mods/thaumcraft/research/AddTab.java index 83085a6..95cbf89 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/AddTab.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/research/AddTab.java @@ -1,10 +1,13 @@ package modtweaker2.mods.thaumcraft.research; import minetweaker.IUndoableAction; + import net.minecraft.util.ResourceLocation; + import thaumcraft.api.research.ResearchCategories; public class AddTab implements IUndoableAction { + String tab; ResourceLocation icon; ResourceLocation background; @@ -45,4 +48,4 @@ public class AddTab implements IUndoableAction { return null; } -} \ No newline at end of file +} diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/ClearPages.java b/src/main/java/modtweaker2/mods/thaumcraft/research/ClearPages.java index 8f012c5..0292ce4 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/ClearPages.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/research/ClearPages.java @@ -1,14 +1,15 @@ package modtweaker2.mods.thaumcraft.research; +import static modtweaker2.mods.thaumcraft.ThaumcraftHelper.getResearchSafe; + import minetweaker.IUndoableAction; import modtweaker2.mods.thaumcraft.ThaumcraftHelper; import thaumcraft.api.research.ResearchCategories; import thaumcraft.api.research.ResearchItem; import thaumcraft.api.research.ResearchPage; -import static modtweaker2.mods.thaumcraft.ThaumcraftHelper.getResearchSafe; - public class ClearPages implements IUndoableAction { + String key; String tab; ResearchPage[] oldPages; @@ -37,7 +38,7 @@ public class ClearPages implements IUndoableAction { @Override public void undo() { final ResearchItem research = getResearchSafe(tab, key); - if(research == null) { + if (research == null) { return; } @@ -54,4 +55,4 @@ public class ClearPages implements IUndoableAction { return null; } -} \ No newline at end of file +} diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/ClearPrereqs.java b/src/main/java/modtweaker2/mods/thaumcraft/research/ClearPrereqs.java index 012f026..f9e10e0 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/ClearPrereqs.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/research/ClearPrereqs.java @@ -1,13 +1,14 @@ package modtweaker2.mods.thaumcraft.research; +import static modtweaker2.mods.thaumcraft.ThaumcraftHelper.getResearchSafe; + import minetweaker.IUndoableAction; import modtweaker2.mods.thaumcraft.ThaumcraftHelper; import thaumcraft.api.research.ResearchCategories; import thaumcraft.api.research.ResearchItem; -import static modtweaker2.mods.thaumcraft.ThaumcraftHelper.getResearchSafe; - public class ClearPrereqs implements IUndoableAction { + String key; String tab; String[] prereqs; @@ -39,7 +40,7 @@ public class ClearPrereqs implements IUndoableAction { @Override public void undo() { final ResearchItem research = getResearchSafe(tab, key); - if(research == null) { + if (research == null) { return; } @@ -57,4 +58,4 @@ public class ClearPrereqs implements IUndoableAction { return null; } -} \ No newline at end of file +} diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/ClearSiblings.java b/src/main/java/modtweaker2/mods/thaumcraft/research/ClearSiblings.java index c5a0371..2e2e8cf 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/ClearSiblings.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/research/ClearSiblings.java @@ -1,13 +1,14 @@ package modtweaker2.mods.thaumcraft.research; +import static modtweaker2.mods.thaumcraft.ThaumcraftHelper.getResearchSafe; + import minetweaker.IUndoableAction; import modtweaker2.mods.thaumcraft.ThaumcraftHelper; import thaumcraft.api.research.ResearchCategories; import thaumcraft.api.research.ResearchItem; -import static modtweaker2.mods.thaumcraft.ThaumcraftHelper.getResearchSafe; - public class ClearSiblings implements IUndoableAction { + String key; String tab; String[] siblings; @@ -36,7 +37,7 @@ public class ClearSiblings implements IUndoableAction { @Override public void undo() { final ResearchItem research = getResearchSafe(tab, key); - if(research == null) { + if (research == null) { return; } @@ -53,4 +54,4 @@ public class ClearSiblings implements IUndoableAction { return null; } -} \ No newline at end of file +} diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/Difficulty.java b/src/main/java/modtweaker2/mods/thaumcraft/research/Difficulty.java index 8ff2dbc..bc0bbdf 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/Difficulty.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/research/Difficulty.java @@ -1,22 +1,23 @@ package modtweaker2.mods.thaumcraft.research; +import static modtweaker2.mods.thaumcraft.ThaumcraftHelper.getResearchSafe; + +import java.lang.reflect.Field; + import minetweaker.IUndoableAction; import modtweaker2.mods.thaumcraft.ThaumcraftHelper; import thaumcraft.api.research.ResearchCategories; import thaumcraft.api.research.ResearchItem; -import java.lang.reflect.Field; - -import static modtweaker2.mods.thaumcraft.ThaumcraftHelper.getResearchSafe; - public class Difficulty implements IUndoableAction { + String key; String tab; int difficulty; int oldDif; boolean applied = false; final static Field complexity; - + static { Field complexity1; try { @@ -27,8 +28,6 @@ public class Difficulty implements IUndoableAction { } complexity = complexity1; } - - public Difficulty(String res, int dif) { key = res; @@ -64,7 +63,7 @@ public class Difficulty implements IUndoableAction { public void undo() { try { final ResearchItem research = getResearchSafe(tab, key); - if(research == null || complexity == null) { + if (research == null || complexity == null) { return; } complexity.setAccessible(true); @@ -84,4 +83,4 @@ public class Difficulty implements IUndoableAction { return null; } -} \ No newline at end of file +} diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/MoveResearch.java b/src/main/java/modtweaker2/mods/thaumcraft/research/MoveResearch.java index 05578c5..f71ae74 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/MoveResearch.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/research/MoveResearch.java @@ -8,6 +8,7 @@ import thaumcraft.api.research.ResearchCategories; import thaumcraft.api.research.ResearchItem; public class MoveResearch implements IUndoableAction { + String key; String newTab; int x; @@ -40,7 +41,8 @@ public class MoveResearch implements IUndoableAction { } } - private void moveResearchItem(ResearchItem research, int x, int y, String newTab, String tab) throws ReflectiveOperationException { + private void moveResearchItem(ResearchItem research, int x, int y, String newTab, String tab) + throws ReflectiveOperationException { Class res = Class.forName("thaumcraft.api.research.ResearchItem"); Field ex = res.getField("displayColumn"); ex.setAccessible(true); @@ -86,4 +88,4 @@ public class MoveResearch implements IUndoableAction { return null; } -} \ No newline at end of file +} diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/OrphanResearch.java b/src/main/java/modtweaker2/mods/thaumcraft/research/OrphanResearch.java index b71f3ea..5ccf5f3 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/OrphanResearch.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/research/OrphanResearch.java @@ -9,12 +9,15 @@ import java.util.function.Function; import minetweaker.IUndoableAction; import modtweaker2.helpers.LogHelper; + import org.apache.commons.lang3.ArrayUtils; + import thaumcraft.api.research.ResearchCategories; import thaumcraft.api.research.ResearchCategoryList; import thaumcraft.api.research.ResearchItem; public class OrphanResearch implements IUndoableAction { + String key; private final Set children = new HashSet<>(); private final Set secretChildren = new HashSet<>(); @@ -35,13 +38,12 @@ public class OrphanResearch implements IUndoableAction { } } - private void add(Set set, Function function, BiConsumer consumer) { + private void add(Set set, Function function, + BiConsumer consumer) { for (String research : set) { ResearchItem researchItem = ResearchCategories.getResearch(research); - if (researchItem == null) - LogHelper.logWarning("Missing research: " + research); - else - consumer.accept(researchItem, ArrayUtils.add(function.apply(researchItem), key)); + if (researchItem == null) LogHelper.logWarning("Missing research: " + research); + else consumer.accept(researchItem, ArrayUtils.add(function.apply(researchItem), key)); } } @@ -85,4 +87,4 @@ public class OrphanResearch implements IUndoableAction { return null; } -} \ No newline at end of file +} diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/RefreshResearch.java b/src/main/java/modtweaker2/mods/thaumcraft/research/RefreshResearch.java index 251cad5..a6c6435 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/RefreshResearch.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/research/RefreshResearch.java @@ -1,11 +1,14 @@ package modtweaker2.mods.thaumcraft.research; import static modtweaker2.helpers.StackHelper.areEqual; + import minetweaker.IUndoableAction; import modtweaker2.mods.thaumcraft.ThaumcraftHelper; + import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.IRecipe; + import thaumcraft.api.ThaumcraftApi; import thaumcraft.api.crafting.CrucibleRecipe; import thaumcraft.api.crafting.IArcaneRecipe; @@ -15,6 +18,7 @@ import thaumcraft.api.research.ResearchItem; import thaumcraft.api.research.ResearchPage; public class RefreshResearch implements IUndoableAction { + String research; String tab; @@ -35,7 +39,8 @@ public class RefreshResearch implements IUndoableAction { for (Object craft : CraftingManager.getInstance().getRecipeList()) { if (craft instanceof IRecipe) { IRecipe theCraft = (IRecipe) craft; - if (theCraft.getRecipeOutput() != null && areEqual(theCraft.getRecipeOutput(), recipe.getRecipeOutput())) { + if (theCraft.getRecipeOutput() != null + && areEqual(theCraft.getRecipeOutput(), recipe.getRecipeOutput())) { pages[x] = new ResearchPage(theCraft); break; } @@ -46,7 +51,8 @@ public class RefreshResearch implements IUndoableAction { for (Object craft : ThaumcraftApi.getCraftingRecipes()) { if (craft instanceof IArcaneRecipe) { IArcaneRecipe theCraft = (IArcaneRecipe) craft; - if (theCraft.getRecipeOutput() != null && areEqual(theCraft.getRecipeOutput(), recipe.getRecipeOutput())) { + if (theCraft.getRecipeOutput() != null + && areEqual(theCraft.getRecipeOutput(), recipe.getRecipeOutput())) { pages[x] = new ResearchPage(theCraft); break; } @@ -57,7 +63,8 @@ public class RefreshResearch implements IUndoableAction { for (Object craft : ThaumcraftApi.getCraftingRecipes()) { if (craft instanceof CrucibleRecipe) { CrucibleRecipe theCraft = (CrucibleRecipe) craft; - if (theCraft.getRecipeOutput() != null && areEqual(theCraft.getRecipeOutput(), recipe.getRecipeOutput())) { + if (theCraft.getRecipeOutput() != null + && areEqual(theCraft.getRecipeOutput(), recipe.getRecipeOutput())) { pages[x] = new ResearchPage(theCraft); break; } @@ -69,7 +76,11 @@ public class RefreshResearch implements IUndoableAction { for (Object craft : ThaumcraftApi.getCraftingRecipes()) { if (craft instanceof InfusionRecipe) { InfusionRecipe theCraft = (InfusionRecipe) craft; - if (theCraft.getRecipeOutput() != null && theCraft.getRecipeOutput() instanceof ItemStack && areEqual(((ItemStack) theCraft.getRecipeOutput()), (ItemStack) recipe.getRecipeOutput())) { + if (theCraft.getRecipeOutput() != null + && theCraft.getRecipeOutput() instanceof ItemStack + && areEqual( + ((ItemStack) theCraft.getRecipeOutput()), + (ItemStack) recipe.getRecipeOutput())) { pages[x] = new ResearchPage(theCraft); break; } @@ -107,4 +118,4 @@ public class RefreshResearch implements IUndoableAction { return null; } -} \ No newline at end of file +} diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/RemoveResearch.java b/src/main/java/modtweaker2/mods/thaumcraft/research/RemoveResearch.java index 3eb114c..efed2db 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/RemoveResearch.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/research/RemoveResearch.java @@ -6,6 +6,7 @@ import thaumcraft.api.research.ResearchCategories; import thaumcraft.api.research.ResearchItem; public class RemoveResearch implements IUndoableAction { + String key; String tab; ResearchItem removed; @@ -48,4 +49,4 @@ public class RemoveResearch implements IUndoableAction { return null; } -} \ No newline at end of file +} diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/RemoveTab.java b/src/main/java/modtweaker2/mods/thaumcraft/research/RemoveTab.java index ded9eda..16d9015 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/RemoveTab.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/research/RemoveTab.java @@ -5,6 +5,7 @@ import thaumcraft.api.research.ResearchCategories; import thaumcraft.api.research.ResearchCategoryList; public class RemoveTab implements IUndoableAction { + String tab; ResearchCategoryList list; @@ -43,4 +44,4 @@ public class RemoveTab implements IUndoableAction { return null; } -} \ No newline at end of file +} diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/SetAspects.java b/src/main/java/modtweaker2/mods/thaumcraft/research/SetAspects.java index 5e38e84..f191601 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/SetAspects.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/research/SetAspects.java @@ -1,23 +1,24 @@ package modtweaker2.mods.thaumcraft.research; +import static modtweaker2.mods.thaumcraft.ThaumcraftHelper.getResearchSafe; + +import java.lang.reflect.Field; + import minetweaker.IUndoableAction; import modtweaker2.mods.thaumcraft.ThaumcraftHelper; import thaumcraft.api.aspects.AspectList; import thaumcraft.api.research.ResearchCategories; import thaumcraft.api.research.ResearchItem; -import java.lang.reflect.Field; - -import static modtweaker2.mods.thaumcraft.ThaumcraftHelper.getResearchSafe; - public class SetAspects implements IUndoableAction { + String key; String tab; AspectList oldList; AspectList list; boolean applied = false; final static Field tags; - + static { Field tags1; try { @@ -63,7 +64,7 @@ public class SetAspects implements IUndoableAction { public void undo() { try { final ResearchItem research = getResearchSafe(tab, key); - if(research == null || tags == null) { + if (research == null || tags == null) { return; } tags.setAccessible(true); @@ -83,4 +84,4 @@ public class SetAspects implements IUndoableAction { return null; } -} \ No newline at end of file +} diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/SetResearch.java b/src/main/java/modtweaker2/mods/thaumcraft/research/SetResearch.java index cff7d5c..937f64b 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/SetResearch.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/research/SetResearch.java @@ -1,16 +1,17 @@ package modtweaker2.mods.thaumcraft.research; +import static modtweaker2.mods.thaumcraft.ThaumcraftHelper.getResearchSafe; + +import java.lang.reflect.Field; + import minetweaker.IUndoableAction; import modtweaker2.mods.thaumcraft.ThaumcraftHelper; import modtweaker2.mods.thaumcraft.handlers.Research.SetType; import thaumcraft.api.research.ResearchCategories; import thaumcraft.api.research.ResearchItem; -import java.lang.reflect.Field; - -import static modtweaker2.mods.thaumcraft.ThaumcraftHelper.getResearchSafe; - public class SetResearch implements IUndoableAction { + String key; String tab; SetType type; @@ -40,14 +41,22 @@ public class SetResearch implements IUndoableAction { } else { try { Field target = null; - if (type == SetType.AUTO) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isAutoUnlock"); - else if (type == SetType.ROUND) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isRound"); - else if (type == SetType.SPIKE) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isSpecial"); - else if (type == SetType.SECONDARY) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isSecondary"); - else if (type == SetType.STUB) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isStub"); - else if (type == SetType.VIRTUAL) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isVirtual"); - else if (type == SetType.CONCEAL) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isConcealed"); - else if (type == SetType.HIDDEN) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isHidden"); + if (type == SetType.AUTO) + target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isAutoUnlock"); + else if (type == SetType.ROUND) + target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isRound"); + else if (type == SetType.SPIKE) + target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isSpecial"); + else if (type == SetType.SECONDARY) + target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isSecondary"); + else if (type == SetType.STUB) + target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isStub"); + else if (type == SetType.VIRTUAL) + target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isVirtual"); + else if (type == SetType.CONCEAL) + target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isConcealed"); + else if (type == SetType.HIDDEN) + target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isHidden"); if (target != null) { target.setAccessible(true); @@ -73,7 +82,7 @@ public class SetResearch implements IUndoableAction { @Override public void undo() { final ResearchItem research = getResearchSafe(tab, key); - if(research == null) { + if (research == null) { return; } @@ -89,14 +98,22 @@ public class SetResearch implements IUndoableAction { } else { try { Field target = null; - if (type == SetType.AUTO) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isAutoUnlock"); - else if (type == SetType.ROUND) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isRound"); - else if (type == SetType.SPIKE) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isSpecial"); - else if (type == SetType.SECONDARY) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isSecondary"); - else if (type == SetType.STUB) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isStub"); - else if (type == SetType.VIRTUAL) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isVirtual"); - else if (type == SetType.CONCEAL) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isConcealed"); - else if (type == SetType.HIDDEN) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isHidden"); + if (type == SetType.AUTO) + target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isAutoUnlock"); + else if (type == SetType.ROUND) + target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isRound"); + else if (type == SetType.SPIKE) + target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isSpecial"); + else if (type == SetType.SECONDARY) + target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isSecondary"); + else if (type == SetType.STUB) + target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isStub"); + else if (type == SetType.VIRTUAL) + target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isVirtual"); + else if (type == SetType.CONCEAL) + target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isConcealed"); + else if (type == SetType.HIDDEN) + target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isHidden"); if (target != null) { target.setAccessible(true); @@ -118,4 +135,4 @@ public class SetResearch implements IUndoableAction { return null; } -} \ No newline at end of file +} diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/commands/ResearchLogger.java b/src/main/java/modtweaker2/mods/thaumcraft/research/commands/ResearchLogger.java index d19b52c..cabfbbc 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/commands/ResearchLogger.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/research/commands/ResearchLogger.java @@ -2,12 +2,14 @@ package modtweaker2.mods.thaumcraft.research.commands; import static modtweaker2.helpers.LogHelper.log; import static modtweaker2.helpers.LogHelper.logPrinted; + import minetweaker.MineTweakerAPI; import minetweaker.api.player.IPlayer; import minetweaker.api.server.ICommandFunction; import thaumcraft.api.research.ResearchCategories; public class ResearchLogger implements ICommandFunction { + @Override public void execute(String[] arguments, IPlayer player) { if (arguments == null || arguments.length <= 0 || arguments[0] == null) { diff --git a/src/main/java/modtweaker2/mods/thermalexpansion/ThermalExpansion.java b/src/main/java/modtweaker2/mods/thermalexpansion/ThermalExpansion.java index fc1f304..b96adc8 100644 --- a/src/main/java/modtweaker2/mods/thermalexpansion/ThermalExpansion.java +++ b/src/main/java/modtweaker2/mods/thermalexpansion/ThermalExpansion.java @@ -11,13 +11,13 @@ import modtweaker2.mods.thermalexpansion.handlers.Transposer; public class ThermalExpansion { - public ThermalExpansion(){ - MineTweakerAPI.registerClass(Crucible.class); - MineTweakerAPI.registerClass(Furnace.class); - MineTweakerAPI.registerClass(Insolator.class); - MineTweakerAPI.registerClass(Pulverizer.class); - MineTweakerAPI.registerClass(Sawmill.class); - MineTweakerAPI.registerClass(Smelter.class); - MineTweakerAPI.registerClass(Transposer.class); - } + public ThermalExpansion() { + MineTweakerAPI.registerClass(Crucible.class); + MineTweakerAPI.registerClass(Furnace.class); + MineTweakerAPI.registerClass(Insolator.class); + MineTweakerAPI.registerClass(Pulverizer.class); + MineTweakerAPI.registerClass(Sawmill.class); + MineTweakerAPI.registerClass(Smelter.class); + MineTweakerAPI.registerClass(Transposer.class); + } } diff --git a/src/main/java/modtweaker2/mods/thermalexpansion/ThermalHelper.java b/src/main/java/modtweaker2/mods/thermalexpansion/ThermalHelper.java index 8b4b867..219bfd0 100644 --- a/src/main/java/modtweaker2/mods/thermalexpansion/ThermalHelper.java +++ b/src/main/java/modtweaker2/mods/thermalexpansion/ThermalHelper.java @@ -6,8 +6,10 @@ import static modtweaker2.helpers.StackHelper.areEqualOrNull; import java.lang.reflect.Constructor; import modtweaker2.helpers.LogHelper; + import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; + import cofh.thermalexpansion.util.crafting.CrucibleManager.RecipeCrucible; import cofh.thermalexpansion.util.crafting.FurnaceManager.RecipeFurnace; import cofh.thermalexpansion.util.crafting.InsolatorManager.RecipeInsolator; @@ -17,6 +19,7 @@ import cofh.thermalexpansion.util.crafting.SmelterManager.RecipeSmelter; import cofh.thermalexpansion.util.crafting.TransposerManager.RecipeTransposer; public class ThermalHelper { + public static Constructor crucibleRecipe; public static Constructor furanceRecipe; public static Constructor insolatorRecipe; @@ -24,236 +27,270 @@ public class ThermalHelper { public static Constructor sawmillRecipe; public static Constructor smelterRecipe; public static Constructor transposerRecipe; - + static { - try { - crucibleRecipe = getConstructor(RecipeCrucible.class, ItemStack.class, FluidStack.class, int.class); - furanceRecipe = getConstructor(RecipeFurnace.class, ItemStack.class, ItemStack.class, int.class); - insolatorRecipe = getConstructor(RecipeInsolator.class, ItemStack.class, ItemStack.class, ItemStack.class, ItemStack.class, int.class, int.class); - pulverizerRecipe = getConstructor(RecipePulverizer.class, ItemStack.class, ItemStack.class, ItemStack.class, int.class, int.class); - sawmillRecipe = getConstructor(RecipeSawmill.class, ItemStack.class, ItemStack.class, ItemStack.class, int.class, int.class); - smelterRecipe = getConstructor(RecipeSmelter.class, ItemStack.class, ItemStack.class, ItemStack.class, ItemStack.class, int.class, int.class); - transposerRecipe = getConstructor(RecipeTransposer.class, ItemStack.class, ItemStack.class, FluidStack.class, int.class, int.class); - } catch (Exception e) { LogHelper.logError("Exception getting constructor for Thermal Expansion recipes!", e); } + try { + crucibleRecipe = getConstructor(RecipeCrucible.class, ItemStack.class, FluidStack.class, int.class); + furanceRecipe = getConstructor(RecipeFurnace.class, ItemStack.class, ItemStack.class, int.class); + insolatorRecipe = getConstructor( + RecipeInsolator.class, + ItemStack.class, + ItemStack.class, + ItemStack.class, + ItemStack.class, + int.class, + int.class); + pulverizerRecipe = getConstructor( + RecipePulverizer.class, + ItemStack.class, + ItemStack.class, + ItemStack.class, + int.class, + int.class); + sawmillRecipe = getConstructor( + RecipeSawmill.class, + ItemStack.class, + ItemStack.class, + ItemStack.class, + int.class, + int.class); + smelterRecipe = getConstructor( + RecipeSmelter.class, + ItemStack.class, + ItemStack.class, + ItemStack.class, + ItemStack.class, + int.class, + int.class); + transposerRecipe = getConstructor( + RecipeTransposer.class, + ItemStack.class, + ItemStack.class, + FluidStack.class, + int.class, + int.class); + } catch (Exception e) { + LogHelper.logError("Exception getting constructor for Thermal Expansion recipes!", e); + } } public static boolean equals(RecipeCrucible r1, RecipeCrucible r2) { - if(r1 == r2) { + if (r1 == r2) { return true; } - - if(r1 == null || r2 == null) { + + if (r1 == null || r2 == null) { return false; } - - if(!areEqualOrNull(r1.getInput(), r2.getInput())) { + + if (!areEqualOrNull(r1.getInput(), r2.getInput())) { return false; } - - if(r1.getEnergy() != r2.getEnergy()) { + + if (r1.getEnergy() != r2.getEnergy()) { return false; } - - if(!areEqualOrNull(r1.getOutput(), r2.getOutput())) { + + if (!areEqualOrNull(r1.getOutput(), r2.getOutput())) { return false; } return true; } - + public static boolean equals(RecipeFurnace r1, RecipeFurnace r2) { - if(r1 == r2) { + if (r1 == r2) { return true; } - - if(r1 == null || r2 == null) { + + if (r1 == null || r2 == null) { return false; } - - if(!areEqualOrNull(r1.getInput(), r2.getInput())) { - return false; - } - - if(r1.getEnergy() != r2.getEnergy()) { + + if (!areEqualOrNull(r1.getInput(), r2.getInput())) { return false; } - - if(!areEqualOrNull(r1.getOutput(), r2.getOutput())) { + + if (r1.getEnergy() != r2.getEnergy()) { return false; } - + + if (!areEqualOrNull(r1.getOutput(), r2.getOutput())) { + return false; + } + return true; } - + public static boolean equals(RecipePulverizer r1, RecipePulverizer r2) { - if(r1 == r2) { + if (r1 == r2) { return true; } - - if(r1 == null || r2 == null) { + + if (r1 == null || r2 == null) { return false; } - - if(!areEqualOrNull(r1.getInput(), r2.getInput())) { - return false; - } - - if(r1.getEnergy() != r2.getEnergy()) { + + if (!areEqualOrNull(r1.getInput(), r2.getInput())) { return false; } - - if(!areEqualOrNull(r1.getPrimaryOutput(), r2.getPrimaryOutput())) { + + if (r1.getEnergy() != r2.getEnergy()) { return false; } - - if(!areEqualOrNull(r1.getSecondaryOutput(), r2.getSecondaryOutput())) { + + if (!areEqualOrNull(r1.getPrimaryOutput(), r2.getPrimaryOutput())) { return false; } - - if(r1.getSecondaryOutput() != null && r2.getSecondaryOutput() != null && - r1.getSecondaryOutputChance() != r2.getSecondaryOutputChance()) { + + if (!areEqualOrNull(r1.getSecondaryOutput(), r2.getSecondaryOutput())) { return false; } - + + if (r1.getSecondaryOutput() != null && r2.getSecondaryOutput() != null + && r1.getSecondaryOutputChance() != r2.getSecondaryOutputChance()) { + return false; + } + return true; } - + public static boolean equals(RecipeSawmill r1, RecipeSawmill r2) { - if(r1 == r2) { + if (r1 == r2) { return true; } - - if(r1 == null || r2 == null) { + + if (r1 == null || r2 == null) { return false; } - - if(!areEqualOrNull(r1.getInput(), r2.getInput())) { - return false; - } - - if(r1.getEnergy() != r2.getEnergy()) { + + if (!areEqualOrNull(r1.getInput(), r2.getInput())) { return false; } - - if(!areEqualOrNull(r1.getPrimaryOutput(), r2.getPrimaryOutput())) { + + if (r1.getEnergy() != r2.getEnergy()) { return false; } - - if(!areEqualOrNull(r1.getSecondaryOutput(), r2.getSecondaryOutput())) { + + if (!areEqualOrNull(r1.getPrimaryOutput(), r2.getPrimaryOutput())) { return false; } - - if(r1.getSecondaryOutput() != null && r2.getSecondaryOutput() != null && - r1.getSecondaryOutputChance() != r2.getSecondaryOutputChance()) { + + if (!areEqualOrNull(r1.getSecondaryOutput(), r2.getSecondaryOutput())) { return false; } - + + if (r1.getSecondaryOutput() != null && r2.getSecondaryOutput() != null + && r1.getSecondaryOutputChance() != r2.getSecondaryOutputChance()) { + return false; + } + return true; } - + public static boolean equals(RecipeSmelter r1, RecipeSmelter r2) { - if(r1 == r2) { + if (r1 == r2) { return true; } - - if(r1 == null || r2 == null) { + + if (r1 == null || r2 == null) { return false; } - - if(!areEqualOrNull(r1.getPrimaryInput(), r2.getPrimaryInput())) { + + if (!areEqualOrNull(r1.getPrimaryInput(), r2.getPrimaryInput())) { return false; } - - if(!areEqualOrNull(r1.getSecondaryInput(), r2.getSecondaryInput())) { + + if (!areEqualOrNull(r1.getSecondaryInput(), r2.getSecondaryInput())) { return false; } - - if(r1.getEnergy() != r2.getEnergy()) { + + if (r1.getEnergy() != r2.getEnergy()) { return false; } - - if(!areEqualOrNull(r1.getPrimaryOutput(), r2.getPrimaryOutput())) { + + if (!areEqualOrNull(r1.getPrimaryOutput(), r2.getPrimaryOutput())) { return false; } - - if(!areEqualOrNull(r1.getSecondaryOutput(), r2.getSecondaryOutput())) { + + if (!areEqualOrNull(r1.getSecondaryOutput(), r2.getSecondaryOutput())) { return false; } - - if(r1.getSecondaryOutput() != null && r2.getSecondaryOutput() != null && - r1.getSecondaryOutputChance() != r2.getSecondaryOutputChance()) { + + if (r1.getSecondaryOutput() != null && r2.getSecondaryOutput() != null + && r1.getSecondaryOutputChance() != r2.getSecondaryOutputChance()) { return false; } - + return true; } - + public static boolean equals(RecipeInsolator r1, RecipeInsolator r2) { - if(r1 == r2) { + if (r1 == r2) { return true; } - - if(r1 == null || r2 == null) { + + if (r1 == null || r2 == null) { return false; } - - if(!areEqualOrNull(r1.getPrimaryInput(), r2.getPrimaryInput())) { + + if (!areEqualOrNull(r1.getPrimaryInput(), r2.getPrimaryInput())) { return false; } - - if(!areEqualOrNull(r1.getSecondaryInput(), r2.getSecondaryInput())) { + + if (!areEqualOrNull(r1.getSecondaryInput(), r2.getSecondaryInput())) { return false; } - - if(r1.getEnergy() != r2.getEnergy()) { + + if (r1.getEnergy() != r2.getEnergy()) { return false; } - - if(!areEqualOrNull(r1.getPrimaryOutput(), r2.getPrimaryOutput())) { + + if (!areEqualOrNull(r1.getPrimaryOutput(), r2.getPrimaryOutput())) { return false; } - - if(!areEqualOrNull(r1.getSecondaryOutput(), r2.getSecondaryOutput())) { + + if (!areEqualOrNull(r1.getSecondaryOutput(), r2.getSecondaryOutput())) { return false; } - - if(r1.getSecondaryOutput() != null && r2.getSecondaryOutput() != null && - r1.getSecondaryOutputChance() != r2.getSecondaryOutputChance()) { + + if (r1.getSecondaryOutput() != null && r2.getSecondaryOutput() != null + && r1.getSecondaryOutputChance() != r2.getSecondaryOutputChance()) { return false; } - + return true; } - + public static boolean equals(RecipeTransposer r1, RecipeTransposer r2) { - if(r1 == r2) { + if (r1 == r2) { return true; } - - if(r1 == null || r2 == null) { + + if (r1 == null || r2 == null) { return false; } - - if(!areEqualOrNull(r1.getInput(), r2.getInput())) { - return false; - } - - if(r1.getEnergy() != r2.getEnergy()) { + + if (!areEqualOrNull(r1.getInput(), r2.getInput())) { return false; } - - if(!areEqualOrNull(r1.getOutput(), r2.getOutput())) { + + if (r1.getEnergy() != r2.getEnergy()) { return false; } - - if(!areEqualOrNull(r1.getFluid(), r2.getFluid())) { + + if (!areEqualOrNull(r1.getOutput(), r2.getOutput())) { return false; } - - if(r1.getChance() != r2.getChance()) { + + if (!areEqualOrNull(r1.getFluid(), r2.getFluid())) { return false; } - + + if (r1.getChance() != r2.getChance()) { + return false; + } + return true; } } diff --git a/src/main/java/modtweaker2/mods/thermalexpansion/commands/ThermalExpansionLogger.java b/src/main/java/modtweaker2/mods/thermalexpansion/commands/ThermalExpansionLogger.java index 2e923ac..cccbfe3 100644 --- a/src/main/java/modtweaker2/mods/thermalexpansion/commands/ThermalExpansionLogger.java +++ b/src/main/java/modtweaker2/mods/thermalexpansion/commands/ThermalExpansionLogger.java @@ -26,8 +26,9 @@ import cofh.thermalexpansion.util.crafting.TransposerManager; import cofh.thermalexpansion.util.crafting.TransposerManager.RecipeTransposer; public class ThermalExpansionLogger implements ICommandFunction { + private static final List validArguments = new LinkedList(); - + static { validArguments.add("Crucible"); validArguments.add("Furnace"); @@ -37,131 +38,160 @@ public class ThermalExpansionLogger implements ICommandFunction { validArguments.add("Smelter"); validArguments.add("Transposer"); } - + @Override public void execute(String[] arguments, IPlayer player) { List args = StringHelper.toLowerCase(Arrays.asList(arguments)); - - if(!validArguments.containsAll(args)) { - if(player != null) { - player.sendChat(MineTweakerImplementationAPI.platform.getMessage("Invalid arguments for command. Valid arguments: " + StringHelper.join(validArguments, ", "))); + + if (!validArguments.containsAll(args)) { + if (player != null) { + player.sendChat( + MineTweakerImplementationAPI.platform.getMessage( + "Invalid arguments for command. Valid arguments: " + + StringHelper.join(validArguments, ", "))); } } else { - if(args.isEmpty() || args.contains("Crucible")) { - for(RecipeCrucible recipe : CrucibleManager.getRecipeList()) { - MineTweakerAPI.logCommand(String.format("mods.thermalexpansion.Crucible.addRecipe(%d, %s, %s);", - recipe.getEnergy(), - LogHelper.getStackDescription(recipe.getInput()), - LogHelper.getStackDescription(recipe.getOutput()))); + if (args.isEmpty() || args.contains("Crucible")) { + for (RecipeCrucible recipe : CrucibleManager.getRecipeList()) { + MineTweakerAPI.logCommand( + String.format( + "mods.thermalexpansion.Crucible.addRecipe(%d, %s, %s);", + recipe.getEnergy(), + LogHelper.getStackDescription(recipe.getInput()), + LogHelper.getStackDescription(recipe.getOutput()))); } } - - if(args.isEmpty() || args.contains("Furnace")) { - for(RecipeFurnace recipe : FurnaceManager.getRecipeList()) { - MineTweakerAPI.logCommand(String.format("mods.thermalexpansion.Furnace.addRecipe(%d, %s, %s);", - recipe.getEnergy(), - LogHelper.getStackDescription(recipe.getInput()), - LogHelper.getStackDescription(recipe.getOutput()))); + + if (args.isEmpty() || args.contains("Furnace")) { + for (RecipeFurnace recipe : FurnaceManager.getRecipeList()) { + MineTweakerAPI.logCommand( + String.format( + "mods.thermalexpansion.Furnace.addRecipe(%d, %s, %s);", + recipe.getEnergy(), + LogHelper.getStackDescription(recipe.getInput()), + LogHelper.getStackDescription(recipe.getOutput()))); } } - - if(args.isEmpty() || args.contains("Insolator")) { - for(RecipeInsolator recipe : InsolatorManager.getRecipeList()) { - if(recipe.getSecondaryOutput() != null) { - MineTweakerAPI.logCommand(String.format("mods.thermalexpansion.Insolator.addRecipe(%d, %s, %s, %s, %s, %d);", - recipe.getEnergy(), - LogHelper.getStackDescription(recipe.getPrimaryInput()), - LogHelper.getStackDescription(recipe.getSecondaryInput()), - LogHelper.getStackDescription(recipe.getPrimaryOutput()), - LogHelper.getStackDescription(recipe.getSecondaryOutput()), - recipe.getSecondaryOutputChance())); + + if (args.isEmpty() || args.contains("Insolator")) { + for (RecipeInsolator recipe : InsolatorManager.getRecipeList()) { + if (recipe.getSecondaryOutput() != null) { + MineTweakerAPI.logCommand( + String.format( + "mods.thermalexpansion.Insolator.addRecipe(%d, %s, %s, %s, %s, %d);", + recipe.getEnergy(), + LogHelper.getStackDescription(recipe.getPrimaryInput()), + LogHelper.getStackDescription(recipe.getSecondaryInput()), + LogHelper.getStackDescription(recipe.getPrimaryOutput()), + LogHelper.getStackDescription(recipe.getSecondaryOutput()), + recipe.getSecondaryOutputChance())); } else { - MineTweakerAPI.logCommand(String.format("mods.thermalexpansion.Insolator.addRecipe(%d, %s, %s, %s);", - recipe.getEnergy(), - LogHelper.getStackDescription(recipe.getPrimaryInput()), - LogHelper.getStackDescription(recipe.getSecondaryInput()), - LogHelper.getStackDescription(recipe.getPrimaryOutput()))); + MineTweakerAPI.logCommand( + String.format( + "mods.thermalexpansion.Insolator.addRecipe(%d, %s, %s, %s);", + recipe.getEnergy(), + LogHelper.getStackDescription(recipe.getPrimaryInput()), + LogHelper.getStackDescription(recipe.getSecondaryInput()), + LogHelper.getStackDescription(recipe.getPrimaryOutput()))); } } } - - if(args.isEmpty() || args.contains("Pulverizer")) { - for(RecipePulverizer recipe : PulverizerManager.getRecipeList()) { - if(recipe.getSecondaryOutput() != null) { - MineTweakerAPI.logCommand(String.format("mods.thermalexpansion.Pulverizer.addRecipe(%d, %s, %s, %s, %d);", - recipe.getEnergy(), - LogHelper.getStackDescription(recipe.getInput()), - LogHelper.getStackDescription(recipe.getPrimaryOutput()), - LogHelper.getStackDescription(recipe.getSecondaryOutput()), - recipe.getSecondaryOutputChance())); + + if (args.isEmpty() || args.contains("Pulverizer")) { + for (RecipePulverizer recipe : PulverizerManager.getRecipeList()) { + if (recipe.getSecondaryOutput() != null) { + MineTweakerAPI.logCommand( + String.format( + "mods.thermalexpansion.Pulverizer.addRecipe(%d, %s, %s, %s, %d);", + recipe.getEnergy(), + LogHelper.getStackDescription(recipe.getInput()), + LogHelper.getStackDescription(recipe.getPrimaryOutput()), + LogHelper.getStackDescription(recipe.getSecondaryOutput()), + recipe.getSecondaryOutputChance())); } else { - MineTweakerAPI.logCommand(String.format("mods.thermalexpansion.Pulverizer.addRecipe(%d, %s, %s);", - recipe.getEnergy(), - LogHelper.getStackDescription(recipe.getInput()), - LogHelper.getStackDescription(recipe.getPrimaryOutput()))); + MineTweakerAPI.logCommand( + String.format( + "mods.thermalexpansion.Pulverizer.addRecipe(%d, %s, %s);", + recipe.getEnergy(), + LogHelper.getStackDescription(recipe.getInput()), + LogHelper.getStackDescription(recipe.getPrimaryOutput()))); } } } - - if(args.isEmpty() || args.contains("Sawmill")) { - for(RecipeSawmill recipe : SawmillManager.getRecipeList()) { - if(recipe.getSecondaryOutput() != null) { - MineTweakerAPI.logCommand(String.format("mods.thermalexpansion.Sawmill.addRecipe(%d, %s, %s, %s, %d);", - recipe.getEnergy(), - LogHelper.getStackDescription(recipe.getInput()), - LogHelper.getStackDescription(recipe.getPrimaryOutput()), - LogHelper.getStackDescription(recipe.getSecondaryOutput()), - recipe.getSecondaryOutputChance())); + + if (args.isEmpty() || args.contains("Sawmill")) { + for (RecipeSawmill recipe : SawmillManager.getRecipeList()) { + if (recipe.getSecondaryOutput() != null) { + MineTweakerAPI.logCommand( + String.format( + "mods.thermalexpansion.Sawmill.addRecipe(%d, %s, %s, %s, %d);", + recipe.getEnergy(), + LogHelper.getStackDescription(recipe.getInput()), + LogHelper.getStackDescription(recipe.getPrimaryOutput()), + LogHelper.getStackDescription(recipe.getSecondaryOutput()), + recipe.getSecondaryOutputChance())); } else { - MineTweakerAPI.logCommand(String.format("mods.thermalexpansion.Sawmill.addRecipe(%d, %s, %s);", - recipe.getEnergy(), - LogHelper.getStackDescription(recipe.getInput()), - LogHelper.getStackDescription(recipe.getPrimaryOutput()))); + MineTweakerAPI.logCommand( + String.format( + "mods.thermalexpansion.Sawmill.addRecipe(%d, %s, %s);", + recipe.getEnergy(), + LogHelper.getStackDescription(recipe.getInput()), + LogHelper.getStackDescription(recipe.getPrimaryOutput()))); } } } - - if(args.isEmpty() || args.contains("Smelter")) { - for(RecipeSmelter recipe : SmelterManager.getRecipeList()) { - if(recipe.getSecondaryOutput() != null) { - MineTweakerAPI.logCommand(String.format("mods.thermalexpansion.Smelter.addRecipe(%d, %s, %s, %s, %s, %d);", - recipe.getEnergy(), - LogHelper.getStackDescription(recipe.getPrimaryInput()), - LogHelper.getStackDescription(recipe.getSecondaryInput()), - LogHelper.getStackDescription(recipe.getPrimaryOutput()), - LogHelper.getStackDescription(recipe.getSecondaryOutput()), - recipe.getSecondaryOutputChance())); + + if (args.isEmpty() || args.contains("Smelter")) { + for (RecipeSmelter recipe : SmelterManager.getRecipeList()) { + if (recipe.getSecondaryOutput() != null) { + MineTweakerAPI.logCommand( + String.format( + "mods.thermalexpansion.Smelter.addRecipe(%d, %s, %s, %s, %s, %d);", + recipe.getEnergy(), + LogHelper.getStackDescription(recipe.getPrimaryInput()), + LogHelper.getStackDescription(recipe.getSecondaryInput()), + LogHelper.getStackDescription(recipe.getPrimaryOutput()), + LogHelper.getStackDescription(recipe.getSecondaryOutput()), + recipe.getSecondaryOutputChance())); } else { - MineTweakerAPI.logCommand(String.format("mods.thermalexpansion.Smelter.addRecipe(%d, %s, %s, %s);", - recipe.getEnergy(), - LogHelper.getStackDescription(recipe.getPrimaryInput()), - LogHelper.getStackDescription(recipe.getSecondaryInput()), - LogHelper.getStackDescription(recipe.getPrimaryOutput()))); + MineTweakerAPI.logCommand( + String.format( + "mods.thermalexpansion.Smelter.addRecipe(%d, %s, %s, %s);", + recipe.getEnergy(), + LogHelper.getStackDescription(recipe.getPrimaryInput()), + LogHelper.getStackDescription(recipe.getSecondaryInput()), + LogHelper.getStackDescription(recipe.getPrimaryOutput()))); } } } - - if(args.isEmpty() || args.contains("Transposer")) { - for(RecipeTransposer recipe : TransposerManager.getFillRecipeList()) { - MineTweakerAPI.logCommand(String.format("mods.thermalexpansion.Transposer.addFillRecipe(%d, %s, %s, %s);", - recipe.getEnergy(), - LogHelper.getStackDescription(recipe.getInput()), - LogHelper.getStackDescription(recipe.getOutput()), - LogHelper.getStackDescription(recipe.getFluid()))); + + if (args.isEmpty() || args.contains("Transposer")) { + for (RecipeTransposer recipe : TransposerManager.getFillRecipeList()) { + MineTweakerAPI.logCommand( + String.format( + "mods.thermalexpansion.Transposer.addFillRecipe(%d, %s, %s, %s);", + recipe.getEnergy(), + LogHelper.getStackDescription(recipe.getInput()), + LogHelper.getStackDescription(recipe.getOutput()), + LogHelper.getStackDescription(recipe.getFluid()))); } - - for(RecipeTransposer recipe : TransposerManager.getExtractionRecipeList()) { - MineTweakerAPI.logCommand(String.format("mods.thermalexpansion.Transposer.addExtractRecipe(%d, %s, %s, %s, %d);", - recipe.getEnergy(), - LogHelper.getStackDescription(recipe.getInput()), - LogHelper.getStackDescription(recipe.getOutput()), - LogHelper.getStackDescription(recipe.getFluid()), - recipe.getChance())); + + for (RecipeTransposer recipe : TransposerManager.getExtractionRecipeList()) { + MineTweakerAPI.logCommand( + String.format( + "mods.thermalexpansion.Transposer.addExtractRecipe(%d, %s, %s, %s, %d);", + recipe.getEnergy(), + LogHelper.getStackDescription(recipe.getInput()), + LogHelper.getStackDescription(recipe.getOutput()), + LogHelper.getStackDescription(recipe.getFluid()), + recipe.getChance())); } } - + if (player != null) { - player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir")); + player.sendChat( + MineTweakerImplementationAPI.platform + .getMessage("List generated; see minetweaker.log in your minecraft dir")); } } } diff --git a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Crucible.java b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Crucible.java index 6b57c73..7e1b356 100644 --- a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Crucible.java +++ b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Crucible.java @@ -25,124 +25,123 @@ import cofh.thermalexpansion.util.crafting.CrucibleManager.RecipeCrucible; @ZenClass("mods.thermalexpansion.Crucible") public class Crucible { - + public static final String name = "Thermal Expansion Crucible"; - - @ZenMethod - public static void addRecipe(int energy, IItemStack input, ILiquidStack output) { - if(input == null || output == null) { + + @ZenMethod + public static void addRecipe(int energy, IItemStack input, ILiquidStack output) { + if (input == null || output == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - - if(CrucibleManager.recipeExists(toStack(input))) { - LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s. Command ignored!", name, LogHelper.getStackDescription(toStack(input)))); + + if (CrucibleManager.recipeExists(toStack(input))) { + LogHelper.logWarning( + String.format( + "Duplicate %s Recipe found for %s. Command ignored!", + name, + LogHelper.getStackDescription(toStack(input)))); return; - } - - RecipeCrucible recipe = ReflectionHelper.getInstance(ThermalHelper.crucibleRecipe, toStack(input), toFluid(output), energy); - - if(recipe != null) { + } + + RecipeCrucible recipe = ReflectionHelper + .getInstance(ThermalHelper.crucibleRecipe, toStack(input), toFluid(output), energy); + + if (recipe != null) { MineTweakerAPI.apply(new Add(recipe)); } else { LogHelper.logError(String.format("Error while creating instance for %s recipe.", name)); } - } + } - private static class Add extends BaseListAddition { + private static class Add extends BaseListAddition { - public Add(RecipeCrucible recipe) { - super(Crucible.name, null); - recipes.add(recipe); - } + public Add(RecipeCrucible recipe) { + super(Crucible.name, null); + recipes.add(recipe); + } - public void apply() { - for(RecipeCrucible recipe : recipes) { - boolean applied = CrucibleManager.addRecipe( - recipe.getEnergy(), - recipe.getInput(), - recipe.getOutput()); - - if(applied) { - successful.add(recipe); - } - } - } + public void apply() { + for (RecipeCrucible recipe : recipes) { + boolean applied = CrucibleManager.addRecipe(recipe.getEnergy(), recipe.getInput(), recipe.getOutput()); - public void undo() { - for(RecipeCrucible recipe : successful) { - CrucibleManager.removeRecipe(recipe.getInput()); - } - } - - @Override - protected boolean equals(RecipeCrucible recipe, RecipeCrucible otherRecipe) { - return ThermalHelper.equals(recipe, otherRecipe); - } - - @Override - protected String getRecipeInfo(RecipeCrucible recipe) { - return LogHelper.getStackDescription(recipe.getInput()); - } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - @ZenMethod - public static void removeRecipe(IIngredient input) { - List recipes = new LinkedList(); - - for(RecipeCrucible recipe : CrucibleManager.getRecipeList()) { - if(recipe != null && matches(input, toIItemStack(recipe.getInput()))) { - recipes.add(recipe); - } - } - - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new Remove(recipes)); - } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s.", name, input.toString())); - } - } - - private static class Remove extends BaseListRemoval { - - public Remove(List recipes) { - super(Crucible.name, null, recipes); - } - - public void apply() { - for(RecipeCrucible recipe : recipes) { - boolean removed = CrucibleManager.removeRecipe(recipe.getInput()); - - if(removed) { - successful.add(recipe); - } - } - } - - public void undo() { - for(RecipeCrucible recipe : successful) { - CrucibleManager.addRecipe( - recipe.getEnergy(), - recipe.getInput(), - recipe.getOutput()); + if (applied) { + successful.add(recipe); + } } - } - + } + + public void undo() { + for (RecipeCrucible recipe : successful) { + CrucibleManager.removeRecipe(recipe.getInput()); + } + } + @Override protected boolean equals(RecipeCrucible recipe, RecipeCrucible otherRecipe) { return ThermalHelper.equals(recipe, otherRecipe); } - + @Override protected String getRecipeInfo(RecipeCrucible recipe) { return LogHelper.getStackDescription(recipe.getInput()); } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + @ZenMethod + public static void removeRecipe(IIngredient input) { + List recipes = new LinkedList(); + + for (RecipeCrucible recipe : CrucibleManager.getRecipeList()) { + if (recipe != null && matches(input, toIItemStack(recipe.getInput()))) { + recipes.add(recipe); + } + } + + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new Remove(recipes)); + } else { + LogHelper.logWarning(String.format("No %s Recipe found for %s.", name, input.toString())); + } + } + + private static class Remove extends BaseListRemoval { + + public Remove(List recipes) { + super(Crucible.name, null, recipes); + } + + public void apply() { + for (RecipeCrucible recipe : recipes) { + boolean removed = CrucibleManager.removeRecipe(recipe.getInput()); + + if (removed) { + successful.add(recipe); + } + } + } + + public void undo() { + for (RecipeCrucible recipe : successful) { + CrucibleManager.addRecipe(recipe.getEnergy(), recipe.getInput(), recipe.getOutput()); + } + } + + @Override + protected boolean equals(RecipeCrucible recipe, RecipeCrucible otherRecipe) { + return ThermalHelper.equals(recipe, otherRecipe); + } + + @Override + protected String getRecipeInfo(RecipeCrucible recipe) { + return LogHelper.getStackDescription(recipe.getInput()); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + @ZenMethod public static void refreshRecipes() { MineTweakerAPI.apply(new Refresh()); @@ -162,8 +161,7 @@ public class Crucible { return "Refreshing " + Crucible.name + " recipes"; } - public void undo() { - } + public void undo() {} public String describeUndo() { return "Ignoring undo of " + Crucible.name + " recipe refresh"; diff --git a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Furnace.java b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Furnace.java index d40851a..4d48ed4 100644 --- a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Furnace.java +++ b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Furnace.java @@ -23,115 +23,63 @@ import cofh.thermalexpansion.util.crafting.FurnaceManager.RecipeFurnace; @ZenClass("mods.thermalexpansion.Furnace") public class Furnace { - + public static final String name = "Thermal Expansion Furnace"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - @ZenMethod - public static void addRecipe(int energy, IItemStack input, IItemStack output) { - if(input == null || output == null) { - LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); - return; - } - - if(FurnaceManager.recipeExists(toStack(input))) { - LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s. Command ignored!", name, LogHelper.getStackDescription(toStack(input)))); + + @ZenMethod + public static void addRecipe(int energy, IItemStack input, IItemStack output) { + if (input == null || output == null) { + LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - - RecipeFurnace recipe = ReflectionHelper.getInstance(ThermalHelper.furanceRecipe, toStack(input), toStack(output), energy); - - if(recipe != null) { + + if (FurnaceManager.recipeExists(toStack(input))) { + LogHelper.logWarning( + String.format( + "Duplicate %s Recipe found for %s. Command ignored!", + name, + LogHelper.getStackDescription(toStack(input)))); + return; + } + + RecipeFurnace recipe = ReflectionHelper + .getInstance(ThermalHelper.furanceRecipe, toStack(input), toStack(output), energy); + + if (recipe != null) { MineTweakerAPI.apply(new Add(recipe)); } else { LogHelper.logError(String.format("Error while creating instance for %s recipe.", name)); } - } + } - private static class Add extends BaseListAddition { - public Add(RecipeFurnace recipe) { - super(Furnace.name, null); - recipes.add(recipe); - } + private static class Add extends BaseListAddition { - public void apply() { - for(RecipeFurnace recipe : recipes) { - boolean applied = FurnaceManager.addRecipe( - recipe.getEnergy(), - recipe.getInput(), - recipe.getOutput(), - false); - - if(applied) { - successful.add(recipe); - } - } + public Add(RecipeFurnace recipe) { + super(Furnace.name, null); + recipes.add(recipe); + } - } + public void apply() { + for (RecipeFurnace recipe : recipes) { + boolean applied = FurnaceManager + .addRecipe(recipe.getEnergy(), recipe.getInput(), recipe.getOutput(), false); - public void undo() { - for(RecipeFurnace recipe : recipes) { - FurnaceManager.removeRecipe(recipe.getInput()); - } - - } - - @Override - protected boolean equals(RecipeFurnace recipe, RecipeFurnace otherRecipe) { - return ThermalHelper.equals(recipe, otherRecipe); - } + if (applied) { + successful.add(recipe); + } + } - @Override - protected String getRecipeInfo(RecipeFurnace recipe) { - return LogHelper.getStackDescription(recipe.getOutput()); - } - } + } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + public void undo() { + for (RecipeFurnace recipe : recipes) { + FurnaceManager.removeRecipe(recipe.getInput()); + } - @ZenMethod - public static void removeRecipe(IIngredient input) { - List recipes = new LinkedList(); - - for(RecipeFurnace recipe : FurnaceManager.getRecipeList()) { - if(recipe != null && matches(input, toIItemStack(recipe.getInput()))) { - recipes.add(recipe); - } - } - - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new Remove(recipes)); - } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s.", name, input.toString())); - } - } + } - private static class Remove extends BaseListRemoval { - public Remove(List recipes) { - super(Furnace.name, null, recipes); - } - - public void apply() { - for(RecipeFurnace recipe : recipes) { - boolean removed = FurnaceManager.removeRecipe(recipe.getInput()); - - if(removed) { - successful.add(recipe); - } - } - } - - public void undo() { - for(RecipeFurnace recipe : successful) { - FurnaceManager.addRecipe( - recipe.getEnergy(), - recipe.getInput(), - recipe.getOutput(), - false); - } - } - @Override protected boolean equals(RecipeFurnace recipe, RecipeFurnace otherRecipe) { return ThermalHelper.equals(recipe, otherRecipe); @@ -141,38 +89,89 @@ public class Furnace { protected String getRecipeInfo(RecipeFurnace recipe) { return LogHelper.getStackDescription(recipe.getOutput()); } - } + } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - @ZenMethod - public static void refreshRecipes() { - MineTweakerAPI.apply(new Refresh()); - } + @ZenMethod + public static void removeRecipe(IIngredient input) { + List recipes = new LinkedList(); - private static class Refresh implements IUndoableAction { + for (RecipeFurnace recipe : FurnaceManager.getRecipeList()) { + if (recipe != null && matches(input, toIItemStack(recipe.getInput()))) { + recipes.add(recipe); + } + } - public void apply() { - FurnaceManager.refreshRecipes(); - } + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new Remove(recipes)); + } else { + LogHelper.logWarning(String.format("No %s Recipe found for %s.", name, input.toString())); + } + } - public boolean canUndo() { - return true; - } + private static class Remove extends BaseListRemoval { - public String describe() { - return "Refreshing " + Furnace.name + " recipes"; - } + public Remove(List recipes) { + super(Furnace.name, null, recipes); + } - public void undo() { - } + public void apply() { + for (RecipeFurnace recipe : recipes) { + boolean removed = FurnaceManager.removeRecipe(recipe.getInput()); - public String describeUndo() { - return "Ignoring undo of " + Furnace.name + " recipe refresh"; - } + if (removed) { + successful.add(recipe); + } + } + } - public Object getOverrideKey() { - return null; - } - } + public void undo() { + for (RecipeFurnace recipe : successful) { + FurnaceManager.addRecipe(recipe.getEnergy(), recipe.getInput(), recipe.getOutput(), false); + } + } + + @Override + protected boolean equals(RecipeFurnace recipe, RecipeFurnace otherRecipe) { + return ThermalHelper.equals(recipe, otherRecipe); + } + + @Override + protected String getRecipeInfo(RecipeFurnace recipe) { + return LogHelper.getStackDescription(recipe.getOutput()); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + @ZenMethod + public static void refreshRecipes() { + MineTweakerAPI.apply(new Refresh()); + } + + private static class Refresh implements IUndoableAction { + + public void apply() { + FurnaceManager.refreshRecipes(); + } + + public boolean canUndo() { + return true; + } + + public String describe() { + return "Refreshing " + Furnace.name + " recipes"; + } + + public void undo() {} + + public String describeUndo() { + return "Ignoring undo of " + Furnace.name + " recipe refresh"; + } + + public Object getOverrideKey() { + return null; + } + } } diff --git a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Insolator.java b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Insolator.java index 84a1f75..edc763b 100644 --- a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Insolator.java +++ b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Insolator.java @@ -24,129 +24,137 @@ import cofh.thermalexpansion.util.crafting.InsolatorManager.RecipeInsolator; @ZenClass("mods.thermalexpansion.Insolator") public class Insolator { - - public static final String name = "Thermal Expansion Insolator"; - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - @ZenMethod - public static void addRecipe(int energy, IItemStack secondaryInput, IItemStack primaryInput, IItemStack primaryOutput, @Optional IItemStack secondaryOutput, @Optional int secondaryChance) { - if(primaryInput == null || secondaryInput == null || primaryOutput == null) { - LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); - return; - } - - /* TODO: Make it check for meta data - if(InsolatorManager.recipeExists(toStack(primaryInput), toStack(secondaryInput))) { - LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s and %s. Command ignored!", name, primaryInput.toString(), secondaryInput.toString())); + + public static final String name = "Thermal Expansion Insolator"; + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + @ZenMethod + public static void addRecipe(int energy, IItemStack secondaryInput, IItemStack primaryInput, + IItemStack primaryOutput, @Optional IItemStack secondaryOutput, @Optional int secondaryChance) { + if (primaryInput == null || secondaryInput == null || primaryOutput == null) { + LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; - } - */ - - RecipeInsolator recipe = ReflectionHelper.getInstance(ThermalHelper.insolatorRecipe, toStack(primaryInput), toStack(secondaryInput), toStack(primaryOutput), toStack(secondaryOutput), secondaryChance, energy); - - if(recipe != null) { + } + + /* + * TODO: Make it check for meta data if(InsolatorManager.recipeExists(toStack(primaryInput), + * toStack(secondaryInput))) { + * LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s and %s. Command ignored!", name, + * primaryInput.toString(), secondaryInput.toString())); return; } + */ + + RecipeInsolator recipe = ReflectionHelper.getInstance( + ThermalHelper.insolatorRecipe, + toStack(primaryInput), + toStack(secondaryInput), + toStack(primaryOutput), + toStack(secondaryOutput), + secondaryChance, + energy); + + if (recipe != null) { MineTweakerAPI.apply(new Add(recipe)); } else { LogHelper.logError(String.format("Error while creating instance for %s recipe.", name)); } - } - - private static class Add extends BaseListAddition { - public Add(RecipeInsolator recipe) { - super(Insolator.name, null); - recipes.add(recipe); - } + } - public void apply() { - for(RecipeInsolator recipe : recipes) { - boolean applied = InsolatorManager.addRecipe( - recipe.getEnergy(), - recipe.getPrimaryInput(), - recipe.getSecondaryInput(), - recipe.getPrimaryOutput(), - recipe.getSecondaryOutput(), - recipe.getSecondaryOutputChance(), - false); - - if(applied) { - successful.add(recipe); - } - } + private static class Add extends BaseListAddition { - } + public Add(RecipeInsolator recipe) { + super(Insolator.name, null); + recipes.add(recipe); + } - public void undo() { - for(RecipeInsolator recipe : recipes) { - InsolatorManager.removeRecipe(recipe.getPrimaryInput(), recipe.getSecondaryInput()); - } - - } - - @Override - protected boolean equals(RecipeInsolator recipe, RecipeInsolator otherRecipe) { - return ThermalHelper.equals(recipe, otherRecipe); - } + public void apply() { + for (RecipeInsolator recipe : recipes) { + boolean applied = InsolatorManager.addRecipe( + recipe.getEnergy(), + recipe.getPrimaryInput(), + recipe.getSecondaryInput(), + recipe.getPrimaryOutput(), + recipe.getSecondaryOutput(), + recipe.getSecondaryOutputChance(), + false); - @Override - protected String getRecipeInfo(RecipeInsolator recipe) { - return LogHelper.getStackDescription(recipe.getPrimaryOutput()); - } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + if (applied) { + successful.add(recipe); + } + } - @ZenMethod - public static void removeRecipe(IIngredient input2, IIngredient input1) { - List recipes = new LinkedList(); - - for(RecipeInsolator recipe : InsolatorManager.getRecipeList()) { - if(recipe != null && matches(input1, toIItemStack(recipe.getPrimaryInput())) && matches(input2, toIItemStack(recipe.getSecondaryInput()))) { + } + + public void undo() { + for (RecipeInsolator recipe : recipes) { + InsolatorManager.removeRecipe(recipe.getPrimaryInput(), recipe.getSecondaryInput()); + } + + } + + @Override + protected boolean equals(RecipeInsolator recipe, RecipeInsolator otherRecipe) { + return ThermalHelper.equals(recipe, otherRecipe); + } + + @Override + protected String getRecipeInfo(RecipeInsolator recipe) { + return LogHelper.getStackDescription(recipe.getPrimaryOutput()); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + @ZenMethod + public static void removeRecipe(IIngredient input2, IIngredient input1) { + List recipes = new LinkedList(); + + for (RecipeInsolator recipe : InsolatorManager.getRecipeList()) { + if (recipe != null && matches(input1, toIItemStack(recipe.getPrimaryInput())) + && matches(input2, toIItemStack(recipe.getSecondaryInput()))) { recipes.add(recipe); } } - - /* TODO: Make it check for meta data - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new Remove(recipes)); - } else { - LogHelper.logWarning(String.format("No %s Recipes found for %s and %s.", name, input1.toString(), input2.toString())); + + /* + * TODO: Make it check for meta data if(!recipes.isEmpty()) { MineTweakerAPI.apply(new Remove(recipes)); } else + * { LogHelper.logWarning(String.format("No %s Recipes found for %s and %s.", name, input1.toString(), + * input2.toString())); } + */ + } + + private static class Remove extends BaseListRemoval { + + public Remove(List recipes) { + super(Insolator.name, null, recipes); } - */ - } - private static class Remove extends BaseListRemoval { + @Override + public void apply() { + for (RecipeInsolator recipe : recipes) { + boolean removed = InsolatorManager.removeRecipe(recipe.getPrimaryInput(), recipe.getSecondaryInput()); - public Remove(List recipes) { - super(Insolator.name, null, recipes); - } + if (removed) { + successful.add(recipe); + } + } + } + + @Override + public void undo() { + for (RecipeInsolator recipe : recipes) { + InsolatorManager.addRecipe( + recipe.getEnergy(), + recipe.getPrimaryInput(), + recipe.getSecondaryInput(), + recipe.getPrimaryOutput(), + recipe.getSecondaryOutput(), + recipe.getSecondaryOutputChance()); + } + } - @Override - public void apply() { - for(RecipeInsolator recipe : recipes) { - boolean removed = InsolatorManager.removeRecipe(recipe.getPrimaryInput(), recipe.getSecondaryInput()); - - if(removed) { - successful.add(recipe); - } - } - } - - @Override - public void undo() { - for(RecipeInsolator recipe : recipes) { - InsolatorManager.addRecipe( - recipe.getEnergy(), - recipe.getPrimaryInput(), - recipe.getSecondaryInput(), - recipe.getPrimaryOutput(), - recipe.getSecondaryOutput(), - recipe.getSecondaryOutputChance()); - } - } - @Override protected boolean equals(RecipeInsolator recipe, RecipeInsolator otherRecipe) { return ThermalHelper.equals(recipe, otherRecipe); @@ -156,9 +164,9 @@ public class Insolator { public String getRecipeInfo(RecipeInsolator recipe) { return LogHelper.getStackDescription(recipe.getPrimaryOutput()); } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @ZenMethod public static void refreshRecipes() { @@ -168,7 +176,7 @@ public class Insolator { private static class Refresh implements IUndoableAction { public void apply() { - InsolatorManager.refreshRecipes(); + InsolatorManager.refreshRecipes(); } public boolean canUndo() { @@ -179,8 +187,7 @@ public class Insolator { return "Refreshing " + Insolator.name + " recipes"; } - public void undo() { - } + public void undo() {} public String describeUndo() { return "Ignoring undo of " + Insolator.name + " recipe refresh"; diff --git a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Pulverizer.java b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Pulverizer.java index dfde51c..da05319 100644 --- a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Pulverizer.java +++ b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Pulverizer.java @@ -16,130 +16,84 @@ import modtweaker2.helpers.ReflectionHelper; import modtweaker2.mods.thermalexpansion.ThermalHelper; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; +import stanhebben.zenscript.annotations.Optional; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; -import stanhebben.zenscript.annotations.Optional; import cofh.thermalexpansion.util.crafting.PulverizerManager; import cofh.thermalexpansion.util.crafting.PulverizerManager.RecipePulverizer; @ZenClass("mods.thermalexpansion.Pulverizer") public class Pulverizer { - - public static final String name = "Thermal Expansion Pulverizer"; - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - @ZenMethod - public static void addRecipe(int energy, IItemStack input, IItemStack output) { - addRecipe(energy, input, output, null, 0); - } - @ZenMethod - public static void addRecipe(int energy, IItemStack input, IItemStack output, @Optional IItemStack secondary, @Optional int secondaryChance) { - if(input == null || output == null) { + public static final String name = "Thermal Expansion Pulverizer"; + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + @ZenMethod + public static void addRecipe(int energy, IItemStack input, IItemStack output) { + addRecipe(energy, input, output, null, 0); + } + + @ZenMethod + public static void addRecipe(int energy, IItemStack input, IItemStack output, @Optional IItemStack secondary, + @Optional int secondaryChance) { + if (input == null || output == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - - if(PulverizerManager.recipeExists(toStack(input))) { - LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s. Command ignored!", name, LogHelper.getStackDescription(toStack(input)))); + + if (PulverizerManager.recipeExists(toStack(input))) { + LogHelper.logWarning( + String.format( + "Duplicate %s Recipe found for %s. Command ignored!", + name, + LogHelper.getStackDescription(toStack(input)))); return; } - - RecipePulverizer recipe = ReflectionHelper.getInstance(ThermalHelper.pulverizerRecipe, toStack(input), toStack(output), toStack(secondary), secondaryChance, energy); - - if(recipe != null) { + + RecipePulverizer recipe = ReflectionHelper.getInstance( + ThermalHelper.pulverizerRecipe, + toStack(input), + toStack(output), + toStack(secondary), + secondaryChance, + energy); + + if (recipe != null) { MineTweakerAPI.apply(new Add(recipe)); } else { LogHelper.logError(String.format("Error while creating instance for %s recipe.", name)); } - } + } - private static class Add extends BaseListAddition { - public Add(RecipePulverizer recipe) { - super(Pulverizer.name, null); - recipes.add(recipe); - } + private static class Add extends BaseListAddition { - public void apply() { - for(RecipePulverizer recipe : recipes) { - boolean applied = PulverizerManager.addRecipe( - recipe.getEnergy(), - recipe.getInput(), - recipe.getPrimaryOutput(), - recipe.getSecondaryOutput(), - recipe.getSecondaryOutputChance()); - - if(applied) { - successful.add(recipe); - } - } - } + public Add(RecipePulverizer recipe) { + super(Pulverizer.name, null); + recipes.add(recipe); + } - public void undo() { - for(RecipePulverizer recipe : successful) { - PulverizerManager.removeRecipe(recipe.getInput()); - } - } - - @Override - protected boolean equals(RecipePulverizer recipe, RecipePulverizer otherRecipe) { - return ThermalHelper.equals(recipe, otherRecipe); - } + public void apply() { + for (RecipePulverizer recipe : recipes) { + boolean applied = PulverizerManager.addRecipe( + recipe.getEnergy(), + recipe.getInput(), + recipe.getPrimaryOutput(), + recipe.getSecondaryOutput(), + recipe.getSecondaryOutputChance()); - @Override - protected String getRecipeInfo(RecipePulverizer recipe) { - return LogHelper.getStackDescription(recipe.getInput()); - } - } + if (applied) { + successful.add(recipe); + } + } + } - // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + public void undo() { + for (RecipePulverizer recipe : successful) { + PulverizerManager.removeRecipe(recipe.getInput()); + } + } - @ZenMethod - public static void removeRecipe(IIngredient input) { - List recipes = new LinkedList(); - RecipePulverizer[] list = PulverizerManager.getRecipeList(); - - for(RecipePulverizer recipe : list) { - if(recipe != null && recipe.getInput() != null && matches(input, toIItemStack(recipe.getInput()))) { - recipes.add(recipe); - } - } - - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new Remove(recipes)); - } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s.", name, input.toString())); - } - - } - - private static class Remove extends BaseListRemoval { - public Remove(List recipes) { - super(Pulverizer.name, null, recipes); - } - - public void apply() { - for(RecipePulverizer recipe : recipes) { - boolean removed = PulverizerManager.removeRecipe(recipe.getInput()); - - if(removed) { - successful.add(recipe); - } - } - } - - public void undo() { - for(RecipePulverizer recipe : successful) { - PulverizerManager.addRecipe( - recipe.getEnergy(), - recipe.getInput(), - recipe.getPrimaryOutput(), - recipe.getSecondaryOutput(), - recipe.getSecondaryOutputChance()); - } - } - @Override protected boolean equals(RecipePulverizer recipe, RecipePulverizer otherRecipe) { return ThermalHelper.equals(recipe, otherRecipe); @@ -149,9 +103,68 @@ public class Pulverizer { protected String getRecipeInfo(RecipePulverizer recipe) { return LogHelper.getStackDescription(recipe.getInput()); } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + } + + // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + @ZenMethod + public static void removeRecipe(IIngredient input) { + List recipes = new LinkedList(); + RecipePulverizer[] list = PulverizerManager.getRecipeList(); + + for (RecipePulverizer recipe : list) { + if (recipe != null && recipe.getInput() != null && matches(input, toIItemStack(recipe.getInput()))) { + recipes.add(recipe); + } + } + + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new Remove(recipes)); + } else { + LogHelper.logWarning(String.format("No %s Recipe found for %s.", name, input.toString())); + } + + } + + private static class Remove extends BaseListRemoval { + + public Remove(List recipes) { + super(Pulverizer.name, null, recipes); + } + + public void apply() { + for (RecipePulverizer recipe : recipes) { + boolean removed = PulverizerManager.removeRecipe(recipe.getInput()); + + if (removed) { + successful.add(recipe); + } + } + } + + public void undo() { + for (RecipePulverizer recipe : successful) { + PulverizerManager.addRecipe( + recipe.getEnergy(), + recipe.getInput(), + recipe.getPrimaryOutput(), + recipe.getSecondaryOutput(), + recipe.getSecondaryOutputChance()); + } + } + + @Override + protected boolean equals(RecipePulverizer recipe, RecipePulverizer otherRecipe) { + return ThermalHelper.equals(recipe, otherRecipe); + } + + @Override + protected String getRecipeInfo(RecipePulverizer recipe) { + return LogHelper.getStackDescription(recipe.getInput()); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @ZenMethod public static void refreshRecipes() { @@ -172,8 +185,7 @@ public class Pulverizer { return "Refreshing " + Pulverizer.name + " recipes"; } - public void undo() { - } + public void undo() {} public String describeUndo() { return "Ignoring undo of " + Pulverizer.name + " recipe refresh"; diff --git a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Sawmill.java b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Sawmill.java index 88d8063..f095260 100644 --- a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Sawmill.java +++ b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Sawmill.java @@ -16,144 +16,157 @@ import modtweaker2.helpers.ReflectionHelper; import modtweaker2.mods.thermalexpansion.ThermalHelper; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; +import stanhebben.zenscript.annotations.Optional; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; -import stanhebben.zenscript.annotations.Optional; import cofh.thermalexpansion.util.crafting.SawmillManager; import cofh.thermalexpansion.util.crafting.SawmillManager.RecipeSawmill; @ZenClass("mods.thermalexpansion.Sawmill") public class Sawmill { - - public static final String name = "Thermal Expansion Sawmill"; - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - @ZenMethod - public static void addRecipe(int energy, IItemStack input, IItemStack output) { - addRecipe(energy, input, output, null, 0); - } - @ZenMethod - public static void addRecipe(int energy, IItemStack input, IItemStack output, @Optional IItemStack secondary, @Optional int secondaryChance) { - if(input == null || output == null) { + public static final String name = "Thermal Expansion Sawmill"; + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + @ZenMethod + public static void addRecipe(int energy, IItemStack input, IItemStack output) { + addRecipe(energy, input, output, null, 0); + } + + @ZenMethod + public static void addRecipe(int energy, IItemStack input, IItemStack output, @Optional IItemStack secondary, + @Optional int secondaryChance) { + if (input == null || output == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - - if(SawmillManager.recipeExists(toStack(input))) { - LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s. Command ignored!", name, LogHelper.getStackDescription(toStack(input)))); + + if (SawmillManager.recipeExists(toStack(input))) { + LogHelper.logWarning( + String.format( + "Duplicate %s Recipe found for %s. Command ignored!", + name, + LogHelper.getStackDescription(toStack(input)))); return; } - - RecipeSawmill recipe = ReflectionHelper.getInstance(ThermalHelper.sawmillRecipe, toStack(input), toStack(output), toStack(secondary), secondaryChance, energy); - - if(recipe != null) { + + RecipeSawmill recipe = ReflectionHelper.getInstance( + ThermalHelper.sawmillRecipe, + toStack(input), + toStack(output), + toStack(secondary), + secondaryChance, + energy); + + if (recipe != null) { MineTweakerAPI.apply(new Add(recipe)); } else { LogHelper.logError(String.format("Error while creating instance for %s recipe.", name)); } - } + } - private static class Add extends BaseListAddition { - public Add(RecipeSawmill recipe) { - super(Sawmill.name, null); - recipes.add(recipe); - } + private static class Add extends BaseListAddition { - @Override - public void apply() { - for(RecipeSawmill recipe : recipes) { - boolean applied = SawmillManager.addRecipe( - recipe.getEnergy(), - recipe.getInput(), - recipe.getPrimaryOutput(), - recipe.getSecondaryOutput(), - recipe.getSecondaryOutputChance()); - - if(applied) { - successful.add(recipe); - } - } - } + public Add(RecipeSawmill recipe) { + super(Sawmill.name, null); + recipes.add(recipe); + } - @Override - public void undo() { - for(RecipeSawmill recipe : successful) { - SawmillManager.removeRecipe(recipe.getInput()); - } - } - - @Override - protected boolean equals(RecipeSawmill recipe, RecipeSawmill otherRecipe) { - return ThermalHelper.equals(recipe, otherRecipe); - } + @Override + public void apply() { + for (RecipeSawmill recipe : recipes) { + boolean applied = SawmillManager.addRecipe( + recipe.getEnergy(), + recipe.getInput(), + recipe.getPrimaryOutput(), + recipe.getSecondaryOutput(), + recipe.getSecondaryOutputChance()); + + if (applied) { + successful.add(recipe); + } + } + } + + @Override + public void undo() { + for (RecipeSawmill recipe : successful) { + SawmillManager.removeRecipe(recipe.getInput()); + } + } + + @Override + protected boolean equals(RecipeSawmill recipe, RecipeSawmill otherRecipe) { + return ThermalHelper.equals(recipe, otherRecipe); + } @Override protected String getRecipeInfo(RecipeSawmill recipe) { return LogHelper.getStackDescription(recipe.getInput()); } - } + } - // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - @ZenMethod - public static void removeRecipe(IIngredient input) { - List recipes = new LinkedList(); - RecipeSawmill[] list = SawmillManager.getRecipeList(); - - for(RecipeSawmill recipe : list) { - if(recipe != null && recipe.getInput() != null && matches(input, toIItemStack(recipe.getInput()))) { - recipes.add(recipe); - } - } - - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new Remove(recipes)); - } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s.", name, input.toString())); - } - } + @ZenMethod + public static void removeRecipe(IIngredient input) { + List recipes = new LinkedList(); + RecipeSawmill[] list = SawmillManager.getRecipeList(); - private static class Remove extends BaseListRemoval { - public Remove(List recipes) { - super(Sawmill.name, null, recipes); - } + for (RecipeSawmill recipe : list) { + if (recipe != null && recipe.getInput() != null && matches(input, toIItemStack(recipe.getInput()))) { + recipes.add(recipe); + } + } - public void apply() { - for(RecipeSawmill recipe : recipes) { - boolean removed = SawmillManager.removeRecipe(recipe.getInput()); - if(removed) { - successful.add(recipe); - } - - } - } + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new Remove(recipes)); + } else { + LogHelper.logWarning(String.format("No %s Recipe found for %s.", name, input.toString())); + } + } + + private static class Remove extends BaseListRemoval { + + public Remove(List recipes) { + super(Sawmill.name, null, recipes); + } + + public void apply() { + for (RecipeSawmill recipe : recipes) { + boolean removed = SawmillManager.removeRecipe(recipe.getInput()); + if (removed) { + successful.add(recipe); + } + + } + } + + public void undo() { + for (RecipeSawmill recipe : successful) { + SawmillManager.addRecipe( + recipe.getEnergy(), + recipe.getInput(), + recipe.getPrimaryOutput(), + recipe.getSecondaryOutput(), + recipe.getSecondaryOutputChance()); + } + } - public void undo() { - for(RecipeSawmill recipe : successful) { - SawmillManager.addRecipe( - recipe.getEnergy(), - recipe.getInput(), - recipe.getPrimaryOutput(), - recipe.getSecondaryOutput(), - recipe.getSecondaryOutputChance()); - } - } - @Override protected boolean equals(RecipeSawmill recipe, RecipeSawmill otherRecipe) { return ThermalHelper.equals(recipe, otherRecipe); } - - @Override - protected String getRecipeInfo(RecipeSawmill recipe) { - return LogHelper.getStackDescription(recipe.getInput()); - } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + @Override + protected String getRecipeInfo(RecipeSawmill recipe) { + return LogHelper.getStackDescription(recipe.getInput()); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @ZenMethod public static void refreshRecipes() { @@ -174,8 +187,7 @@ public class Sawmill { return "Refreshing " + Sawmill.name + " recipes"; } - public void undo() { - } + public void undo() {} public String describeUndo() { return "Ignoring undo of " + Sawmill.name + " recipe refresh"; diff --git a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Smelter.java b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Smelter.java index b97c6ae..4864f2f 100644 --- a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Smelter.java +++ b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Smelter.java @@ -16,135 +16,89 @@ import modtweaker2.helpers.ReflectionHelper; import modtweaker2.mods.thermalexpansion.ThermalHelper; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; +import stanhebben.zenscript.annotations.Optional; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; -import stanhebben.zenscript.annotations.Optional; import cofh.thermalexpansion.util.crafting.SmelterManager; import cofh.thermalexpansion.util.crafting.SmelterManager.RecipeSmelter; @ZenClass("mods.thermalexpansion.Smelter") public class Smelter { - + public static final String name = "Thermal Expansion Smelter"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - @ZenMethod - public static void addRecipe(int energy, IItemStack input, IItemStack input2, IItemStack output) { - addRecipe(energy, input, input2, output, null, 0); - } + @ZenMethod + public static void addRecipe(int energy, IItemStack input, IItemStack input2, IItemStack output) { + addRecipe(energy, input, input2, output, null, 0); + } - @ZenMethod - public static void addRecipe(int energy, IItemStack input, IItemStack input2, IItemStack output, @Optional IItemStack output2, @Optional int chance) { - if(input == null || input2 == null || output == null) { + @ZenMethod + public static void addRecipe(int energy, IItemStack input, IItemStack input2, IItemStack output, + @Optional IItemStack output2, @Optional int chance) { + if (input == null || input2 == null || output == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); return; } - - if(SmelterManager.recipeExists(toStack(input), toStack(input2))) { - LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s and %s. Command ignored!", name, LogHelper.getStackDescription(toStack(input)), LogHelper.getStackDescription(toStack(input2)))); + + if (SmelterManager.recipeExists(toStack(input), toStack(input2))) { + LogHelper.logWarning( + String.format( + "Duplicate %s Recipe found for %s and %s. Command ignored!", + name, + LogHelper.getStackDescription(toStack(input)), + LogHelper.getStackDescription(toStack(input2)))); return; } - - RecipeSmelter recipe = ReflectionHelper.getInstance(ThermalHelper.smelterRecipe, toStack(input), toStack(input2), toStack(output), toStack(output2), chance, energy); - - if(recipe != null) { + + RecipeSmelter recipe = ReflectionHelper.getInstance( + ThermalHelper.smelterRecipe, + toStack(input), + toStack(input2), + toStack(output), + toStack(output2), + chance, + energy); + + if (recipe != null) { MineTweakerAPI.apply(new Add(recipe)); } else { LogHelper.logError(String.format("Error while creating instance for %s recipe.", name)); } - } + } - private static class Add extends BaseListAddition { - public Add(RecipeSmelter recipe) { - super(Smelter.name, null); - recipes.add(recipe); - } + private static class Add extends BaseListAddition { - @Override - public void apply() { - for(RecipeSmelter recipe : recipes) { - boolean applied = SmelterManager.addRecipe( - recipe.getEnergy(), - recipe.getPrimaryInput(), - recipe.getSecondaryInput(), - recipe.getPrimaryOutput(), - recipe.getSecondaryOutput(), - recipe.getSecondaryOutputChance()); - - if(applied) { - successful.add(recipe); - } - } - } + public Add(RecipeSmelter recipe) { + super(Smelter.name, null); + recipes.add(recipe); + } - @Override - public void undo() { - for(RecipeSmelter recipe : successful) { - SmelterManager.removeRecipe(recipe.getPrimaryInput(), recipe.getSecondaryInput()); - } - } - - @Override - protected boolean equals(RecipeSmelter recipe, RecipeSmelter otherRecipe) { - return ThermalHelper.equals(recipe, otherRecipe); - } + @Override + public void apply() { + for (RecipeSmelter recipe : recipes) { + boolean applied = SmelterManager.addRecipe( + recipe.getEnergy(), + recipe.getPrimaryInput(), + recipe.getSecondaryInput(), + recipe.getPrimaryOutput(), + recipe.getSecondaryOutput(), + recipe.getSecondaryOutputChance()); - @Override - public String getRecipeInfo(RecipeSmelter recipe) { - return LogHelper.getStackDescription(recipe.getPrimaryOutput()); - } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - @ZenMethod - public static void removeRecipe(IIngredient input2, IIngredient input1) { - List recipes = new LinkedList(); - - for(RecipeSmelter recipe : SmelterManager.getRecipeList()) { - if(recipe != null && matches(input1, toIItemStack(recipe.getPrimaryInput())) && matches(input2, toIItemStack(recipe.getSecondaryInput()))) { - recipes.add(recipe); + if (applied) { + successful.add(recipe); + } } } - - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new Remove(recipes)); - } else { - LogHelper.logWarning(String.format("No %s Recipes found for %s and %s.", name, input1.toString(), input2.toString())); + + @Override + public void undo() { + for (RecipeSmelter recipe : successful) { + SmelterManager.removeRecipe(recipe.getPrimaryInput(), recipe.getSecondaryInput()); + } } - } - private static class Remove extends BaseListRemoval { - - public Remove(List recipes) { - super(Smelter.name, null, recipes); - } - - @Override - public void apply() { - for(RecipeSmelter recipe : recipes) { - boolean removed = SmelterManager.removeRecipe(recipe.getPrimaryInput(), recipe.getSecondaryInput()); - - if(removed) { - successful.add(recipe); - } - } - } - - @Override - public void undo() { - for(RecipeSmelter recipe : recipes) { - SmelterManager.addRecipe( - recipe.getEnergy(), - recipe.getPrimaryInput(), - recipe.getSecondaryInput(), - recipe.getPrimaryOutput(), - recipe.getSecondaryOutput(), - recipe.getSecondaryOutputChance()); - } - } - @Override protected boolean equals(RecipeSmelter recipe, RecipeSmelter otherRecipe) { return ThermalHelper.equals(recipe, otherRecipe); @@ -154,9 +108,71 @@ public class Smelter { public String getRecipeInfo(RecipeSmelter recipe) { return LogHelper.getStackDescription(recipe.getPrimaryOutput()); } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + @ZenMethod + public static void removeRecipe(IIngredient input2, IIngredient input1) { + List recipes = new LinkedList(); + + for (RecipeSmelter recipe : SmelterManager.getRecipeList()) { + if (recipe != null && matches(input1, toIItemStack(recipe.getPrimaryInput())) + && matches(input2, toIItemStack(recipe.getSecondaryInput()))) { + recipes.add(recipe); + } + } + + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new Remove(recipes)); + } else { + LogHelper.logWarning( + String.format("No %s Recipes found for %s and %s.", name, input1.toString(), input2.toString())); + } + } + + private static class Remove extends BaseListRemoval { + + public Remove(List recipes) { + super(Smelter.name, null, recipes); + } + + @Override + public void apply() { + for (RecipeSmelter recipe : recipes) { + boolean removed = SmelterManager.removeRecipe(recipe.getPrimaryInput(), recipe.getSecondaryInput()); + + if (removed) { + successful.add(recipe); + } + } + } + + @Override + public void undo() { + for (RecipeSmelter recipe : recipes) { + SmelterManager.addRecipe( + recipe.getEnergy(), + recipe.getPrimaryInput(), + recipe.getSecondaryInput(), + recipe.getPrimaryOutput(), + recipe.getSecondaryOutput(), + recipe.getSecondaryOutputChance()); + } + } + + @Override + protected boolean equals(RecipeSmelter recipe, RecipeSmelter otherRecipe) { + return ThermalHelper.equals(recipe, otherRecipe); + } + + @Override + public String getRecipeInfo(RecipeSmelter recipe) { + return LogHelper.getStackDescription(recipe.getPrimaryOutput()); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @ZenMethod public static void refreshRecipes() { @@ -177,8 +193,7 @@ public class Smelter { return "Refreshing " + Smelter.name + " recipes"; } - public void undo() { - } + public void undo() {} public String describeUndo() { return "Ignoring undo of " + Smelter.name + " recipe refresh"; diff --git a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Transposer.java b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Transposer.java index 8c6b1e1..7864330 100644 --- a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Transposer.java +++ b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Transposer.java @@ -28,78 +28,114 @@ import cofh.thermalexpansion.util.crafting.TransposerManager.RecipeTransposer; @ZenClass("mods.thermalexpansion.Transposer") public class Transposer { - + public static final String nameFill = "Thermal Expansion Transposer (Fill)"; public static final String nameExtract = "Thermal Expansion Transposer (Extract)"; - + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - @ZenMethod - public static void addFillRecipe(int energy, IItemStack input, IItemStack output, ILiquidStack liquid) { - if(input == null || output == null || liquid == null) { + + @ZenMethod + public static void addFillRecipe(int energy, IItemStack input, IItemStack output, ILiquidStack liquid) { + if (input == null || output == null || liquid == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", nameFill)); return; } - - if(TransposerManager.fillRecipeExists(toStack(input), toFluid(liquid))) { - LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s and %s. Command ignored!", Transposer.nameFill, LogHelper.getStackDescription(toStack(input)), LogHelper.getStackDescription(toFluid(liquid)))); + + if (TransposerManager.fillRecipeExists(toStack(input), toFluid(liquid))) { + LogHelper.logWarning( + String.format( + "Duplicate %s Recipe found for %s and %s. Command ignored!", + Transposer.nameFill, + LogHelper.getStackDescription(toStack(input)), + LogHelper.getStackDescription(toFluid(liquid)))); return; } - - RecipeTransposer recipe = ReflectionHelper.getInstance(ThermalHelper.transposerRecipe, toStack(input), toStack(output), toFluid(liquid), energy, 100); - - if(recipe != null) { + + RecipeTransposer recipe = ReflectionHelper.getInstance( + ThermalHelper.transposerRecipe, + toStack(input), + toStack(output), + toFluid(liquid), + energy, + 100); + + if (recipe != null) { MineTweakerAPI.apply(new Add(recipe, RecipeType.Fill)); } else { LogHelper.logError(String.format("Error while creating instance for %s recipe.", nameFill)); } - } - - @ZenMethod - public static void addExtractRecipe(int energy, IItemStack input, ILiquidStack liquid, @Optional IItemStack output, @Optional int chance) { - if(input == null || output == null || liquid == null) { - LogHelper.logError(String.format("Required parameters missing for %s Recipe.", nameExtract)); - return; - } - - if(TransposerManager.extractionRecipeExists(toStack(input), toFluid(liquid))) { - LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s and %s. Command ignored!", Transposer.nameExtract, LogHelper.getStackDescription(toStack(input)), LogHelper.getStackDescription(toFluid(liquid)))); - return; - } - - RecipeTransposer recipe = ReflectionHelper.getInstance(ThermalHelper.transposerRecipe, toStack(input), toStack(output), toFluid(liquid), energy, 100); - - if(recipe != null) { - MineTweakerAPI.apply(new Add(recipe, RecipeType.Extract)); - } else { - LogHelper.logError(String.format("Error while creating instance for %s recipe.", nameExtract)); - } - } + } - //Deprecated - @ZenMethod - public static void addExtractRecipe(int energy, IItemStack input, IItemStack output, ILiquidStack liquid, int chance) { - if(input == null || output == null || liquid == null) { + @ZenMethod + public static void addExtractRecipe(int energy, IItemStack input, ILiquidStack liquid, @Optional IItemStack output, + @Optional int chance) { + if (input == null || output == null || liquid == null) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", nameExtract)); return; } - - if(TransposerManager.extractionRecipeExists(toStack(input), toFluid(liquid))) { - LogHelper.logWarning(String.format("Duplicate %s Recipe found for %s and %s. Command ignored!", Transposer.nameExtract, LogHelper.getStackDescription(toStack(input)), LogHelper.getStackDescription(toFluid(liquid)))); + + if (TransposerManager.extractionRecipeExists(toStack(input), toFluid(liquid))) { + LogHelper.logWarning( + String.format( + "Duplicate %s Recipe found for %s and %s. Command ignored!", + Transposer.nameExtract, + LogHelper.getStackDescription(toStack(input)), + LogHelper.getStackDescription(toFluid(liquid)))); return; } - - RecipeTransposer recipe = ReflectionHelper.getInstance(ThermalHelper.transposerRecipe, toStack(input), toStack(output), toFluid(liquid), energy, 100); - - if(recipe != null) { + + RecipeTransposer recipe = ReflectionHelper.getInstance( + ThermalHelper.transposerRecipe, + toStack(input), + toStack(output), + toFluid(liquid), + energy, + 100); + + if (recipe != null) { MineTweakerAPI.apply(new Add(recipe, RecipeType.Extract)); } else { LogHelper.logError(String.format("Error while creating instance for %s recipe.", nameExtract)); } - } - - private static class Add extends BaseListAddition { - private RecipeType type; + } + + // Deprecated + @ZenMethod + public static void addExtractRecipe(int energy, IItemStack input, IItemStack output, ILiquidStack liquid, + int chance) { + if (input == null || output == null || liquid == null) { + LogHelper.logError(String.format("Required parameters missing for %s Recipe.", nameExtract)); + return; + } + + if (TransposerManager.extractionRecipeExists(toStack(input), toFluid(liquid))) { + LogHelper.logWarning( + String.format( + "Duplicate %s Recipe found for %s and %s. Command ignored!", + Transposer.nameExtract, + LogHelper.getStackDescription(toStack(input)), + LogHelper.getStackDescription(toFluid(liquid)))); + return; + } + + RecipeTransposer recipe = ReflectionHelper.getInstance( + ThermalHelper.transposerRecipe, + toStack(input), + toStack(output), + toFluid(liquid), + energy, + 100); + + if (recipe != null) { + MineTweakerAPI.apply(new Add(recipe, RecipeType.Extract)); + } else { + LogHelper.logError(String.format("Error while creating instance for %s recipe.", nameExtract)); + } + } + + private static class Add extends BaseListAddition { + + private RecipeType type; protected Add(RecipeTransposer recipe, RecipeType type) { super(type == RecipeType.Fill ? Transposer.nameFill : Transposer.nameExtract, null); @@ -109,9 +145,9 @@ public class Transposer { @Override public void apply() { - for(RecipeTransposer recipe : recipes) { + for (RecipeTransposer recipe : recipes) { boolean applied = false; - switch(type) { + switch (type) { case Fill: applied = TransposerManager.addFillRecipe( recipe.getEnergy(), @@ -120,11 +156,11 @@ public class Transposer { recipe.getFluid(), false); break; - + case Extract: applied = TransposerManager.addExtractionRecipe( recipe.getEnergy(), - recipe.getInput(), + recipe.getInput(), recipe.getOutput(), recipe.getFluid(), recipe.getChance(), @@ -132,17 +168,16 @@ public class Transposer { break; } - if(applied) { + if (applied) { successful.add(recipe); } } } - + @Override public void undo() { - for(RecipeTransposer recipe : successful) { - switch(type) - { + for (RecipeTransposer recipe : successful) { + switch (type) { case Fill: TransposerManager.removeFillRecipe(recipe.getInput(), recipe.getFluid()); break; @@ -152,59 +187,67 @@ public class Transposer { } } } - + @Override protected boolean equals(RecipeTransposer recipe, RecipeTransposer otherRecipe) { return ThermalHelper.equals(recipe, otherRecipe); } - + @Override protected String getRecipeInfo(RecipeTransposer recipe) { return LogHelper.getStackDescription(recipe.getInput()); } - } + } - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - @ZenMethod - public static void removeFillRecipe(IIngredient input, IIngredient liquid) { - removeRecipe(input, liquid, RecipeType.Fill); - } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - @ZenMethod - public static void removeExtractRecipe(IIngredient input) { - removeRecipe(input, IngredientAny.INSTANCE, RecipeType.Extract); - } + @ZenMethod + public static void removeFillRecipe(IIngredient input, IIngredient liquid) { + removeRecipe(input, liquid, RecipeType.Fill); + } - public static void removeRecipe(IIngredient input, IIngredient liquid, RecipeType type) { + @ZenMethod + public static void removeExtractRecipe(IIngredient input) { + removeRecipe(input, IngredientAny.INSTANCE, RecipeType.Extract); + } + + public static void removeRecipe(IIngredient input, IIngredient liquid, RecipeType type) { List recipes = new LinkedList(); - - for(RecipeTransposer recipe : type == RecipeType.Fill ? TransposerManager.getFillRecipeList() : TransposerManager.getExtractionRecipeList()) { - if(recipe != null && matches(input, toIItemStack(recipe.getInput())) && matches(liquid, toILiquidStack(recipe.getFluid()))) { + + for (RecipeTransposer recipe : type == RecipeType.Fill ? TransposerManager.getFillRecipeList() + : TransposerManager.getExtractionRecipeList()) { + if (recipe != null && matches(input, toIItemStack(recipe.getInput())) + && matches(liquid, toILiquidStack(recipe.getFluid()))) { recipes.add(recipe); } } - - if(!recipes.isEmpty()) { + + if (!recipes.isEmpty()) { MineTweakerAPI.apply(new Remove(recipes, type)); } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s and %s.", type == RecipeType.Fill ? Transposer.nameFill : Transposer.nameExtract, input.toString(), liquid.toString())); + LogHelper.logWarning( + String.format( + "No %s Recipe found for %s and %s.", + type == RecipeType.Fill ? Transposer.nameFill : Transposer.nameExtract, + input.toString(), + liquid.toString())); } - } + } + + private static class Remove extends BaseListRemoval { + + private RecipeType type; - private static class Remove extends BaseListRemoval { - private RecipeType type; - protected Remove(List recipes, RecipeType type) { super(type == RecipeType.Fill ? Transposer.nameFill : Transposer.nameExtract, null, recipes); this.type = type; } - + @Override public void apply() { - for(RecipeTransposer recipe : recipes) { + for (RecipeTransposer recipe : recipes) { boolean removed = false; - switch(type) { + switch (type) { case Fill: removed = TransposerManager.removeFillRecipe(recipe.getInput(), recipe.getFluid()); break; @@ -212,35 +255,35 @@ public class Transposer { removed = TransposerManager.removeExtractionRecipe(recipe.getInput()); break; } - - if(removed) { + + if (removed) { successful.add(recipe); } } } - + @Override public void undo() { - for(RecipeTransposer recipe : successful) { - switch(type) { - case Fill: - TransposerManager.addFillRecipe( - recipe.getEnergy(), - recipe.getInput(), - recipe.getOutput(), - recipe.getFluid(), - false); - break; - - case Extract: - TransposerManager.addExtractionRecipe( - recipe.getEnergy(), - recipe.getInput(), - recipe.getOutput(), - recipe.getFluid(), - recipe.getChance(), - false); - break; + for (RecipeTransposer recipe : successful) { + switch (type) { + case Fill: + TransposerManager.addFillRecipe( + recipe.getEnergy(), + recipe.getInput(), + recipe.getOutput(), + recipe.getFluid(), + false); + break; + + case Extract: + TransposerManager.addExtractionRecipe( + recipe.getEnergy(), + recipe.getInput(), + recipe.getOutput(), + recipe.getFluid(), + recipe.getChance(), + false); + break; } } } @@ -249,19 +292,19 @@ public class Transposer { protected boolean equals(RecipeTransposer recipe, RecipeTransposer otherRecipe) { return ThermalHelper.equals(recipe, otherRecipe); } - + @Override protected String getRecipeInfo(RecipeTransposer recipe) { return LogHelper.getStackDescription(recipe.getOutput()); } - } - + } + protected enum RecipeType { Fill, Extract } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @ZenMethod public static void refreshRecipes() { @@ -282,8 +325,7 @@ public class Transposer { return "Refreshing " + Transposer.nameFill + " & " + Transposer.nameExtract + " recipes"; } - public void undo() { - } + public void undo() {} public String describeUndo() { return "Ignoring undo of " + Transposer.nameFill + " & " + Transposer.nameExtract + " recipe refresh"; diff --git a/src/main/java/modtweaker2/proxy/ClientProxy.java b/src/main/java/modtweaker2/proxy/ClientProxy.java index 03fc8f6..cfd21fd 100644 --- a/src/main/java/modtweaker2/proxy/ClientProxy.java +++ b/src/main/java/modtweaker2/proxy/ClientProxy.java @@ -2,11 +2,11 @@ package modtweaker2.proxy; import modtweaker2.Commands; -public class ClientProxy extends CommonProxy{ - - @Override - public void registerCommands() { - Commands.registerCommands(); - } +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 index e25b202..8876b7d 100644 --- a/src/main/java/modtweaker2/proxy/CommonProxy.java +++ b/src/main/java/modtweaker2/proxy/CommonProxy.java @@ -3,9 +3,9 @@ package modtweaker2.proxy; import modtweaker2.Commands; public class CommonProxy { - - public void registerCommands(){ - Commands.registerCommands(); - } + + public void registerCommands() { + Commands.registerCommands(); + } } diff --git a/src/main/java/modtweaker2/utils/ArrayUtils.java b/src/main/java/modtweaker2/utils/ArrayUtils.java index 3297f67..8c43ce1 100644 --- a/src/main/java/modtweaker2/utils/ArrayUtils.java +++ b/src/main/java/modtweaker2/utils/ArrayUtils.java @@ -4,14 +4,12 @@ import java.util.ArrayList; public class ArrayUtils { - - public static ArrayList toArrayList(E[] array) { - ArrayList list = new ArrayList(); - for (E e : array) { - list.add(e); - } - return list; - } - + public static ArrayList toArrayList(E[] array) { + ArrayList list = new ArrayList(); + for (E e : array) { + list.add(e); + } + return list; + } } diff --git a/src/main/java/modtweaker2/utils/BaseCraftingAddition.java b/src/main/java/modtweaker2/utils/BaseCraftingAddition.java index b33a1e1..421f38c 100644 --- a/src/main/java/modtweaker2/utils/BaseCraftingAddition.java +++ b/src/main/java/modtweaker2/utils/BaseCraftingAddition.java @@ -3,6 +3,7 @@ package modtweaker2.utils; import java.util.List; import modtweaker2.helpers.LogHelper; + import net.minecraft.item.crafting.IRecipe; public abstract class BaseCraftingAddition extends BaseListAddition { @@ -10,11 +11,11 @@ public abstract class BaseCraftingAddition extends BaseListAddition { protected BaseCraftingAddition(String name, List list) { super(name, list); } - + protected BaseCraftingAddition(String name, List list, List recipes) { super(name, list, recipes); } - + @Override protected String getRecipeInfo(IRecipe recipe) { return LogHelper.getStackDescription(recipe.getRecipeOutput()); diff --git a/src/main/java/modtweaker2/utils/BaseCraftingRemoval.java b/src/main/java/modtweaker2/utils/BaseCraftingRemoval.java index 3cfa78e..b6f6477 100644 --- a/src/main/java/modtweaker2/utils/BaseCraftingRemoval.java +++ b/src/main/java/modtweaker2/utils/BaseCraftingRemoval.java @@ -8,28 +8,32 @@ import java.util.List; import minetweaker.api.item.IIngredient; import modtweaker2.helpers.LogHelper; + import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; public class BaseCraftingRemoval extends BaseListRemoval { - public BaseCraftingRemoval(String name, List list, List recipes) { - super(name, list, recipes); - } - + + public BaseCraftingRemoval(String name, List list, List recipes) { + super(name, list, recipes); + } + @Override public String getRecipeInfo(IRecipe recipe) { return LogHelper.getStackDescription(recipe.getRecipeOutput()); } - + public static List getRecipes(List list, IIngredient ingredient) { List recipes = new LinkedList(); - + for (IRecipe r : list) { - if (r != null && r.getRecipeOutput() != null && r.getRecipeOutput() instanceof ItemStack && matches(ingredient, toIItemStack(r.getRecipeOutput()))) { + if (r != null && r.getRecipeOutput() != null + && r.getRecipeOutput() instanceof ItemStack + && matches(ingredient, toIItemStack(r.getRecipeOutput()))) { recipes.add(r); } } - + return recipes; } -} \ No newline at end of file +} diff --git a/src/main/java/modtweaker2/utils/BaseListAddition.java b/src/main/java/modtweaker2/utils/BaseListAddition.java index 9e16460..0bc48d0 100644 --- a/src/main/java/modtweaker2/utils/BaseListAddition.java +++ b/src/main/java/modtweaker2/utils/BaseListAddition.java @@ -9,23 +9,23 @@ public abstract class BaseListAddition extends BaseListModification { protected BaseListAddition(String name, List list) { super(name, list); } - + protected BaseListAddition(String name, List list, List recipies) { this(name, list); - if(recipes != null) { + if (recipes != null) { recipes.addAll(recipies); } } @Override public void apply() { - if(recipes.isEmpty()) { + if (recipes.isEmpty()) { return; } - for(T recipe : recipes) { - if(recipe != null) { - if(list.add(recipe)) { + for (T recipe : recipes) { + if (recipe != null) { + if (list.add(recipe)) { successful.add(recipe); } else { LogHelper.logError(String.format("Error adding %s Recipe for %s", name, getRecipeInfo(recipe))); @@ -35,17 +35,18 @@ public abstract class BaseListAddition extends BaseListModification { } } } - + @Override public void undo() { - if(this.successful.isEmpty()) { + if (this.successful.isEmpty()) { return; } - - for(T recipe : successful) { - if(recipe != null) { - if(!list.remove(recipe)) { - LogHelper.logError(String.format("Error removing %s Recipe for %s", name, this.getRecipeInfo(recipe))); + + for (T recipe : successful) { + if (recipe != null) { + if (!list.remove(recipe)) { + LogHelper.logError( + String.format("Error removing %s Recipe for %s", name, this.getRecipeInfo(recipe))); } } else { LogHelper.logError(String.format("Error removing %s Recipe: null object", name)); @@ -62,4 +63,4 @@ public abstract class BaseListAddition extends BaseListModification { public String describeUndo() { return String.format("[ModTweaker2] Removing %d %s Recipe(s) for %s", recipes.size(), name, getRecipeInfo()); } -} \ No newline at end of file +} diff --git a/src/main/java/modtweaker2/utils/BaseListModification.java b/src/main/java/modtweaker2/utils/BaseListModification.java index f9798c7..7c196b9 100644 --- a/src/main/java/modtweaker2/utils/BaseListModification.java +++ b/src/main/java/modtweaker2/utils/BaseListModification.java @@ -4,98 +4,91 @@ import java.util.LinkedList; import java.util.List; public abstract class BaseListModification extends BaseUndoable { + protected final List list; - protected final LinkedList recipes; - protected final LinkedList successful; - - protected BaseListModification(String name, List list) { - super(name); - this.list = list; - this.recipes = new LinkedList(); - this.successful = new LinkedList(); - } - - @Override + protected final LinkedList recipes; + protected final LinkedList successful; + + protected BaseListModification(String name, List list) { + super(name); + this.list = list; + this.recipes = new LinkedList(); + this.successful = new LinkedList(); + } + + @Override public boolean canUndo() { - if(recipes.isEmpty() || successful.isEmpty()) - return false; - + if (recipes.isEmpty() || successful.isEmpty()) return false; + return true; } - - @Override - protected String getRecipeInfo() { - if(!recipes.isEmpty()) - { - StringBuilder sb = new StringBuilder(); - for(T recipe : recipes) { - if(recipe != null) { - sb.append(getRecipeInfo(recipe)).append(", "); - } - } - - if(sb.length() > 0 ) { - sb.setLength(sb.length() - 2); - } - - return sb.toString(); - } - - return super.getRecipeInfo(); - } - - /** - * This method must be overwritten by the extending classes. It should return - * the name of the key item, for which the recipe is for. For example for machines - * which produce new items, it should return the name of the ouput. For machines - * which are processing items (like a pulverizer) it should return the name of the - * the input. Another example would be the name of the enchantmant for a thaumcraft - * infusion recipe. - */ + + @Override + protected String getRecipeInfo() { + if (!recipes.isEmpty()) { + StringBuilder sb = new StringBuilder(); + for (T recipe : recipes) { + if (recipe != null) { + sb.append(getRecipeInfo(recipe)).append(", "); + } + } + + if (sb.length() > 0) { + sb.setLength(sb.length() - 2); + } + + return sb.toString(); + } + + return super.getRecipeInfo(); + } + + /** + * This method must be overwritten by the extending classes. It should return the name of the key item, for which + * the recipe is for. For example for machines which produce new items, it should return the name of the ouput. For + * machines which are processing items (like a pulverizer) it should return the name of the the input. Another + * example would be the name of the enchantmant for a thaumcraft infusion recipe. + */ protected abstract String getRecipeInfo(T recipe); - + @Override public int hashCode() { return 37 * super.hashCode() ^ (list != null ? 43 * list.hashCode() : 0); } - + @Override public boolean equals(Object obj) { - if(obj == this) - return true; - - if (obj == null) - return false; - + if (obj == this) return true; + + if (obj == null) return false; + // Do both actions have the same base? - if(!super.equals(obj)) - return false; - - if (!(obj instanceof BaseListModification)) - return false; - - BaseListModification mod = (BaseListModification)obj; + if (!super.equals(obj)) return false; + + if (!(obj instanceof BaseListModification)) return false; + + BaseListModification mod = (BaseListModification) obj; // Do both actions reference the same list? - if(this.list != mod.list) { + if (this.list != mod.list) { return false; } - + // Do both actions contain the same recipes? - if(recipes.size() != mod.recipes.size()) { + if (recipes.size() != mod.recipes.size()) { return false; } - - for(T recipe : recipes) { + + for (T recipe : recipes) { boolean found = false; - for(T otherRecipe : (List)mod.recipes) { - if(equals(recipe, otherRecipe)) { + for (T otherRecipe : (List) mod.recipes) { + if (equals(recipe, otherRecipe)) { found = true; break; } } - if(!found) { + if (!found) { return false; } } @@ -104,19 +97,18 @@ public abstract class BaseListModification extends BaseUndoable { } /** - * Compares two recipes if they are equal. If the mod does not overwrite equals() in - * their recipe object, this method should be overwritten by the extending classes to - * add a custom equals method + * Compares two recipes if they are equal. If the mod does not overwrite equals() in their recipe object, this + * method should be overwritten by the extending classes to add a custom equals method */ protected boolean equals(T recipe, T otherRecipe) { - if(recipe == otherRecipe) { + if (recipe == otherRecipe) { return true; } - - if(!recipe.equals(otherRecipe)) { + + if (!recipe.equals(otherRecipe)) { return false; } - + return true; } -} \ No newline at end of file +} diff --git a/src/main/java/modtweaker2/utils/BaseListRemoval.java b/src/main/java/modtweaker2/utils/BaseListRemoval.java index 06f0518..4fc1e8c 100644 --- a/src/main/java/modtweaker2/utils/BaseListRemoval.java +++ b/src/main/java/modtweaker2/utils/BaseListRemoval.java @@ -5,28 +5,28 @@ import java.util.List; import modtweaker2.helpers.LogHelper; public abstract class BaseListRemoval extends BaseListModification { - + protected BaseListRemoval(String name, List list) { super(name, list); } - + protected BaseListRemoval(String name, List list, List recipies) { this(name, list); - - if(recipes != null) { + + if (recipes != null) { recipes.addAll(recipies); } } - + @Override public void apply() { - if(recipes.isEmpty()) { + if (recipes.isEmpty()) { return; } - - for(T recipe : this.recipes) { - if(recipe != null) { - if(this.list.remove(recipe)) { + + for (T recipe : this.recipes) { + if (recipe != null) { + if (this.list.remove(recipe)) { successful.add(recipe); } else { LogHelper.logError(String.format("Error removing %s Recipe for %s", name, getRecipeInfo(recipe))); @@ -36,15 +36,15 @@ public abstract class BaseListRemoval extends BaseListModification { } } } - + @Override public void undo() { - if(successful.isEmpty()) { + if (successful.isEmpty()) { return; } - for(T recipe : successful) { - if(recipe != null) { - if(!list.add(recipe)) { + for (T recipe : successful) { + if (recipe != null) { + if (!list.add(recipe)) { LogHelper.logError(String.format("Error restoring %s Recipe for %s", name, getRecipeInfo(recipe))); } } else { @@ -55,11 +55,19 @@ public abstract class BaseListRemoval extends BaseListModification { @Override public String describe() { - return String.format("[ModTweaker2] Removing %d %s Recipe(s) for %s", this.recipes.size(), this.name, this.getRecipeInfo()); + return String.format( + "[ModTweaker2] Removing %d %s Recipe(s) for %s", + this.recipes.size(), + this.name, + this.getRecipeInfo()); } @Override public String describeUndo() { - return String.format("[ModTweaker2] Restoring %d %s Recipe(s) for %s", this.recipes.size(), this.name, this.getRecipeInfo()); + return String.format( + "[ModTweaker2] Restoring %d %s Recipe(s) for %s", + this.recipes.size(), + this.name, + this.getRecipeInfo()); } -} \ No newline at end of file +} diff --git a/src/main/java/modtweaker2/utils/BaseMapAddition.java b/src/main/java/modtweaker2/utils/BaseMapAddition.java index 67bbfca..e571589 100644 --- a/src/main/java/modtweaker2/utils/BaseMapAddition.java +++ b/src/main/java/modtweaker2/utils/BaseMapAddition.java @@ -8,14 +8,14 @@ import java.util.Map.Entry; import modtweaker2.helpers.LogHelper; public abstract class BaseMapAddition extends BaseMapModification { - + protected final HashMap overwritten; - + protected BaseMapAddition(String name, Map map) { super(name, map); this.overwritten = new HashMap(); } - + protected BaseMapAddition(String name, Map map, Map recipes) { this(name, map); this.recipes.putAll(recipes); @@ -23,44 +23,50 @@ public abstract class BaseMapAddition extends BaseMapModification { @Override public void apply() { - if(recipes.isEmpty()) - return; - - for(Entry entry : recipes.entrySet()) { + if (recipes.isEmpty()) return; + + for (Entry entry : recipes.entrySet()) { K key = entry.getKey(); V value = entry.getValue(); V oldValue = map.put(key, value); - - if(oldValue != null) { - LogHelper.logWarning(String.format("Overwritten %s Recipe for %s", name, getRecipeInfo( new AbstractMap.SimpleEntry(entry.getKey(), value)))); + + if (oldValue != null) { + LogHelper.logWarning( + String.format( + "Overwritten %s Recipe for %s", + name, + getRecipeInfo(new AbstractMap.SimpleEntry(entry.getKey(), value)))); overwritten.put(key, oldValue); } - + successful.put(key, value); } } @Override public void undo() { - if(successful.isEmpty() && overwritten.isEmpty()) - return; + if (successful.isEmpty() && overwritten.isEmpty()) return; - for(Entry entry : successful.entrySet()) { + for (Entry entry : successful.entrySet()) { K key = entry.getKey(); V value = map.remove(key); - if(value == null) { + if (value == null) { LogHelper.logError(String.format("Error removing %s Recipe: null object", name)); } } - - for(Entry entry : overwritten.entrySet()) { + + for (Entry entry : overwritten.entrySet()) { K key = entry.getKey(); V value = entry.getValue(); V oldValue = map.put(key, value); - - if(oldValue != null) { - LogHelper.logWarning(String.format("Overwritten %s Recipe which should not exist for %s", name, getRecipeInfo(new AbstractMap.SimpleEntry(entry.getKey(), value)))); + + if (oldValue != null) { + LogHelper.logWarning( + String.format( + "Overwritten %s Recipe which should not exist for %s", + name, + getRecipeInfo(new AbstractMap.SimpleEntry(entry.getKey(), value)))); } } } diff --git a/src/main/java/modtweaker2/utils/BaseMapModification.java b/src/main/java/modtweaker2/utils/BaseMapModification.java index ac71c80..9d4fc1d 100644 --- a/src/main/java/modtweaker2/utils/BaseMapModification.java +++ b/src/main/java/modtweaker2/utils/BaseMapModification.java @@ -5,10 +5,11 @@ import java.util.Map; import java.util.Map.Entry; public abstract class BaseMapModification extends BaseUndoable { + protected Map map; protected final HashMap recipes; protected final HashMap successful; - + protected BaseMapModification(String name, Map map) { super(name); this.map = map; @@ -20,35 +21,32 @@ public abstract class BaseMapModification extends BaseUndoable { public boolean canUndo() { return !recipes.isEmpty(); } - + @Override protected String getRecipeInfo() { - if(!recipes.isEmpty()) - { + if (!recipes.isEmpty()) { StringBuilder sb = new StringBuilder(); - for(Entry recipe : recipes.entrySet()) { - if(recipe != null) { + for (Entry recipe : recipes.entrySet()) { + if (recipe != null) { sb.append(getRecipeInfo(recipe)).append(", "); } } - - if(sb.length() > 0) { + + if (sb.length() > 0) { sb.setLength(sb.length() - 2); } - + return sb.toString(); } - + return super.getRecipeInfo(); } - + /** - * This method must be overwritten by the extending classes. It should return - * the name of the key item, for which the recipe is for. For example for machines - * which produce new items, it should return the name of the ouput. For machines - * which are processing items (like a pulverizer) it should return the name of the - * the input. Another example would be the name of the enchantmant for a thaumcraft - * infusion recipe. + * This method must be overwritten by the extending classes. It should return the name of the key item, for which + * the recipe is for. For example for machines which produce new items, it should return the name of the ouput. For + * machines which are processing items (like a pulverizer) it should return the name of the the input. Another + * example would be the name of the enchantmant for a thaumcraft infusion recipe. */ protected abstract String getRecipeInfo(Entry recipe); } diff --git a/src/main/java/modtweaker2/utils/BaseMapRemoval.java b/src/main/java/modtweaker2/utils/BaseMapRemoval.java index dcdc9ce..27d073d 100644 --- a/src/main/java/modtweaker2/utils/BaseMapRemoval.java +++ b/src/main/java/modtweaker2/utils/BaseMapRemoval.java @@ -6,50 +6,49 @@ import java.util.Map.Entry; import modtweaker2.helpers.LogHelper; public abstract class BaseMapRemoval extends BaseMapModification { - + protected BaseMapRemoval(String name, Map map) { super(name, map); } - + protected BaseMapRemoval(String name, Map map, Map recipes) { this(name, map); - - if(recipes != null) { + + if (recipes != null) { this.recipes.putAll(recipes); } } @Override public void apply() { - if(recipes.isEmpty()) - return; - - for(K key : recipes.keySet()) { + if (recipes.isEmpty()) return; + + for (K key : recipes.keySet()) { V oldValue = map.remove(key); - - if(oldValue != null) { + + if (oldValue != null) { successful.put(key, oldValue); } else { LogHelper.logError(String.format("Error removing %s Recipe : null object", name)); } } } - + @Override public void undo() { - if(successful.isEmpty()) - return; - - for(Entry entry : successful.entrySet()) { - if(entry != null) { + if (successful.isEmpty()) return; + + for (Entry entry : successful.entrySet()) { + if (entry != null) { V oldValue = map.put(entry.getKey(), entry.getValue()); - if(oldValue != null) { - LogHelper.logWarning(String.format("Overwritten %s Recipe for %s while restoring.", name, getRecipeInfo(entry))); + if (oldValue != null) { + LogHelper.logWarning( + String.format("Overwritten %s Recipe for %s while restoring.", name, getRecipeInfo(entry))); } } } } - + @Override public String describe() { return String.format("[ModTweaker2] Removing %d %s Recipe(s) for %s", recipes.size(), name, getRecipeInfo()); diff --git a/src/main/java/modtweaker2/utils/BaseMultiModification.java b/src/main/java/modtweaker2/utils/BaseMultiModification.java index c8fd478..7105aaa 100644 --- a/src/main/java/modtweaker2/utils/BaseMultiModification.java +++ b/src/main/java/modtweaker2/utils/BaseMultiModification.java @@ -7,7 +7,7 @@ import minetweaker.IUndoableAction; public class BaseMultiModification extends BaseUndoable { protected final LinkedList actions; - + protected BaseMultiModification(String name) { super(name); this.actions = new LinkedList(); @@ -15,16 +15,15 @@ public class BaseMultiModification extends BaseUndoable { @Override public void apply() { - for(IUndoableAction action : actions) { + for (IUndoableAction action : actions) { action.apply(); } } @Override public boolean canUndo() { - for(IUndoableAction action : actions) { - if(!action.canUndo()) - return false; + for (IUndoableAction action : actions) { + if (!action.canUndo()) return false; } return true; @@ -42,7 +41,7 @@ public class BaseMultiModification extends BaseUndoable { @Override public void undo() { - for(IUndoableAction action : actions) { + for (IUndoableAction action : actions) { action.undo(); } } diff --git a/src/main/java/modtweaker2/utils/BaseUndoable.java b/src/main/java/modtweaker2/utils/BaseUndoable.java index a6cf6e1..d72b48e 100644 --- a/src/main/java/modtweaker2/utils/BaseUndoable.java +++ b/src/main/java/modtweaker2/utils/BaseUndoable.java @@ -4,59 +4,57 @@ import minetweaker.IUndoableAction; public abstract class BaseUndoable implements IUndoableAction { - // Holds the name of the mod / machine this action manipulates - protected final String name; - - // Basic indicator, if the action was successful and can be reverted - protected boolean success = false; + // Holds the name of the mod / machine this action manipulates + protected final String name; + + // Basic indicator, if the action was successful and can be reverted + protected boolean success = false; + + protected BaseUndoable(String name) { + this.name = name; + } + + protected String getRecipeInfo() { + return "Unknown item"; + } + + @Override + public boolean canUndo() { + return success; + } + + @Override + public String describe() { + return String.format("[ModTweaker2] Altering %s Recipe(s) for %s", this.name, this.getRecipeInfo()); + } - protected BaseUndoable(String name) { - this.name = name; - } - - protected String getRecipeInfo() { - return "Unknown item"; - } - - @Override - public boolean canUndo() { - return success; - } - - @Override - public String describe() { - return String.format("[ModTweaker2] Altering %s Recipe(s) for %s", this.name, this.getRecipeInfo()); - } - @Override public String describeUndo() { return String.format("[ModTweaker2] Reverting %s Recipe(s) changes for %s", this.name, this.getRecipeInfo()); } - - @Override - public boolean equals(Object obj) { - if (obj == null) - return false; - - if(!(obj instanceof BaseUndoable)) { - return false; - } - - BaseUndoable u = (BaseUndoable)obj; - - if(!name.equals(u.name)) - return false; - - return true; - } - - @Override - public int hashCode() { - return name.hashCode(); - } - + + @Override + public boolean equals(Object obj) { + if (obj == null) return false; + + if (!(obj instanceof BaseUndoable)) { + return false; + } + + BaseUndoable u = (BaseUndoable) obj; + + if (!name.equals(u.name)) return false; + + return true; + } + + @Override + public int hashCode() { + return name.hashCode(); + } + @Override public Object getOverrideKey() { return null; } -} \ No newline at end of file +} diff --git a/src/main/java/modtweaker2/utils/TweakerPlugin.java b/src/main/java/modtweaker2/utils/TweakerPlugin.java index f839e1b..1a08747 100644 --- a/src/main/java/modtweaker2/utils/TweakerPlugin.java +++ b/src/main/java/modtweaker2/utils/TweakerPlugin.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import cpw.mods.fml.common.Loader; public class TweakerPlugin { + private static ArrayList isLoaded = new ArrayList(); public static void register(String mod, Class clazz) { @@ -25,5 +26,5 @@ public class TweakerPlugin { public static boolean isLoaded(String string) { return isLoaded.contains(string); } - + }