Jump to content

NBTtag storing variable number in TileEntity always reads and writes 2 values


Recommended Posts

Posted

Hi there,

 

I have been making a custom TileEntity and the basic idea is that you put 9 Gel into the block and when 9 of those are extracted (the number increases every time after 1 is extracted) a certain item is "created". So i have it all working, but i wanted to make it so that my GUI shows the correct number so i thought of using the NBTTagCompound Read and Write to save the ammount of gel (also because i wanted it to be saved whenever you close the game etc). To see what it is writing and reading i did the following:

@Override
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
System.out.println("[soul Forest] write : " + (short)this.gelAmmountExtracted);
par1NBTTagCompound.setShort("Gel", (short)this.gelAmmountExtracted);
// Some more code below (but thats for itemstacks) so i left it out
}

Now in the console i get the following values 1, 0. And whenever another gel is updated i get 2 and 0 etc. So 2 lines are being printed with 2 values and thats why my GUI picks up 0 continuesly, but how do i make it so that i don't read and write 2 values.

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.