Posted December 25, 20159 yr I'm trying to save player NBT in an external file and be able to load it later when the player logs in. In a PlayerLoggedInEvent listener I put the code: NBTInputStream inputStream = new NBTInputStream(new GZIPInputStream(new FileInputStream(savedFile))); CompoundTag savedCompound = (CompoundTag) inputStream.readTag(); for(Map.Entry<String, ITag> entry : savedCompound.getTags().entrySet()){ ITag tag = entry.getValue(); event.player.getEntityData().setTag(tag.getName(), getType(tag)); } I implemented an NBT reader to parse through the data in the file, as you can't get the value or name of tags with the minecraft classes, so that's what ITag and CompoundTag are. getType(tag) just returns a new NBTBase of the correct type (NBTTagByte, NBTTagInt, etc) with the value in the ITag. The NBT file is read just fine, however the player's NBT remains the same after this, as displayed by their inventory remaining empty rather than filling up with the saved inventory. How can I make it update with the new data?
December 26, 20159 yr Author Well, getEntityData doesn't seem to be saving the changes I made to it for some reason. I don't want to add new data to the player, but rather change the values of the fields that it already has, such as inventory, health, etc. Could I do this with IExtendedEntityProperties?
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.