Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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?

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);
}

  • Author

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.

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

 

  • Author

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?

 

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

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.