Jump to content

Recommended Posts

Posted

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?

Posted

Use the item values to change the tileentity state.

Something like:

onItemUse(world, itemstack,x,y,z...)
{
data = getData(itemstack.getTagCompound());
(MyTileEntity)world.getBlockTileEntity(x,y,z).changeState(data);
}

Posted

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.

Posted

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).

 

Posted

If I want the item to actually render like a block, is that going to be a huge ordeal of building a custom renderer or something, or is there some shortcut way to make it render the item as if it's an existing block?

 

Posted

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

 

 

*EDIT*

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

Posted

you could tottally use the same code for the IItemRenderer as the TileEntitySpecialRenderer, nothign is stopping you to do it :)

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

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.