NBT-API

NBT-API

98.9k Downloads

1.21.1 write a tag into item will cause exception when read it after write tag

killerprojecte opened this issue ยท 3 comments

commented

logs

java.lang.RuntimeException: org.fastmcmirror.ultrabind.libs.nbtapi.NbtApiException: [?][2.14.0]Exception while converting NMS ItemStack to NBTCompound!
        at UltraBind-1.0.0-R3-beta8.jar/org.fastmcmirror.ultrabind.utils.Binder.bindForce(Binder.java:228) ~[UltraBind-1.0.0-R3-beta8.jar:?]
        at UltraBind-1.0.0-R3-beta8.jar/org.fastmcmirror.ultrabind.simpleinv.BindUI$1.lambda$new$0(BindUI.java:59) ~[UltraBind-1.0.0-R3-beta8.jar:?]
        at org.fastmcmirror.ultrabind.libs.simpleinv.handlers.ClickHandler.call(ClickHandler.java:15) ~[UltraBind-Libraries-1.0.0.jar:?]
        at org.fastmcmirror.ultrabind.libs.simpleinv.handlers.ClickHandlers.call(ClickHandlers.java:21) ~[UltraBind-Libraries-1.0.0.jar:?]
        at org.fastmcmirror.ultrabind.libs.simpleinv.SimpleInventory.clickSlot(SimpleInventory.java:197) ~[UltraBind-Libraries-1.0.0.jar:?]
        at org.fastmcmirror.ultrabind.libs.simpleinv.listeners.SimpleInventoryListener.onClick(SimpleInventoryListener.java:35) ~[UltraBind-Libraries-1.0.0.jar:?]
        at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor54.execute(Unknown Source) ~[?:?]
        at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:77) ~[paper-mojangapi-1.21.1-R0.1-SNAPSHOT.jar:?]
        at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[paper-mojangapi-1.21.1-R0.1-SNAPSHOT.jar:1.21.1-99-1bc02e6]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[paper-mojangapi-1.21.1-R0.1-SNAPSHOT.jar:?]
        at io.papermc.paper.plugin.manager.PaperEventManager.callEvent(PaperEventManager.java:54) ~[paper-1.21.1.jar:1.21.1-99-1bc02e6]
        at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.callEvent(PaperPluginManagerImpl.java:131) ~[paper-1.21.1.jar:1.21.1-99-1bc02e6]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:628) ~[paper-mojangapi-1.21.1-R0.1-SNAPSHOT.jar:?]
        at net.minecraft.server.network.ServerGamePacketListenerImpl.handleContainerClick(ServerGamePacketListenerImpl.java:3224) ~[paper-1.21.1.jar:1.21.1-99-1bc02e6]
        at net.minecraft.network.protocol.game.ServerboundContainerClickPacket.handle(ServerboundContainerClickPacket.java:69) ~[paper-1.21.1.jar:1.21.1-99-1bc02e6]
        at net.minecraft.network.protocol.game.ServerboundContainerClickPacket.handle(ServerboundContainerClickPacket.java:33) ~[paper-1.21.1.jar:1.21.1-99-1bc02e6]
        at net.minecraft.network.protocol.PacketUtils.lambda$ensureRunningOnSameThread$0(PacketUtils.java:56) ~[paper-1.21.1.jar:1.21.1-99-1bc02e6]
        at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.21.1.jar:1.21.1-99-1bc02e6]
        at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:151) ~[paper-1.21.1.jar:1.21.1-99-1bc02e6]
        at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[paper-1.21.1.jar:1.21.1-99-1bc02e6]
        at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1535) ~[paper-1.21.1.jar:1.21.1-99-1bc02e6]
        at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:201) ~[paper-1.21.1.jar:1.21.1-99-1bc02e6]
        at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:125) ~[paper-1.21.1.jar:1.21.1-99-1bc02e6]
        at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1512) ~[paper-1.21.1.jar:1.21.1-99-1bc02e6]
        at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1505) ~[paper-1.21.1.jar:1.21.1-99-1bc02e6]
        at net.minecraft.util.thread.BlockableEventLoop.runAllTasks(BlockableEventLoop.java:114) ~[paper-1.21.1.jar:1.21.1-99-1bc02e6]
        at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1627) ~[paper-1.21.1.jar:1.21.1-99-1bc02e6]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1302) ~[paper-1.21.1.jar:1.21.1-99-1bc02e6]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:329) ~[paper-1.21.1.jar:1.21.1-99-1bc02e6]
        at java.base/java.lang.Thread.run(Thread.java:1583) ~[?:?]
