Jump to content

Recommended Posts

Posted

Have you searched?  this is well documented.  There is also good examples in the bukkit community that could be cross referenced.

 

After you have done all that, let us know what you had trouble with.

Long time Bukkit & Forge Programmer

Happy to try and help

Posted

As always: It depends™.

Where does that variable belong to?

To a Block? Use a TileEntity or metadata (only 4 bits, most likely not enough if you say "variable").

To an Item? Use the NBTTagCompound attached to every ItemStack.

To an Entity? Use writeToNBT / readFromNBT or IExtendedEntityProperties in case it is not your entity.

To a specific world (=dimension)? Use WorldSavedData with World#perWorldStorage.

To a save file? Use WorldSavedData with World.mapStorage.

To the Mod in general? Use the Configuration class provided by forge, or just a normal file for more complex data (you can use the normal Java file writing mechanics here).

 

I want to do it on an food item.

Can you give an example on how can i do this.

Posted

Thanks i am able to add data to nbt but how can i take data from there.

I want to use the if statement for the data in TickHandler.

I dont know how can i check that. If that nbt key have the proper data saved in it.

Posted

To get the data from the ItemStack you need to get the ItemStack first of course. Where do you want that to be? In the players inventory? Somewhere else?

Well as it is a food item so i wanna check if player has ever eaten this which i am storing in the nbt then on tickhandler i wanna check that if the player has ever eaten that and if true then the process carry on if false than break.

 

Actually i am trying to make an infinite potioneffect for the food. That can last even after the player die or close the game or drink milk. I will add a new item which will break this process.

Posted

Then... the variable doesn't belong to the Item, because the Item is eaten. -.-

You need to store it into the Player, use IExtendedEntityProperties.

Can you give example on how to use that

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.