NBT-API

NBT-API

98.9k Downloads

1.20.4 NBTEntity getOrCreateCompound(String) throwing NbtApiException

RedW0lfStoneYT opened this issue ยท 2 comments

commented

As said in the title, I cannot seem to create new NBTCompounds for NBTEntity.

NBTEntity nbtEntity = new NBTEntity(entity);
LuaMessageUtils.verboseMessage("Compound name: " + LuaCore.getCompountName()); // Prints valid name that has been used for NBTItem
NBTCompound compound = nbtEntity.getOrCreateCompound(LuaCore.getCompountName()); //  (Line 615)

error

org.bukkit.event.EventException: null
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot-api-1.20.4-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[spigot-api-1.20.4-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:589) ~[spigot-api-1.20.4-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:576) ~[spigot-api-1.20.4-R0.1-SNAPSHOT.jar:?]
        at net.minecraft.server.players.PlayerList.a(PlayerList.java:295) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4060-Spigot-e9ec548-366c3ca]
        at net.minecraft.server.network.ServerConfigurationPacketListenerImpl.a(ServerConfigurationPacketListenerImpl.java:129) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4060-Spigot-e9ec548-366c3ca]
        at net.minecraft.network.protocol.configuration.ServerboundFinishConfigurationPacket.a(SourceFile:20) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4060-Spigot-e9ec548-366c3ca]
        at net.minecraft.network.protocol.configuration.ServerboundFinishConfigurationPacket.a(SourceFile:7) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4060-Spigot-e9ec548-366c3ca]
        at net.minecraft.network.protocol.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:33) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4060-Spigot-e9ec548-366c3ca]
        at net.minecraft.server.TickTask.run(SourceFile:18) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4060-Spigot-e9ec548-366c3ca]
        at net.minecraft.util.thread.IAsyncTaskHandler.d(SourceFile:156) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4060-Spigot-e9ec548-366c3ca]
        at net.minecraft.util.thread.IAsyncTaskHandlerReentrant.d(SourceFile:23) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4060-Spigot-e9ec548-366c3ca]
        at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1191) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4060-Spigot-e9ec548-366c3ca]
        at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:1) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4060-Spigot-e9ec548-366c3ca]
        at net.minecraft.util.thread.IAsyncTaskHandler.x(SourceFile:130) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4060-Spigot-e9ec548-366c3ca]
        at net.minecraft.server.MinecraftServer.bl(MinecraftServer.java:1170) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4060-Spigot-e9ec548-366c3ca]
        at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1163) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4060-Spigot-e9ec548-366c3ca]
        at net.minecraft.util.thread.IAsyncTaskHandler.c(SourceFile:139) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4060-Spigot-e9ec548-366c3ca]
        at net.minecraft.server.MinecraftServer.w_(MinecraftServer.java:1147) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4060-Spigot-e9ec548-366c3ca]
        at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1060) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4060-Spigot-e9ec548-366c3ca]
        at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4060-Spigot-e9ec548-366c3ca]
        at java.lang.Thread.run(Thread.java:840) ~[?:?]
Caused by: dev.selena.libs.nbtapi.NbtApiException: [?][2.12.2]Error while adding Compound, got null!
        at dev.selena.libs.nbtapi.NBTCompound.addCompound(NBTCompound.java:770) ~[?:?]
        at dev.selena.libs.nbtapi.NBTCompound.getOrCreateCompound(NBTCompound.java:805) ~[?:?]
        at dev.selena.luacore.utils.entities.EntityBuilder.spawn(EntityBuilder.java:615) ~[?:?]
        at dev.selena.luacore.utils.entities.EntityBuilder.spawn(EntityBuilder.java:638) ~[?:?]
        at dev.selena.tests.LuaTest.onJoin(LuaTest.java:78) ~[?:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
        at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-api-1.20.4-R0.1-SNAPSHOT.jar:?]
        ... 21 more

Edit: It should be noted that the exact line but for NBTItem has been used in my ItemBuilder.

commented

You are probably trying to add custom nbt to the entity. That won't work like that, as you are in the vanilla nbt scope.
You want to call the getPersistentDataContainer method on NBTEntity to get the custom data scope. Also consider switching to the modern NBT.modify(entity, nbt -> {...})/NBT.modifypersistendData(entity, nbt -> {...}) api.

commented

Closing as inactive.