From c0df1733daa8fce69e5db11c6e95bcdca7d69fbf Mon Sep 17 00:00:00 2001 From: Tobias Wohlfarth Date: Mon, 20 Jul 2015 00:17:44 +0200 Subject: [PATCH] imporved: Forestry Carpenter modified: src/main/java/modtweaker2/mods/forestry/handlers/Carpenter.java --- .../mods/forestry/handlers/Carpenter.java | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/main/java/modtweaker2/mods/forestry/handlers/Carpenter.java b/src/main/java/modtweaker2/mods/forestry/handlers/Carpenter.java index ee499ce..c5756d6 100644 --- a/src/main/java/modtweaker2/mods/forestry/handlers/Carpenter.java +++ b/src/main/java/modtweaker2/mods/forestry/handlers/Carpenter.java @@ -2,8 +2,10 @@ 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.StackHelper.matches; import java.util.ArrayList; @@ -20,6 +22,7 @@ import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import stanhebben.zenscript.annotations.Optional; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; import forestry.core.utils.ShapedRecipeCustom; @@ -34,6 +37,20 @@ public class Carpenter { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /** + * Adds a shaped recipe for the Carpenter + * + * @param output recipe output + * @param fluidInput recipe fluid amount + * @param ingredients recipe ingredients + * @param packagingTime time per crafting operation + * @param box recipes casting item (optional) + */ + @ZenMethod + public static void addRecipe(IItemStack output, int packagingTime, IIngredient[][] ingredients, @Optional ILiquidStack fluidInput, @Optional IItemStack box) { + MineTweakerAPI.apply(new Add(new Recipe(packagingTime, toFluid(fluidInput), toStack(box), ShapedRecipeCustom.createShapedRecipe(toStack(output), toShapedObjects(ingredients)) ))); + } + @ZenMethod public static void addRecipe(int packagingTime, ILiquidStack liquid, IItemStack[] ingredients, IItemStack ingredient, IItemStack product) { ArrayList stacks = new ArrayList(); @@ -78,13 +95,23 @@ public class Carpenter { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /** + * Removes a recipe for the Carpenter + * + * @param ingredient item input + */ @ZenMethod - public static void removeRecipe(IIngredient output) { + public static void removeRecipe(IIngredient output, @Optional IIngredient liquid) { List recipes = new LinkedList(); for(Recipe recipe : RecipeManager.recipes) { - if(recipe != null && recipe.getCraftingResult() != null && matches(output, toIItemStack(recipe.getCraftingResult()))) { - recipes.add(recipe); + if( recipe != null && recipe.getCraftingResult() != null && matches(output, toIItemStack(recipe.getCraftingResult())) ) { + if (liquid != null) { + if (matches(liquid, toILiquidStack(recipe.getLiquid()))) + recipes.add(recipe); + } else { + recipes.add(recipe); + } } }