9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-31 04:46:37 +00:00

fix(item): 添加未知物品组件警告日志

This commit is contained in:
jhqwqmc
2025-06-06 00:24:23 +08:00
parent 58c7751a69
commit b8483c00e8
4 changed files with 8 additions and 1 deletions

View File

@@ -8,6 +8,7 @@ import net.momirealms.craftengine.bukkit.nms.FastNMS;
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.CoreReflections;
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MRegistryOps;
import net.momirealms.craftengine.core.item.ItemWrapper;
import net.momirealms.craftengine.core.plugin.locale.TranslationManager;
import net.momirealms.craftengine.core.util.Key;
import net.momirealms.sparrow.nbt.Tag;
import org.bukkit.inventory.ItemStack;
@@ -111,6 +112,10 @@ public class ComponentItemWrapper implements ItemWrapper<ItemStack> {
private void setComponentInternal(Object type, DynamicOps ops, Object value) {
if (value == null) return;
Object componentType = ensureDataComponentType(type);
if (componentType == null) {
TranslationManager.instance().log("warning.config.item.component_notfound", type.toString());
return;
}
Codec codec = FastNMS.INSTANCE.method$DataComponentType$codec(componentType);
try {
DataResult<Object> result = codec.parse(ops, value);