Custom Potion Mixes

== AT ==
public-f net.minecraft.server.MinecraftServer potionBrewing
This commit is contained in:
Jake Potrebic
2021-10-07 14:34:55 -07:00
parent 299d7beee0
commit 0b5d7ad8d6
8 changed files with 286 additions and 34 deletions
@@ -0,0 +1,21 @@
package io.papermc.paper.potion;
import java.util.function.Predicate;
import net.minecraft.world.item.ItemStack;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.inventory.CraftRecipe;
import org.bukkit.inventory.RecipeChoice;
public record PaperPotionMix(ItemStack result, Predicate<ItemStack> input, Predicate<ItemStack> ingredient) {
public PaperPotionMix(PotionMix potionMix) {
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);
}
}