mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-19 09:27:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: 9a129fa99 Add #getEligibleHumans to SkeletonHorseTrapEvent b5e23c7a6 Fix merging spawning values a932e8ad7 Turn off spigot verbose world by default 8ced89f65 Fix Delegation to vanilla chunk gen
53 lines
2.0 KiB
Diff
53 lines
2.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
|
Date: Fri, 2 Oct 2020 17:43:24 -0500
|
|
Subject: [PATCH] Add predicate to recipe's ExactChoice ingredient
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/inventory/RecipeChoice.java b/src/main/java/org/bukkit/inventory/RecipeChoice.java
|
|
index 3d325cab6..4dedbdc1c 100644
|
|
--- a/src/main/java/org/bukkit/inventory/RecipeChoice.java
|
|
+++ b/src/main/java/org/bukkit/inventory/RecipeChoice.java
|
|
@@ -10,6 +10,7 @@ import java.util.function.Predicate;
|
|
import org.bukkit.Material;
|
|
import org.bukkit.Tag;
|
|
import org.jetbrains.annotations.NotNull;
|
|
+import org.jetbrains.annotations.Nullable; // Purpur
|
|
|
|
/**
|
|
* Represents a potential item match within a recipe. All choices within a
|
|
@@ -155,6 +156,7 @@ public interface RecipeChoice extends Predicate<ItemStack>, Cloneable {
|
|
public static class ExactChoice implements RecipeChoice {
|
|
|
|
private List<ItemStack> choices;
|
|
+ private Predicate<ItemStack> predicate; // Purpur
|
|
|
|
public ExactChoice(@NotNull ItemStack stack) {
|
|
this(Arrays.asList(stack));
|
|
@@ -199,6 +201,7 @@ public interface RecipeChoice extends Predicate<ItemStack>, Cloneable {
|
|
|
|
@Override
|
|
public boolean test(@NotNull ItemStack t) {
|
|
+ if (predicate != null) return predicate.test(t); // Purpur
|
|
for (ItemStack match : choices) {
|
|
if (t.isSimilar(match)) {
|
|
return true;
|
|
@@ -208,6 +211,17 @@ public interface RecipeChoice extends Predicate<ItemStack>, Cloneable {
|
|
return false;
|
|
}
|
|
|
|
+ // Purpur start
|
|
+ @Nullable
|
|
+ public Predicate<ItemStack> getPredicate() {
|
|
+ return predicate;
|
|
+ }
|
|
+
|
|
+ public void setPredicate(@Nullable Predicate<ItemStack> predicate) {
|
|
+ this.predicate = predicate;
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
@Override
|
|
public int hashCode() {
|
|
int hash = 7;
|