mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 08:27:43 +01:00
Add predicate to recipe's ExactChoice ingredient
This commit is contained in:
committed by
granny
parent
97d90df5da
commit
32db32c5ae
@@ -0,0 +1,36 @@
|
||||
--- a/src/main/java/org/bukkit/inventory/RecipeChoice.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/RecipeChoice.java
|
||||
@@ -191,6 +_,7 @@
|
||||
public static class ExactChoice implements RecipeChoice {
|
||||
|
||||
private List<ItemStack> choices;
|
||||
+ private Predicate<ItemStack> predicate; // Purpur - Add predicate to recipe's ExactChoice ingredient
|
||||
|
||||
public ExactChoice(@NotNull ItemStack stack) {
|
||||
this(Arrays.asList(stack));
|
||||
@@ -241,6 +_,7 @@
|
||||
|
||||
@Override
|
||||
public boolean test(@NotNull ItemStack t) {
|
||||
+ if (predicate != null) return predicate.test(t); // Purpur - Add predicate to recipe's ExactChoice ingredient
|
||||
for (ItemStack match : choices) {
|
||||
if (t.isSimilar(match)) {
|
||||
return true;
|
||||
@@ -249,6 +_,17 @@
|
||||
|
||||
return false;
|
||||
}
|
||||
+
|
||||
+ // Purpur start - Add predicate to recipe's ExactChoice ingredient
|
||||
+ @org.jetbrains.annotations.Nullable
|
||||
+ public Predicate<ItemStack> getPredicate() {
|
||||
+ return predicate;
|
||||
+ }
|
||||
+
|
||||
+ public void setPredicate(@org.jetbrains.annotations.Nullable Predicate<ItemStack> predicate) {
|
||||
+ this.predicate = predicate;
|
||||
+ }
|
||||
+ // Purpur end - Add predicate to recipe's ExactChoice ingredient
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
Reference in New Issue
Block a user