mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-26 02:19:23 +00:00
修复
This commit is contained in:
@@ -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));
|
||||
})
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user