Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

  • 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.

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.