1.14.3 Paper: NBTTileEntity tagging won't work
kangarko opened this issue ยท 7 comments
Hi there,
we are trying to use your library however run into issues while setting tags for NBTTileEntity. Same problem occurs for NBTEntity however NBTItem works as intended.
Here is our code:
The problem is that the tag does not seem to be set, the log messages are both empty. Calling addCompound() result in "Error while adding Compound, got null!" exception either.
Thanks.
Like described in the JavaDocs, Tiles and Entities don't support custom nbt. https://github.com/tr7zw/Item-NBT-API/blob/master/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/NBTTileEntity.java#L6
With version 2.0 I added a way to make it possible, but you'll need to use the NBTInjector that is also contained in the Plugin, or needs to be shaded and setup separately. https://github.com/tr7zw/Item-NBT-API/blob/master/nbt-injector/src/main/java/de/tr7zw/nbtinjector/NBTInjector.java#L168
Basically NBTCompound nbt = NBTInjector.getNbtData(block); allows custom/saved nbt.
Feel free to join the discord for other quick questions https://discord.gg/yk4caxM .
The NBTInjector is part of the standalone plugin. So when adding the 2.0 of the NBTApi to the plugins folder, the the NBTInjector is also avaliable. Also when shading it should also shade Javassist into your plugin, so the only difference to shading only the NBTApi is, that the Injector needs to be enabled during onLoad (https://github.com/tr7zw/Item-NBT-API/blob/master/item-nbt-plugin/src/main/java/de/tr7zw/nbtapi/plugin/NBTAPI.java#L43).
The TileState PersistentDataContainer looks pretty neat, but as you said is 1.14+ only and doesn't work with entities.
Thank you!
Are you planning to release NBTInjector as a standalone plugin? Since 1.14 we can use the TileState class to store permanent metadata, so I was thinking maybe your plugin would server as an excellent backup solution for servers keeping an older MC version.
Shading it is rather complicated since you use Javassist library as well, so having this as a runnable plugin would do the best :)
Thanks and let me know what you think!
That is amazing thank you for all the support!
I would love to include the base NBT classes such as NBTItem into my library for plugins like ChatControl etc. I am open sourcing the library and would like to connect one of the most useful MC libraries such as yours into a unified solution.
Would that be possible? I would of course include the licence and full credit and take up all the responsibility to keep up with your updates.
Yea of cause you can shade it into some other lib/plugin, thats why I've splitted them up into nbtapi, nbtinjector and a standalone plugin that just loads and provides the other two. Inside the nbtapi there's a bStats instance, that gets enables if any plugin happens to use the nbtapi. So even when the api is shaded into some other plugin, for bStats it will look like the server has the shaded into plugin(if it uses bstats), and the nbtapi as an own plugin. This way it doesn't really matter to me how you use the Api ๐
Just a quick note for everyone reading, you can use Entity#getScoreboardTags to store persistent scoreboard tags on an entity. Those are not visible under normal Minecraft conditions: https://www.spigotmc.org/threads/scoreboard-tag-methods.194208/