Skip to content

Commit

Permalink
Fix inconsistent CraftTweaker functions
Browse files Browse the repository at this point in the history
  • Loading branch information
thedarkcolour committed Mar 28, 2022
1 parent 731abbf commit 0fc524b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down Expand Up @@ -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.";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 -> {
Expand All @@ -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
Expand Down

0 comments on commit 0fc524b

Please sign in to comment.