Jump to content

Recommended Posts

Posted

For the mod I'm making, I need to know how to save extra data to the player. Is there a way for me to do it with NBT data? I'm going to need to save 3 integers and a byte. If anyone knows how I can do this, please let me know. If I need to save it to a custom external file, how would I set up the directory for the file? I already know how to save and read from external files.

Posted

Assuming you have an instance of EntityPlayer (we'll call this 'player'), you can use player.getEntityData() and do whatever you need to there.

Posted

By default, getting an object from an NBTTagCompound will return 0 if the key doesn't exist. You might try using hasKey checks. I haven't had any problems with this before, so here's what I would do:

 

if(player.getEntityData().hasKey("lifePoints"))

{

    //do stuff

}

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.