Caused by: org.fastmcmirror.ultrabind.libs.nbtapi.NbtApiException: [?][2.14.0]Exception while converting NMS ItemStack to NBTCompound!
        at org.fastmcmirror.ultrabind.libs.nbtapi.NBTReflectionUtil.convertNMSItemtoNBTCompound(NBTReflectionUtil.java:250) ~[UltraBind-Libraries-1.0.0.jar:?]
        at org.fastmcmirror.ultrabind.libs.nbtapi.NBTItem.convertItemtoNBT(NBTItem.java:347) ~[UltraBind-Libraries-1.0.0.jar:?]
        at org.fastmcmirror.ultrabind.libs.nbtapi.NBT.itemStackToNBT(NBT.java:484) ~[UltraBind-Libraries-1.0.0.jar:?]
        at UltraBind-1.0.0-R3-beta8.jar/org.fastmcmirror.ultrabind.utils.Binder.bindForce(Binder.java:208) ~[UltraBind-1.0.0-R3-beta8.jar:?]
        ... 29 more
Caused by: org.fastmcmirror.ultrabind.libs.nbtapi.NbtApiException: [?][2.14.0]Error while calling the method 'save', loaded: true, Enum: NMSITEM_SAVE_MODERN, Passed Class: class net.minecraft.world.item.ItemStack Args: [net.minecraft.core.RegistryAccess$1FrozenAccess@5e8dba57]
        at org.fastmcmirror.ultrabind.libs.nbtapi.utils.nmsmappings.ReflectionMethod.run(ReflectionMethod.java:399) ~[UltraBind-Libraries-1.0.0.jar:?]
        at org.fastmcmirror.ultrabind.libs.nbtapi.NBTReflectionUtil.convertNMSItemtoNBTCompound(NBTReflectionUtil.java:243) ~[UltraBind-Libraries-1.0.0.jar:?]
        at org.fastmcmirror.ultrabind.libs.nbtapi.NBTItem.convertItemtoNBT(NBTItem.java:347) ~[UltraBind-Libraries-1.0.0.jar:?]
        at org.fastmcmirror.ultrabind.libs.nbtapi.NBT.itemStackToNBT(NBT.java:484) ~[UltraBind-Libraries-1.0.0.jar:?]
        at UltraBind-1.0.0-R3-beta8.jar/org.fastmcmirror.ultrabind.utils.Binder.bindForce(Binder.java:208) ~[UltraBind-1.0.0-R3-beta8.jar:?]
        ... 29 more
Caused by: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:115) ~[?:?]
        at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[?:?]
        at org.fastmcmirror.ultrabind.libs.nbtapi.utils.nmsmappings.ReflectionMethod.run(ReflectionMethod.java:396) ~[UltraBind-Libraries-1.0.0.jar:?]
        at org.fastmcmirror.ultrabind.libs.nbtapi.NBTReflectionUtil.convertNMSItemtoNBTCompound(NBTReflectionUtil.java:243) ~[UltraBind-Libraries-1.0.0.jar:?]
        at org.fastmcmirror.ultrabind.libs.nbtapi.NBTItem.convertItemtoNBT(NBTItem.java:347) ~[UltraBind-Libraries-1.0.0.jar:?]
        at org.fastmcmirror.ultrabind.libs.nbtapi.NBT.itemStackToNBT(NBT.java:484) ~[UltraBind-Libraries-1.0.0.jar:?]
        at UltraBind-1.0.0-R3-beta8.jar/org.fastmcmirror.ultrabind.utils.Binder.bindForce(Binder.java:208) ~[UltraBind-1.0.0-R3-beta8.jar:?]
        ... 29 more
