Add predicate to recipe's ExactChoice ingredient

This commit is contained in:
William Blake Galbreath
2025-01-05 12:23:28 -08:00
committed by granny
parent 97d90df5da
commit 32db32c5ae
4 changed files with 42 additions and 60 deletions

View File

@@ -0,0 +1,22 @@
--- a/net/minecraft/world/item/crafting/Ingredient.java
+++ b/net/minecraft/world/item/crafting/Ingredient.java
@@ -36,6 +_,7 @@
// CraftBukkit start
@javax.annotation.Nullable
private java.util.Set<ItemStack> itemStacks; // Paper - Improve exact choice recipe ingredients
+ public Predicate<org.bukkit.inventory.ItemStack> predicate; // Purpur - Add predicate to recipe's ExactChoice ingredient
public boolean isExact() {
return this.itemStacks != null;
@@ -87,6 +_,11 @@
if (this.isExact()) {
return this.itemStacks.contains(stack); // Paper - Improve exact choice recipe ingredients (hashing FTW!)
}
+ // Purpur start - Add predicate to recipe's ExactChoice ingredient
+ if (predicate != null) {
+ return predicate.test(stack.asBukkitCopy());
+ }
+ // Purpur end - Add predicate to recipe's ExactChoice ingredient
// CraftBukkit end
return stack.is(this.values);
}