From 0fc524b0beb2f14cfdbd954f8650915f6e09e2a1 Mon Sep 17 00:00:00 2001 From: thedarkcolour <30441001+thedarkcolour@users.noreply.github.com> Date: Mon, 28 Mar 2022 11:50:29 -0700 Subject: [PATCH] Fix inconsistent CraftTweaker functions --- .../compat/crafttweaker/Composter.java | 16 ++++++--------- .../compat/crafttweaker/Stonecutter.java | 20 ++----------------- 2 files changed, 8 insertions(+), 28 deletions(-) diff --git a/src/main/java/thedarkcolour/futuremc/compat/crafttweaker/Composter.java b/src/main/java/thedarkcolour/futuremc/compat/crafttweaker/Composter.java index 60e1512b..d1589bd8 100644 --- a/src/main/java/thedarkcolour/futuremc/compat/crafttweaker/Composter.java +++ b/src/main/java/thedarkcolour/futuremc/compat/crafttweaker/Composter.java @@ -21,7 +21,7 @@ public static void addValidItem(IIngredient stack, int rarity) { } @ZenMethod - public static void removeValidItem(IIngredient stack) { + public static void removeValidItem(IItemStack stack) { CraftTweakerAPI.apply(new Remove(stack)); } @@ -65,24 +65,20 @@ public String describe() { } private static final class Remove implements IAction { - private final IIngredient ingredient; + private final IItemStack stack; - private Remove(IIngredient ingredient) { - this.ingredient = ingredient; + private Remove(IItemStack stack) { + this.stack = stack; } @Override public void apply() { - for (IItemStack item : ingredient.getItems()) { - ItemStack stack = CraftTweakerMC.getItemStack(item); - - ComposterBlock.ItemsForComposter.remove(stack); - } + ComposterBlock.ItemsForComposter.remove(CraftTweakerMC.getItemStack(stack)); } @Override public String describe() { - return "Removed item " + ingredient.toCommandString() + " from the list of valid Composter item."; + return "Removed item " + stack.toCommandString() + " from the list of valid Composter item."; } } } \ No newline at end of file diff --git a/src/main/java/thedarkcolour/futuremc/compat/crafttweaker/Stonecutter.java b/src/main/java/thedarkcolour/futuremc/compat/crafttweaker/Stonecutter.java index 3d926995..a3420cf3 100644 --- a/src/main/java/thedarkcolour/futuremc/compat/crafttweaker/Stonecutter.java +++ b/src/main/java/thedarkcolour/futuremc/compat/crafttweaker/Stonecutter.java @@ -6,7 +6,6 @@ import crafttweaker.api.item.IIngredient; import crafttweaker.api.item.IItemStack; import crafttweaker.api.minecraft.CraftTweakerMC; -import crafttweaker.api.oredict.IOreDictEntry; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; import thedarkcolour.futuremc.recipe.stonecutter.StonecutterRecipes; @@ -17,29 +16,15 @@ @ZenClass("mods.futuremc.Stonecutter") public final class Stonecutter { @ZenMethod - public static void addOutputs(IItemStack input, IItemStack... outputs) { + public static void addOutputs(IIngredient input, IItemStack... outputs) { Arrays.stream(outputs).forEach(output -> addOutput(input, output)); } - @ZenMethod - public static void addOutputs(IOreDictEntry input, IItemStack... outputs) { - for (IItemStack i : input.getItems()) { - Arrays.stream(outputs).forEach(output -> addOutput(i, output)); - } - } - @ZenMethod public static void addOutput(IIngredient input, IItemStack output) { CraftTweakerAPI.apply(Action.of(() -> StonecutterRecipes.INSTANCE.addRecipe(CraftTweakerMC.getIngredient(input), CraftTweakerMC.getItemStack(output)))); } - @ZenMethod - public static void addOutputs(IOreDictEntry input, IItemStack output) { - for (IItemStack i : input.getItems()) { - addOutput(i, output); - } - } - @ZenMethod public static void removeOutputs(IItemStack input, IItemStack... outputs) { Arrays.stream(outputs).forEach(output -> { @@ -52,10 +37,9 @@ public static void removeRecipe(IItemStack input) { CraftTweakerAPI.apply(Action.of(() -> StonecutterRecipes.INSTANCE.removeRecipeForInput(CraftTweakerMC.getItemStack(input)))); } - // todo turn into overloaded version of #removeOutputs and add separate functionality for #removeRecipe @ZenMethod public static void removeAllOutputsForInput(IItemStack input) { - CraftTweakerAPI.apply(Action.of(() -> StonecutterRecipes.INSTANCE.removeRecipeForInput(CraftTweakerMC.getItemStack(input)))); + removeRecipe(input); } @ZenMethod