mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-31 12:23:51 -07:00
add predicate recipe choice only for potion mixes (#9486)
This commit is contained in:
@@ -12,15 +12,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
@@ -0,0 +0,0 @@
|
||||
+package io.papermc.paper.potion;
|
||||
+
|
||||
+import java.util.function.Predicate;
|
||||
+import net.minecraft.world.item.ItemStack;
|
||||
+import net.minecraft.world.item.crafting.Ingredient;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftRecipe;
|
||||
+import org.bukkit.inventory.RecipeChoice;
|
||||
+
|
||||
+public record PaperPotionMix(ItemStack result, Ingredient input, Ingredient ingredient) {
|
||||
+public record PaperPotionMix(ItemStack result, Predicate<ItemStack> input, Predicate<ItemStack> ingredient) {
|
||||
+
|
||||
+ public PaperPotionMix(PotionMix potionMix) {
|
||||
+ this(CraftItemStack.asNMSCopy(potionMix.getResult()), CraftRecipe.toIngredient(potionMix.getInput(), true), CraftRecipe.toIngredient(potionMix.getIngredient(), true));
|
||||
+ this(CraftItemStack.asNMSCopy(potionMix.getResult()), convert(potionMix.getInput()), convert(potionMix.getIngredient()));
|
||||
+ }
|
||||
+
|
||||
+ static Predicate<ItemStack> convert(final RecipeChoice choice) {
|
||||
+ if (choice instanceof PredicateRecipeChoice predicateRecipeChoice) {
|
||||
+ return stack -> predicateRecipeChoice.test(CraftItemStack.asBukkitCopy(stack));
|
||||
+ }
|
||||
+ return CraftRecipe.toIngredient(choice, true);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
|
Reference in New Issue
Block a user