diff --git a/src/main/java/com/minelittlepony/unicopia/enchanting/SpellRecipe.java b/src/main/java/com/minelittlepony/unicopia/enchanting/SpellRecipe.java index 238ec067..51c58a36 100644 --- a/src/main/java/com/minelittlepony/unicopia/enchanting/SpellRecipe.java +++ b/src/main/java/com/minelittlepony/unicopia/enchanting/SpellRecipe.java @@ -33,8 +33,6 @@ public class SpellRecipe extends Impl implements IRecipe { Item item = o.has("item") ? Item.getByNameOrId(o.get("item").getAsString()) : null; - - if (item != null) { int metadata = Math.max(0, o.has("data") ? o.get("data").getAsInt() : 0); int size = Math.max(1, o.has("count") ? o.get("count").getAsInt() : 1); @@ -78,11 +76,7 @@ public class SpellRecipe extends Impl implements IRecipe { ItemStack stack = inv.getStackInSlot(i); if (!stack.isEmpty()) { - if (toMatch.isEmpty() && !stack.isEmpty()) { - return false; - } - - if (!toMatch.isEmpty() && !toMatch.removeIf(s -> s.matches(stack, materialMult))) { + if (toMatch.isEmpty() || !removeMatch(toMatch, stack, materialMult)) { return false; } } @@ -90,6 +84,14 @@ public class SpellRecipe extends Impl implements IRecipe { return toMatch.isEmpty(); } + private boolean removeMatch(ArrayList toMatch, ItemStack stack, int materialMult) { + return toMatch.stream() + .filter(s -> s.matches(stack, materialMult)) + .findFirst() + .filter(toMatch::remove) + .isPresent(); + } + @Override public ItemStack getCraftingResult(InventoryCrafting inv) { return getRecipeOutput();