Jump to content

How to preserve TileEntity info when a block is picked up?


Recommended Posts

I'm trying to figure out how to maintain TileEntity data when breaking and placing a block.  The OpenBlocks source code has some clues in it (spawning an EntityItem with the appropriate data stored in it), but when I place the block again, the data is lost.  I'm assuming that there's something I need to do with the item is placed, but I'm not sure what.  Any ideas?

Link to comment
Share on other sites

I'm still kind of in the dark here.  Block doesn't have an onItemUse function, so does that mean I need to create a custom Item class that, when placed, spawns the block and inserts the entity data?  I don't see any way to get the itemstack from inside the Block class when the block is placed.

Link to comment
Share on other sites

I'm assuming that there's something I need to do with the item is placed

You said you had an item.


The easy way is certainly to use an item to place the block. Which means you want noone to get the actual block, only the item.

Then when block is broken, spawn an EntityItem which contains the item (again, not the block).


Link to comment
Share on other sites

Or you could just have the block... and the item... and the tileentity.


All you have to do is, in the method that returns what the block drops, you create a new Item and give it all the data it needs, and then spawn the EntityItem with that item you spawned. And that item is the item etc, that you create




Just relized that it wouldn't look like a block though, it would be the 2D item. But hey, it would be easier xD

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.


I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

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.


  • Create New...

Important Information

By using this site, you agree to our Terms of Use.