Caused by: java.lang.NullPointerException: Cannot invoke "net.minecraft.core.component.DataComponentType.isTransient()" because "datacomponenttype" is null
        at net.minecraft.core.component.DataComponentPatch.lambda$static$1(DataComponentPatch.java:53) ~[paper-1.21.1.jar:1.21.1-99-1bc02e6]
        at com.mojang.serialization.Encoder$1.encode(Encoder.java:25) ~[datafixerupper-8.0.16.jar:?]
        at com.mojang.serialization.Codec$2.encode(Codec.java:80) ~[datafixerupper-8.0.16.jar:?]
        at com.mojang.serialization.Encoder.encodeStart(Encoder.java:14) ~[datafixerupper-8.0.16.jar:?]
        at com.mojang.serialization.codecs.OptionalFieldCodec.encode(OptionalFieldCodec.java:44) ~[datafixerupper-8.0.16.jar:?]
        at com.mojang.serialization.codecs.OptionalFieldCodec.encode(OptionalFieldCodec.java:17) ~[datafixerupper-8.0.16.jar:?]
        at com.mojang.serialization.MapEncoder$1.encode(MapEncoder.java:26) ~[datafixerupper-8.0.16.jar:?]
        at com.mojang.serialization.MapCodec$2.encode(MapCodec.java:82) ~[datafixerupper-8.0.16.jar:?]
        at com.mojang.serialization.codecs.RecordCodecBuilder$Instance$6.encode(RecordCodecBuilder.java:297) ~[datafixerupper-8.0.16.jar:?]
        at com.mojang.serialization.codecs.RecordCodecBuilder$2.encode(RecordCodecBuilder.java:112) ~[datafixerupper-8.0.16.jar:?]
        at com.mojang.serialization.MapCodec$MapCodecCodec.encode(MapCodec.java:163) ~[datafixerupper-8.0.16.jar:?]
        at com.mojang.serialization.Codec$RecursiveCodec.encode(Codec.java:217) ~[datafixerupper-8.0.16.jar:?]
        at com.mojang.serialization.Encoder.encodeStart(Encoder.java:14) ~[datafixerupper-8.0.16.jar:?]
        at net.minecraft.world.item.ItemStack.save(ItemStack.java:622) ~[paper-1.21.1.jar:1.21.1-99-1bc02e6]
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[?:?]
        at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[?:?]
        at org.fastmcmirror.ultrabind.libs.nbtapi.utils.nmsmappings.ReflectionMethod.run(ReflectionMethod.java:396) ~[UltraBind-Libraries-1.0.0.jar:?]
        at org.fastmcmirror.ultrabind.libs.nbtapi.NBTReflectionUtil.convertNMSItemtoNBTCompound(NBTReflectionUtil.java:243) ~[UltraBind-Libraries-1.0.0.jar:?]
        at org.fastmcmirror.ultrabind.libs.nbtapi.NBTItem.convertItemtoNBT(NBTItem.java:347) ~[UltraBind-Libraries-1.0.0.jar:?]
        at org.fastmcmirror.ultrabind.libs.nbtapi.NBT.itemStackToNBT(NBT.java:484) ~[UltraBind-Libraries-1.0.0.jar:?]
        at UltraBind-1.0.0-R3-beta8.jar/org.fastmcmirror.ultrabind.utils.Binder.bindForce(Binder.java:208) ~[UltraBind-1.0.0-R3-beta8.jar:?]
        ... 29 more

part of code

ItemStack it = item;
NBT.modify(item, nbtItem -> {
            String s = id.toString(); // UUID
            //System.out.println(s);
            nbtItem.setString("ULTRA_BIND", s);
});
 System.out.println(NBT.itemStackToNBT(it));
commented

Checked use plugin version will resolve this problem

commented

That seems like a paper/spigot bug, or you have an issue with the shading and run into the paper remapper. Try using the normal NBTAPI jar, not shading.

commented

That seems like a paper/spigot bug, or you have an issue with the shading and run into the paper remapper. Try using the normal NBTAPI jar, not shading.

My plugin should not be affected by remapper because the class will be loaded from the cloud into the jvm
And I have sent an issue to the paper. The paper believes that the problem is caused by the library.
PaperMC/Paper#11604