Files
Purpur/patches/server/0119-Add-predicate-to-recipe-s-ExactChoice-ingredient.patch
BillyGalbreath 4c7ab7083d Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
1c8b6065e Skip distance map update when spawning is disabled
091e6700f Added PlayerStonecutterRecipeSelectEvent
fc885f966 Add toggle for always placing the dragon egg
b3a6da3a7 Updated Upstream (Bukkit/CraftBukkit)
18ccc062d [Auto] Updated Upstream (Spigot)
e9a87b72b fix BaseTag constructor (#5095)
2021-01-24 05:36:26 -06:00

44 lines
2.4 KiB
Diff

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/server/RecipeItemStack.java b/src/main/java/net/minecraft/server/RecipeItemStack.java
index 0f96abd0ca78e9c78306fed69684dee71be37703..f6d92949409b66d5d0c578e010aebd058903c6fa 100644
--- a/src/main/java/net/minecraft/server/RecipeItemStack.java
+++ b/src/main/java/net/minecraft/server/RecipeItemStack.java
@@ -26,6 +26,7 @@ public final class RecipeItemStack implements Predicate<ItemStack> {
public ItemStack[] choices;
private IntList d;
public boolean exact; // CraftBukkit
+ public Predicate<org.bukkit.inventory.ItemStack> predicate; // Purpur
public RecipeItemStack(Stream<? extends RecipeItemStack.Provider> stream) {
this.b = (RecipeItemStack.Provider[]) stream.toArray((i) -> {
@@ -52,6 +53,12 @@ public final class RecipeItemStack implements Predicate<ItemStack> {
if (this.choices.length == 0) {
return itemstack.isEmpty();
} else {
+ // Purpur start
+ if (predicate != null) {
+ return predicate.test(itemstack.asBukkitCopy());
+ }
+ // Purpur end
+
ItemStack[] aitemstack = this.choices;
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 ef29599a89bc630899c65df9a7004f836787d95e..18413e6327458c6d60d2a0ca8167fc5d75389934 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 RecipeItemStack(((RecipeChoice.ExactChoice) bukkit).getChoices().stream().map((mat) -> new net.minecraft.server.RecipeItemStack.StackProvider(CraftItemStack.asNMSCopy(mat))));
stack.exact = true;
+ stack.predicate = ((RecipeChoice.ExactChoice) bukkit).getPredicate(); // Purpur
} else {
throw new IllegalArgumentException("Unknown recipe stack instance " + bukkit);
}