Jump to content

Recommended Posts

Posted

Hello all

 

I'm trying to initialize an item when an ItemStack of it has entered the world without much luck. The Item.onCreated() method seems to only be called when the item is crafted or smelted but not when pulled out of a creative tab and I don't see any form of onDestroy() method.

 

For a little more info, I'm trying to implement item entities but I need to bind them to their respective item by saving a unique identifier to the item's metadata. And this needs to be done only once, when the item enters the world, and the entity needs to be destroyed when the item leaves the world.

 

Is there any way forge can help me with this problem? Or have I just missed something in vanilla?

Bits are dangerous! If you mess with them, you might get nibbles or even bytes; and if you keep doing it, you'll get hertz!

Posted

So you try to link an EntityItem to the Item's metadata? Vanilla already does that. Every EntityItem has an associated ItemStack which is exactly the one that is dropped on the ground, etc.

Do you mean something else? Please be more specific.

 

Does the entity still exist when the item is in an inventory? I'm trying to give an item an inventory that you can open from your inventory (kind of like a bag).

 

Edit: When I initially said item entity, I meant like a tile entity but for an Item/ItemStack, instead of a block.

Bits are dangerous! If you mess with them, you might get nibbles or even bytes; and if you keep doing it, you'll get hertz!

Posted

You need to use the NBTTagCompound of an ItemStack then to store the inventory.

 

Ah! So that's what NBTTagCompound is used for. Thanks.

Bits are dangerous! If you mess with them, you might get nibbles or even bytes; and if you keep doing it, you'll get hertz!

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.