From 9a431f4d407158428ff9a90e7858074bfb136735 Mon Sep 17 00:00:00 2001 From: Tobias Wohlfarth Date: Thu, 1 Oct 2015 12:59:04 +0200 Subject: [PATCH] fix #242 and #245 : ExtraUtilities Q.E.D. - OreDict Support and removeRecipe(<*>) --- .../mods/extraUtils/handlers/QED.java | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/main/java/modtweaker2/mods/extraUtils/handlers/QED.java b/src/main/java/modtweaker2/mods/extraUtils/handlers/QED.java index 7ce123c..2321e73 100644 --- a/src/main/java/modtweaker2/mods/extraUtils/handlers/QED.java +++ b/src/main/java/modtweaker2/mods/extraUtils/handlers/QED.java @@ -3,6 +3,7 @@ package modtweaker2.mods.extraUtils.handlers; import java.util.LinkedList; import minetweaker.MineTweakerAPI; +import minetweaker.api.item.IIngredient; import minetweaker.api.item.IItemStack; import modtweaker2.helpers.InputHelper; import modtweaker2.helpers.LogHelper; @@ -10,17 +11,21 @@ import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; 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; 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."; + @ZenMethod - public static void addShapedRecipe(IItemStack output, IItemStack[][] recipe) { + public static void addShapedRecipe(IItemStack output, IIngredient[][] recipe) { MineTweakerAPI.apply(new Add(new ShapedOreRecipe(InputHelper.toStack(output), InputHelper.toShapedObjects(recipe)))); } @@ -35,39 +40,35 @@ public class QED { protected String getRecipeInfo(IRecipe recipe) { return recipe.toString(); } - } @ZenMethod - public static void removeRecipe(IItemStack toRemove) { - if (toRemove == null) { - LogHelper.logError(String.format("Required parameters missing for %s Recipe.", "QED")); - return; - } + public static void removeRecipe(IIngredient output) { LinkedList recipes = new LinkedList(); for (IRecipe recipe : EnderConstructorRecipesHandler.recipes) { - if (recipe != null && recipe.getRecipeOutput() != null && recipe.getRecipeOutput().isItemEqual(InputHelper.toStack(toRemove))) { + if (recipe != null && recipe.getRecipeOutput() != null && matches(output, toIItemStack(recipe.getRecipeOutput()))) { recipes.add(recipe); } } - MineTweakerAPI.apply(new Remove(recipes)); - + 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))); + } } public static class Remove extends BaseListRemoval { protected Remove(LinkedList stacks) { super("QED", EnderConstructorRecipesHandler.recipes, stacks); - } @Override protected String getRecipeInfo(IRecipe recipe) { return recipe.toString(); } - } }