Skip to content

Commit

Permalink
Fix NPE comparing NBT ingredients (#1493)
Browse files Browse the repository at this point in the history
  • Loading branch information
ALongStringOfNumbers authored Feb 11, 2023
1 parent ed2bec4 commit 6198c8b
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ public boolean equals(Object obj) {
return false;
}
}

// No matchers, just return early comparing items
if (this.matcher == null && other.matcher == null) {
return ItemStack.areItemsEqual(stack, other.stack);
}
// One input has matchers, the other does not. No match
else if (this.matcher == null || other.matcher == null) {
return false;
}
//NBT condition is only available on the MapItemStackNBTIngredient created by from the Recipe, so
//the evaluate method is called from the comparing MapItemStackNBTIngredient that is on the RecipeMap
return ItemStack.areItemsEqual(stack, other.stack) && other.matcher.evaluate(this.stack, other.condition);
Expand Down

0 comments on commit 6198c8b

Please sign in to comment.