Skip to content

Commit a7f9afb

Browse files
committed
Fix NPE
1 parent 236744c commit a7f9afb

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/main/java/minetweaker/mc1710/recipes/MCRecipeManager.java

+18-18
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public void addShapedMirrored(IItemStack output, IIngredient[][] ingredients, IR
170170
public void addShapeless(IItemStack output, IIngredient[] ingredients, IRecipeFunction function, IRecipeAction action) {
171171
if(checkShapelessNulls(output, ingredients))
172172
return;
173-
173+
174174
recipesToAdd.add(new ActionAddShapelessRecipe(output, ingredients, function, action));
175175
}
176176

@@ -267,7 +267,7 @@ public IItemStack craft(IItemStack[][] contents) {
267267
return getIItemStack(result);
268268
}
269269
}
270-
270+
271271
public abstract static class ActionBaseRemoveRecipes implements IUndoableAction {
272272
public abstract boolean matches(IRecipe r);
273273
public abstract Set<IRecipe> find();
@@ -284,7 +284,7 @@ public static class ActionRemoveRecipesNoIngredients extends ActionBaseRemoveRec
284284
public void addOutput(IIngredient output, @Optional boolean nbtMatch) {
285285
outputs.add(Pair.of(output, nbtMatch));
286286
}
287-
287+
288288
public void clearOutputs() {
289289
outputs.clear();
290290
}
@@ -350,13 +350,13 @@ private boolean matches(IItemStack stack) {
350350
}
351351

352352
}
353-
353+
354354
public static class ActionRemoveShapelessRecipes extends ActionBaseRemoveRecipes implements IUndoableAction {
355355
final IIngredient output;
356356
final IIngredient[] ingredients;
357357
final boolean wildcard;
358358
Set<IRecipe> toRemove = new HashSet<>();
359-
359+
360360
public ActionRemoveShapelessRecipes(IIngredient output, IIngredient[] ingredients, boolean wildcard) {
361361
this.output = output;
362362
this.ingredients = ingredients;
@@ -434,7 +434,7 @@ public Set<IRecipe> find() {
434434
public void apply() {
435435
toRemove = find();
436436
MineTweakerAPI.logInfo("Removing " + toRemove.size() + " Shapeless recipes.");
437-
super.removeRecipes(toRemove);
437+
super.removeRecipes(toRemove);
438438
}
439439

440440
@Override
@@ -468,7 +468,7 @@ public Object getOverrideKey() {
468468
return null;
469469
}
470470
}
471-
471+
472472
public static class ActionRemoveShapedRecipes extends ActionBaseRemoveRecipes implements IUndoableAction {
473473
final IIngredient output;
474474
final IIngredient[][] ingredients;
@@ -548,7 +548,7 @@ public void apply() {
548548
toRemove = find();
549549

550550
MineTweakerAPI.logInfo(toRemove.size() + " removed");
551-
super.removeRecipes(toRemove);
551+
super.removeRecipes(toRemove);
552552
}
553553

554554
@Override
@@ -582,20 +582,20 @@ public Object getOverrideKey() {
582582
return null;
583583
}
584584
}
585-
585+
586586
public static class ActionBaseAddRecipe implements IUndoableAction {
587587
private final IRecipe iRecipe;
588588
private final ICraftingRecipe craftingRecipe;
589-
589+
590590
protected final IItemStack output;
591591
protected final boolean isShaped;
592592
protected final boolean isRestoring;
593-
593+
594594
private ActionBaseAddRecipe(IRecipe iRecipe) {
595595
this.iRecipe = iRecipe;
596596
this.craftingRecipe = null;
597597
this.isRestoring = true;
598-
598+
599599
this.isShaped = iRecipe instanceof ShapedRecipes;
600600
this.output = new MCItemStack(iRecipe.getRecipeOutput());
601601
}
@@ -604,10 +604,10 @@ private ActionBaseAddRecipe(ICraftingRecipe craftingRecipe, IItemStack output, b
604604
this.iRecipe = RecipeConverter.convert(craftingRecipe);
605605
this.craftingRecipe = craftingRecipe;
606606
this.isRestoring = false;
607-
607+
608608
this.output = output;
609609
this.isShaped = isShaped;
610-
610+
611611
}
612612

613613
@Override
@@ -639,7 +639,7 @@ public String describe() {
639639

640640
@Override
641641
public String describeUndo() {
642-
return "Undoing addition of " + output.getDisplayName();
642+
return "Undoing addition of " + (output != null ? output.getDisplayName() : "invalid output");
643643
}
644644

645645
@Override
@@ -653,7 +653,7 @@ public ActionAddShapedRecipe(IItemStack output, IIngredient[][] ingredients, IRe
653653
super(new ShapedRecipe(output, ingredients, function, action, mirrored), output, true);
654654
}
655655
}
656-
656+
657657
private static class ActionAddShapelessRecipe extends ActionBaseAddRecipe {
658658
public ActionAddShapelessRecipe(IItemStack output, IIngredient[] ingredients, IRecipeFunction function, IRecipeAction action) {
659659
super(new ShapelessRecipe(output, ingredients, function, action), output, false);
@@ -698,7 +698,7 @@ public Object getOverrideKey() {
698698
return null;
699699
}
700700
}
701-
701+
702702
public static void applyAdditionsAndRemovals() {
703703
System.out.println("MineTweaker: Applying additions and removals");
704704
MineTweakerAPI.apply(MCRecipeManager.actionRemoveRecipesNoIngredients);
@@ -722,7 +722,7 @@ public static void applyAdditionsAndRemovals() {
722722
recipesToRemove.forEach(ActionBaseRemoveRecipes::apply);
723723
}
724724
MCRecipeManager.recipesToAdd.forEach(MineTweakerAPI::apply);
725-
725+
726726
actionRemoveRecipesNoIngredients.clearOutputs();
727727
recipesToRemove.clear();;
728728
recipesToAdd.clear();

0 commit comments

Comments
 (0)