From a7f9afb6c4c8ac0ddbd9314d864779207bee7909 Mon Sep 17 00:00:00 2001 From: miozune Date: Mon, 2 May 2022 14:49:21 +0900 Subject: [PATCH 1/2] Fix NPE --- .../mc1710/recipes/MCRecipeManager.java | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/main/java/minetweaker/mc1710/recipes/MCRecipeManager.java b/src/main/java/minetweaker/mc1710/recipes/MCRecipeManager.java index f3f45ce..097b218 100644 --- a/src/main/java/minetweaker/mc1710/recipes/MCRecipeManager.java +++ b/src/main/java/minetweaker/mc1710/recipes/MCRecipeManager.java @@ -170,7 +170,7 @@ public final class MCRecipeManager implements IRecipeManager { public void addShapeless(IItemStack output, IIngredient[] ingredients, IRecipeFunction function, IRecipeAction action) { if(checkShapelessNulls(output, ingredients)) return; - + recipesToAdd.add(new ActionAddShapelessRecipe(output, ingredients, function, action)); } @@ -267,7 +267,7 @@ public final class MCRecipeManager implements IRecipeManager { return getIItemStack(result); } } - + public abstract static class ActionBaseRemoveRecipes implements IUndoableAction { public abstract boolean matches(IRecipe r); public abstract Set find(); @@ -284,7 +284,7 @@ public final class MCRecipeManager implements IRecipeManager { public void addOutput(IIngredient output, @Optional boolean nbtMatch) { outputs.add(Pair.of(output, nbtMatch)); } - + public void clearOutputs() { outputs.clear(); } @@ -350,13 +350,13 @@ public final class MCRecipeManager implements IRecipeManager { } } - + public static class ActionRemoveShapelessRecipes extends ActionBaseRemoveRecipes implements IUndoableAction { final IIngredient output; final IIngredient[] ingredients; final boolean wildcard; Set toRemove = new HashSet<>(); - + public ActionRemoveShapelessRecipes(IIngredient output, IIngredient[] ingredients, boolean wildcard) { this.output = output; this.ingredients = ingredients; @@ -434,7 +434,7 @@ public final class MCRecipeManager implements IRecipeManager { public void apply() { toRemove = find(); MineTweakerAPI.logInfo("Removing " + toRemove.size() + " Shapeless recipes."); - super.removeRecipes(toRemove); + super.removeRecipes(toRemove); } @Override @@ -468,7 +468,7 @@ public final class MCRecipeManager implements IRecipeManager { return null; } } - + public static class ActionRemoveShapedRecipes extends ActionBaseRemoveRecipes implements IUndoableAction { final IIngredient output; final IIngredient[][] ingredients; @@ -548,7 +548,7 @@ public final class MCRecipeManager implements IRecipeManager { toRemove = find(); MineTweakerAPI.logInfo(toRemove.size() + " removed"); - super.removeRecipes(toRemove); + super.removeRecipes(toRemove); } @Override @@ -582,20 +582,20 @@ public final class MCRecipeManager implements IRecipeManager { return null; } } - + public static class ActionBaseAddRecipe implements IUndoableAction { private final IRecipe iRecipe; private final ICraftingRecipe craftingRecipe; - + protected final IItemStack output; protected final boolean isShaped; protected final boolean isRestoring; - + private ActionBaseAddRecipe(IRecipe iRecipe) { this.iRecipe = iRecipe; this.craftingRecipe = null; this.isRestoring = true; - + this.isShaped = iRecipe instanceof ShapedRecipes; this.output = new MCItemStack(iRecipe.getRecipeOutput()); } @@ -604,10 +604,10 @@ public final class MCRecipeManager implements IRecipeManager { this.iRecipe = RecipeConverter.convert(craftingRecipe); this.craftingRecipe = craftingRecipe; this.isRestoring = false; - + this.output = output; this.isShaped = isShaped; - + } @Override @@ -639,7 +639,7 @@ public final class MCRecipeManager implements IRecipeManager { @Override public String describeUndo() { - return "Undoing addition of " + output.getDisplayName(); + return "Undoing addition of " + (output != null ? output.getDisplayName() : "invalid output"); } @Override @@ -653,7 +653,7 @@ public final class MCRecipeManager implements IRecipeManager { super(new ShapedRecipe(output, ingredients, function, action, mirrored), output, true); } } - + private static class ActionAddShapelessRecipe extends ActionBaseAddRecipe { public ActionAddShapelessRecipe(IItemStack output, IIngredient[] ingredients, IRecipeFunction function, IRecipeAction action) { super(new ShapelessRecipe(output, ingredients, function, action), output, false); @@ -698,7 +698,7 @@ public final class MCRecipeManager implements IRecipeManager { return null; } } - + public static void applyAdditionsAndRemovals() { System.out.println("MineTweaker: Applying additions and removals"); MineTweakerAPI.apply(MCRecipeManager.actionRemoveRecipesNoIngredients); @@ -722,7 +722,7 @@ public final class MCRecipeManager implements IRecipeManager { recipesToRemove.forEach(ActionBaseRemoveRecipes::apply); } MCRecipeManager.recipesToAdd.forEach(MineTweakerAPI::apply); - + actionRemoveRecipesNoIngredients.clearOutputs(); recipesToRemove.clear();; recipesToAdd.clear(); From b86eeb4cc69585b94443719d200a1ed58f19b050 Mon Sep 17 00:00:00 2001 From: miozune Date: Mon, 2 May 2022 17:02:42 +0900 Subject: [PATCH 2/2] ic2 maven --- repositories.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/repositories.gradle b/repositories.gradle index 5fc1ece..ec6ccf1 100644 --- a/repositories.gradle +++ b/repositories.gradle @@ -8,6 +8,7 @@ repositories { maven { name = "ic2" url = "https://maven.ic2.player.to/" + url = "https://maven2.ic2.player.to/" metadataSources { mavenPom() artifact()