Jump to content

[1.7.2] NBT data are not saved


DoctorBooooom

Recommended Posts

I wrote a mod that creates a system of levels, but it does not properly retains NBT data

I go to the game, I Level 5 (https://www.dropbox.com/s/ahsy2bqqai7uvb5/2014-02-15_14.52.11.png)

I used the command to get XP, and my level is a 19 (https://www.dropbox.com/s/yb6h6z91nv12o2u/2014-02-15_14.52.25.png)

Relogin and... failure! my level is not 19, only 6! (https://www.dropbox.com/s/ms49a7a489jgf5b/2014-02-15_14.52.34.png)

 

this is my code:

a class that includes the login and logout events - http://pastebin.com/g7dXxHCa

DataPlayer, which contains details of the player, and some methods - http://pastebin.com/B9PD2J5k

And method from StatsUtil that check exp and call levelUp if need. http://pastebin.com/j8uxui2D

Link to comment
Share on other sites

The types are defined in the NBTBase class:

public static final String[] NBTTypes = new String[] {"END", "BYTE", "SHORT", "INT", "LONG", "FLOAT", "DOUBLE", "BYTE[]", "STRING", "LIST", "COMPOUND", "INT[]"};

Either count to the position of the type that you need, starting at zero (END is 0, BYTE is 1, etc.), or if you have an NBTBase of any type you can use nbtbase.getId() to return the correct id.

 

@Override
public void readFromNBT(NBTTagCompound compound) {
super.readFromNBT(compound);
// here is use the compound.getId(), but I could just write '10' instead
// since I know that I stored NBTTagCompounds in this particular NBTTagList
NBTTagList items = compound.getTagList("Items", compound.getId());
// etc.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.