Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Strange Itemstack NBT behaviour

Recommended Posts

I have a staff item that I want to have drain energy on usage, the current way I have it set up is that this function in the staff class is called via a tickhandler:

public float doDrawEnergy(ItemStack item, EntityPlayer player, float energy)
        if(item.getTagCompound().getFloat("charge") > energy)
            item.setTagInfo("charge", new NBTTagFloat("charge",item.getTagCompound().getFloat("charge") - energy));
            return energy;
            float out = item.getTagCompound().getFloat("charge");
            item.setTagInfo("charge", new NBTTagFloat("charge",0));
            return out;

The problem is that the "charge" nbt value doesn't always change, specifically it only that the getFloat function only returns the latest set value after opening a GUI (ie: it only seems to upate the value after opening a GUI), and I have absoluetly no idea why or how this happens.

Link to post
Share on other sites
  • 2 months later...

I'm doing the same kind of thing and I have no idea how to get ItemStack containers to save NBT data

"Thinking that coding is the nerdy IT guy at work rebooting your computer is like thinking that music is what happens when the piano tuner comes round." - Ed Rex

Link to post
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.

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.

  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.