9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-26 02:19:23 +00:00
This commit is contained in:
XiaoMoMi
2025-07-14 17:03:23 +08:00
parent d736e466b3
commit 45464da22a
2 changed files with 3 additions and 31 deletions

View File

@@ -371,13 +371,14 @@ public class BukkitRecipeManager extends AbstractRecipeManager<ItemStack> {
@Override
protected void registerPlatformRecipe(Key id, Recipe<ItemStack> recipe) {
if (recipe instanceof CustomBrewingRecipe<ItemStack> brewingRecipe) {
if (!VersionHelper.isOrAbove1_20_2()) return;
PotionMix potionMix = new PotionMix(new NamespacedKey(id.namespace(), id.value()),
brewingRecipe.result(ItemBuildContext.EMPTY),
new PredicateChoice(container -> {
PotionMix.createPredicateChoice(container -> {
Item<ItemStack> wrapped = this.plugin.itemManager().wrap(container);
return brewingRecipe.container().test(new UniqueIdItem<>(wrapped.recipeIngredientId(), wrapped));
}),
new PredicateChoice(ingredient -> {
PotionMix.createPredicateChoice(ingredient -> {
Item<ItemStack> wrapped = this.plugin.itemManager().wrap(ingredient);
return brewingRecipe.ingredient().test(new UniqueIdItem<>(wrapped.recipeIngredientId(), wrapped));
})

View File

@@ -1,29 +0,0 @@
package net.momirealms.craftengine.bukkit.item.recipe;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.RecipeChoice;
import org.jetbrains.annotations.NotNull;
import java.util.function.Predicate;
public record PredicateChoice(Predicate<ItemStack> predicate) implements RecipeChoice {
@Override
public @NotNull RecipeChoice clone() {
try {
return (PredicateChoice) super.clone();
} catch (final CloneNotSupportedException ex) {
throw new AssertionError(ex);
}
}
@Override
public @NotNull ItemStack getItemStack() {
throw new UnsupportedOperationException("PredicateChoice doesn't support getItemStack()");
}
@Override
public boolean test(@NotNull ItemStack itemStack) {
return this.predicate.test(itemStack);
}
}