Custom Potion Mixes

This commit is contained in:
Jake Potrebic
2021-10-07 14:34:59 -07:00
parent 64f342f5fb
commit f9d3155517
5 changed files with 187 additions and 5 deletions
@@ -0,0 +1,32 @@
package io.papermc.paper.potion;
import java.util.function.Predicate;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.RecipeChoice;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
@ApiStatus.Internal
@NullMarked
record PredicateRecipeChoice(Predicate<? super ItemStack> itemStackPredicate) implements RecipeChoice, Cloneable {
@Override
@Deprecated
public ItemStack getItemStack() {
throw new UnsupportedOperationException("PredicateRecipeChoice does not support this");
}
@Override
public RecipeChoice clone() {
try {
return (PredicateRecipeChoice) super.clone();
} catch (final CloneNotSupportedException ex) {
throw new AssertionError(ex);
}
}
@Override
public boolean test(final ItemStack itemStack) {
return this.itemStackPredicate.test(itemStack);
}
}