mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
44 lines
2.5 KiB
Diff
44 lines
2.5 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/world/item/crafting/RecipeItemStack.java b/src/main/java/net/minecraft/world/item/crafting/RecipeItemStack.java
|
|
index 63274908bc7552321a4db3d4e0eec0f55ee34786..c7f6dc5a933873a6118a5674e4ce04cfa1664f60 100644
|
|
--- a/src/main/java/net/minecraft/world/item/crafting/RecipeItemStack.java
|
|
+++ b/src/main/java/net/minecraft/world/item/crafting/RecipeItemStack.java
|
|
@@ -36,6 +36,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) -> {
|
|
@@ -62,6 +63,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 b7e8c3798628229be56289818caa3024014640d6..43c50c2c54444c67e4a875be4880afe97c32412c 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.world.item.crafting.RecipeItemStack.StackProvider(CraftItemStack.asNMSCopy(mat))));
|
|
stack.exact = true;
|
|
+ stack.predicate = ((RecipeChoice.ExactChoice) bukkit).getPredicate(); // Purpur
|
|
} else {
|
|
throw new IllegalArgumentException("Unknown recipe stack instance " + bukkit);
|
|
}
|