Failure to obtain NBTCompound for NBTTileEntity
ChenCMD opened this issue ยท 8 comments
environment
Item-NBT-API version: 2.9.2
spigot version: 1.18.2-R0.1-SNAPSHOT (3482-Spigot-42b6152-e87f2e3)
details
When I tried to construct NBTTileEntity
with Container
class BlockState and perform toString, getCompound, etc., the following exception occurred and I could not get the data.
de.tr7zw.nbtapi.NbtApiException: [Selfchecked]Exception while getting NBTCompound from TileEntity!
at de.tr7zw.nbtapi.NBTReflectionUtil.getTileEntityNBTTagCompound(NBTReflectionUtil.java:247)
at de.tr7zw.nbtapi.NBTTileEntity.getCompound(NBTTileEntity.java:36)
at de.tr7zw.nbtapi.NBTCompound.asNBTString(NBTCompound.java:800)
at de.tr7zw.nbtapi.NBTCompound.toString(NBTCompound.java:772)
~~~~~~omit~~~~~~
Caused by: java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "target" is null
at de.tr7zw.nbtapi.utils.nmsmappings.ReflectionMethod.run(ReflectionMethod.java:180)
at de.tr7zw.nbtapi.NBTReflectionUtil.getTileEntityNBTTagCompound(NBTReflectionUtil.java:237)
at de.tr7zw.nbtapi.NBTTileEntity.getCompound(NBTTileEntity.java:36)
at de.tr7zw.nbtapi.NBTCompound.asNBTString(NBTCompound.java:800)
at de.tr7zw.nbtapi.NBTCompound.toString(NBTCompound.java:772)
~~~~~~omit~~~~~~
with Container class BlockState
What kind of block did you pass into the constructor?
Chest and Furnance should abolutley work, and in your crash report the [Selfchecked]
means that the plugin also did try that and it worked. What is your code?
Uh, I was writing some simplified code for this and noticed that there is no support for getting NBTCompound in an asynchronous thread by any chance?
Hmmm, perhaps that is the reason.
However, this exception is so non-trivial that I wonder if it would be possible to make it a little easier to understand?
Well, it fails in resolving the data(minecraft returns null instead of a tag), therefore getting a nullpointer exception. And yes future versions should have better error handling that explains the issue better.