From 9167cd1f1d60674c4cb5fd8bdba5fdeafd2d8a23 Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Sun, 29 Nov 2020 21:04:11 +0100 Subject: [PATCH] Added Overloads --- .../api/recipes/IRecipeManager.java | 37 ++++++-- .../mc1710/recipes/MCRecipeManager.java | 85 +++++++++++++++++++ 2 files changed, 116 insertions(+), 6 deletions(-) diff --git a/MineTweaker3-API/src/main/java/minetweaker/api/recipes/IRecipeManager.java b/MineTweaker3-API/src/main/java/minetweaker/api/recipes/IRecipeManager.java index eb23414..08ed052 100644 --- a/MineTweaker3-API/src/main/java/minetweaker/api/recipes/IRecipeManager.java +++ b/MineTweaker3-API/src/main/java/minetweaker/api/recipes/IRecipeManager.java @@ -41,7 +41,9 @@ public interface IRecipeManager { */ @ZenMethod int remove(IIngredient output, @Optional boolean nbtMatch); - + + int remove(IIngredient output, boolean nbtMatch); + /** * Adds a shaped recipe. * @@ -51,7 +53,12 @@ public interface IRecipeManager { */ @ZenMethod void addShaped(IItemStack output, IIngredient[][] ingredients, @Optional IRecipeFunction function, @Optional IRecipeAction action); - + + void addShaped(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function); + + void addShaped(IItemStack output, IIngredient[][] ingredients, IRecipeAction action); + + void addShaped(IItemStack output, IIngredient[][] ingredients); /** * Adds a mirrored shaped recipe. * @@ -61,7 +68,12 @@ public interface IRecipeManager { */ @ZenMethod void addShapedMirrored(IItemStack output, IIngredient[][] ingredients, @Optional IRecipeFunction function, @Optional IRecipeAction action); - + + void addShapedMirrored(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function); + + void addShapedMirrored(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function); + + void addShapedMirrored(IItemStack output, IIngredient[][] ingredients); /** * Adds a shapeless recipe. * @@ -71,7 +83,13 @@ public interface IRecipeManager { */ @ZenMethod void addShapeless(IItemStack output, IIngredient[] ingredients, @Optional IRecipeFunction function, @Optional IRecipeAction action); - + + void addShapeless(IItemStack output, IIngredient[] ingredients, IRecipeFunction function); + + void addShapeless(IItemStack output, IIngredient[] ingredients, IRecipeAction action); + + void addShapeless(IItemStack output, IIngredient[] ingredients); + /** * Removes shaped recipes. * @@ -82,7 +100,8 @@ public interface IRecipeManager { */ @ZenMethod int removeShaped(IIngredient output, @Optional IIngredient[][] ingredients); - + + int removeShaped(IIngredient output); /** * Removes shapeless recipes. * @@ -95,7 +114,13 @@ public interface IRecipeManager { */ @ZenMethod int removeShapeless(IIngredient output, @Optional IIngredient[] ingredients, @Optional boolean wildcard); - + + int removeShapeless(IIngredient output, boolean wildcard); + + int removeShapeless(IIngredient output, IIngredient[] ingredients); + + int removeShapeless(IIngredient output); + /** * Performs a crafting with the specified ingredients. Returns null if no * crafting recipe exists. diff --git a/MineTweaker3-MC1710-Main/src/main/java/minetweaker/mc1710/recipes/MCRecipeManager.java b/MineTweaker3-MC1710-Main/src/main/java/minetweaker/mc1710/recipes/MCRecipeManager.java index fcbcf4f..56a263a 100644 --- a/MineTweaker3-MC1710-Main/src/main/java/minetweaker/mc1710/recipes/MCRecipeManager.java +++ b/MineTweaker3-MC1710-Main/src/main/java/minetweaker/mc1710/recipes/MCRecipeManager.java @@ -109,6 +109,11 @@ public final class MCRecipeManager implements IRecipeManager { return results; } + @Override + public int remove(IIngredient output) { + return remove(output, false); + } + @Override public int remove(IIngredient output, @Optional boolean nbtMatch) { if(output == null) { @@ -119,16 +124,61 @@ public final class MCRecipeManager implements IRecipeManager { return 1; } + @Override + public void addShaped(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function) { + recipesToAdd.add(new ActionAddShapedRecipe(output, ingredients, function, null, false)); + } + + @Override + public void addShaped(IItemStack output, IIngredient[][] ingredients, IRecipeAction action) { + recipesToAdd.add(new ActionAddShapedRecipe(output, ingredients, null, action, false)); + } + + @Override + public void addShaped(IItemStack output, IIngredient[][] ingredients) { + recipesToAdd.add(new ActionAddShapedRecipe(output, ingredients, null, null, false)); + } + @Override public void addShaped(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function, IRecipeAction action) { recipesToAdd.add(new ActionAddShapedRecipe(output, ingredients, function, action, false)); } + @Override + public void addShapedMirrored(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function) { + recipesToAdd.add(new ActionAddShapedRecipe(output, ingredients, function, null, true)); + } + + @Override + public void addShapedMirrored(IItemStack output, IIngredient[][] ingredients) { + recipesToAdd.add(new ActionAddShapedRecipe(output, ingredients, null, null, true)); + } + + @Override + public void addShaped(IItemStack output, IIngredient[][] ingredients, IRecipeAction action) { + recipesToAdd.add(new ActionAddShapedRecipe(output, ingredients, null, action, false)); + } + @Override public void addShapedMirrored(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function, IRecipeAction action) { recipesToAdd.add(new ActionAddShapedRecipe(output, ingredients, function, action, true)); } + @Override + public void addShapedMirrored(IItemStack output, IIngredient[][] ingredients, IRecipeAction action) { + recipesToAdd.add(new ActionAddShapedRecipe(output, ingredients, null, action, true)); + } + + @Override + public void addShapedMirrored(IItemStack output, IIngredient[][] ingredients, IRecipeFunction function) { + recipesToAdd.add(new ActionAddShapedRecipe(output, ingredients, function, null, true)); + } + + @Override + public void addShapedMirrored(IItemStack output, IIngredient[][] ingredients) { + recipesToAdd.add(new ActionAddShapedRecipe(output, ingredients, null, null, true)); + } + @Override public void addShapeless(IItemStack output, IIngredient[] ingredients, IRecipeFunction function, IRecipeAction action) { if(checkShapelessNulls(output, ingredients)) @@ -137,6 +187,21 @@ public final class MCRecipeManager implements IRecipeManager { recipesToAdd.add(new ActionAddShapelessRecipe(output, ingredients, function, action)); } + @Override + public void addShapeless(IItemStack output, IIngredient[] ingredients, IRecipeFunction function){ + addShapeless(output, ingredients, function, null); + } + + @Override + public void addShapeless(IItemStack output, IIngredient[] ingredients, IRecipeAction action){ + addShapeless(output, ingredients, null, action); + } + + @Override + public void addShapeless(IItemStack output, IIngredient[] ingredients){ + addShapeless(output, ingredients, null, null); + } + private boolean checkShapelessNulls(IItemStack output, IIngredient[] ingredients) { if(output != null && Arrays.stream(ingredients).allMatch(Objects::isNull)) { MineTweakerAPI.logError("Null not allowed in shapeless recipes! Recipe for: " + output + " not created!"); @@ -155,6 +220,11 @@ public final class MCRecipeManager implements IRecipeManager { return 1; } + @Override + public int removeShaped(IIngredient output, IIngredient[][] ingredients) { + return removeShaped(output, null); + } + @Override public int removeShapeless(IIngredient output, IIngredient[] ingredients, boolean wildcard) { if(output == null) { @@ -165,6 +235,21 @@ public final class MCRecipeManager implements IRecipeManager { return 1; } + @Override + public int removeShapeless(IIngredient output, IIngredient[] ingredients) { + return removeShapeless(output, ingredients, true); + } + + @Override + public int removeShapeless(IIngredient output, boolean wildcard) { + return removeShapeless(output, null, wildcard); + } + + @Override + public int removeShapeless(IIngredient output) { + return removeShapeless(output, null, true); + } + @Override public IItemStack craft(IItemStack[][] contents) { Container container = new ContainerVirtual();