From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Sat, 3 Oct 2020 17:40:52 -0500
Subject: [PATCH] Add predicate to recipe's ExactChoice ingredient


diff --git a/src/main/java/net/minecraft/world/item/crafting/Ingredient.java b/src/main/java/net/minecraft/world/item/crafting/Ingredient.java
index e10a7268274488c50c0e4b5a10f8fa5de7d500e5..52063c1b14618cf132dcc45b0503e1aec838ec96 100644
--- a/src/main/java/net/minecraft/world/item/crafting/Ingredient.java
+++ b/src/main/java/net/minecraft/world/item/crafting/Ingredient.java
@@ -36,6 +36,7 @@ public final class Ingredient implements Predicate<ItemStack> {
     public ItemStack[] itemStacks;
     private IntList stackingIds;
     public boolean exact; // CraftBukkit
+    public Predicate<org.bukkit.inventory.ItemStack> predicate;
 
     public Ingredient(Stream<? extends Ingredient.Value> entries) {
         this.values = (Ingredient.Value[]) entries.toArray((i) -> {
@@ -67,6 +68,12 @@ public final class Ingredient implements Predicate<ItemStack> {
             if (this.itemStacks.length == 0) {
                 return itemstack.isEmpty();
             } else {
+                // Purpur start
+                if (predicate != null) {
+                    return predicate.test(itemstack.asBukkitCopy());
+                }
+                // Purpur end
+
                 ItemStack[] aitemstack = this.itemStacks;
                 int i = aitemstack.length;
 
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftRecipe.java
index 10ace7bb17c36bfefc584a6322841ab6ea4c866f..a225ec89946cb4c9634a797c8568171cffe4410d 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftRecipe.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftRecipe.java
@@ -22,6 +22,7 @@ public interface CraftRecipe extends Recipe {
         } else if (bukkit instanceof RecipeChoice.ExactChoice) {
             stack = new Ingredient(((RecipeChoice.ExactChoice) bukkit).getChoices().stream().map((mat) -> new net.minecraft.world.item.crafting.Ingredient.ItemValue(CraftItemStack.asNMSCopy(mat))));
             stack.exact = true;
+            stack.predicate = ((RecipeChoice.ExactChoice) bukkit).getPredicate(); // Purpur
         } else {
             throw new IllegalArgumentException("Unknown recipe stack instance " + bukkit);
         }
