From 7f9c6e6c5fdefeadbfbcc9f4dc92ab715921f779 Mon Sep 17 00:00:00 2001 From: jaredlll08 Date: Mon, 17 Aug 2015 00:00:17 +0200 Subject: [PATCH] IC2C MetalFormerCutting --- .../mods/ic2c/mods/MetalFormerCutting.java | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 src/main/java/modtweaker2/mods/ic2c/mods/MetalFormerCutting.java diff --git a/src/main/java/modtweaker2/mods/ic2c/mods/MetalFormerCutting.java b/src/main/java/modtweaker2/mods/ic2c/mods/MetalFormerCutting.java new file mode 100644 index 0000000..ab90ef5 --- /dev/null +++ b/src/main/java/modtweaker2/mods/ic2c/mods/MetalFormerCutting.java @@ -0,0 +1,69 @@ +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 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; + +@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))); + } + + 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)); + } + + @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)); + } + + private static class Remove extends BaseMapRemoval { + + protected Remove(Map recipes) { + super("MetalFormerCutting", Recipes.metalformerCutting.getRecipes(), recipes); + } + + @Override + protected String getRecipeInfo(Entry recipe) { + return recipe.toString(); + } + + } + +}