mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-25 09:59:20 +00:00
修改空判断
This commit is contained in:
@@ -368,7 +368,7 @@ public class BukkitItemManager extends AbstractItemManager<ItemStack> {
|
||||
@Nullable
|
||||
private ItemStack createVanillaItemStack(Key id) {
|
||||
Object item = FastNMS.INSTANCE.method$Registry$getValue(MBuiltInRegistries.ITEM, KeyUtils.toResourceLocation(id));
|
||||
if (item == MItems.AIR) {
|
||||
if (item == MItems.AIR && !id.equals(ItemKeys.AIR)) {
|
||||
return null;
|
||||
}
|
||||
return FastNMS.INSTANCE.method$CraftItemStack$asCraftMirror(FastNMS.INSTANCE.constructor$ItemStack(item, 1));
|
||||
|
||||
@@ -101,4 +101,9 @@ public abstract class AbstractCustomItem<I> implements CustomItem<I> {
|
||||
public @NotNull List<ItemBehavior> behaviors() {
|
||||
return this.behaviors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ public interface BuildableItem<I> {
|
||||
|
||||
Item<I> buildItem(ItemBuildContext context, int count);
|
||||
|
||||
boolean isEmpty();
|
||||
|
||||
default Item<I> buildItem(Player player) {
|
||||
return buildItem(ItemBuildContext.of(player));
|
||||
}
|
||||
|
||||
@@ -27,4 +27,9 @@ public class CloneableConstantItem<I> implements BuildableItem<I> {
|
||||
public I buildItemStack(ItemBuildContext context, int count) {
|
||||
return this.item.copyWithCount(count).getItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return this.item.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package net.momirealms.craftengine.core.item.recipe;
|
||||
|
||||
import net.momirealms.craftengine.core.item.CloneableConstantItem;
|
||||
import net.momirealms.craftengine.core.item.CustomItem;
|
||||
import net.momirealms.craftengine.core.item.Item;
|
||||
import net.momirealms.craftengine.core.item.ItemManager;
|
||||
import net.momirealms.craftengine.core.item.*;
|
||||
import net.momirealms.craftengine.core.item.recipe.reader.VanillaRecipeReader;
|
||||
import net.momirealms.craftengine.core.item.recipe.reader.VanillaRecipeReader1_20;
|
||||
import net.momirealms.craftengine.core.item.recipe.reader.VanillaRecipeReader1_20_5;
|
||||
@@ -72,9 +69,13 @@ public abstract class AbstractRecipeSerializer<T, R extends Recipe<T>> implement
|
||||
}
|
||||
String id = ResourceConfigUtils.requireNonEmptyStringOrThrow(resultMap.get("id"), "warning.config.recipe.result.missing_id");
|
||||
int count = ResourceConfigUtils.getAsInt(resultMap.getOrDefault("count", 1), "count");
|
||||
BuildableItem<T> resultItem = (BuildableItem<T>) CraftEngine.instance().itemManager().getBuildableItem(Key.of(id)).orElseThrow(() -> new LocalizedResourceConfigException("warning.config.recipe.invalid_result", id));
|
||||
if (resultItem.isEmpty()) {
|
||||
throw new LocalizedResourceConfigException("warning.config.recipe.invalid_result", id);
|
||||
}
|
||||
List<PostProcessor<T>> processors = ResourceConfigUtils.parseConfigAsList(resultMap.get("post-processors"), PostProcessors::fromMap);
|
||||
return (CustomRecipeResult<T>) new CustomRecipeResult<>(
|
||||
CraftEngine.instance().itemManager().getBuildableItem(Key.of(id)).orElseThrow(() -> new LocalizedResourceConfigException("warning.config.recipe.invalid_result", id)),
|
||||
return new CustomRecipeResult<>(
|
||||
resultItem,
|
||||
count,
|
||||
processors.isEmpty() ? null : processors.toArray(new PostProcessor[0])
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user