Posted February 15, 201411 yr 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
February 16, 201411 yr Author As it turned out, writes NBT date correctly. However reads not correctly. Probably a mistake in NBTTagList nbtListStats = nbtPlayer.getTagList("Stats", 9); , because there was no 1.6.4 2nd parameter, and now I have taken it at random.
February 16, 201411 yr 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. http://i.imgur.com/NdrFdld.png[/img]
February 16, 201411 yr Or use the Constants class from forge. Oh, I didn't know that existed! Sweet http://i.imgur.com/NdrFdld.png[/img]
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.