Querz / NBT

A java implementation of the NBT protocol, including a way to implement custom tags.
MIT License
182 stars 48 forks source link

CompoundTag .get method returning null with valid key #93

Open p1gyy opened 1 year ago

p1gyy commented 1 year ago

i am trying to get the LevelName from a level.dat file but whenever I try to do that it always returns null

CompoundTag namedTag = (CompoundTag)NBTUtil.read(levelDat).getTag();
this.WORLD_NAME = namedTag.getStringTag("LevelName").getValue();

LOGGER.info(WORLD_NAME);

Caused by: java.lang.NullPointerException: Cannot invoke "net.querz.nbt.tag.StringTag.getValue()" because the return value of "net.querz.nbt.tag.CompoundTag.getStringTag(String)" is null