Jump to content

Recommended Posts

Posted

I have a field of type String on a TileEntity provided by a block. When I break and then pick up the block, I want the string on the ItemStack in the player's inventory. My intention is to use the string when I place the block again with method

 

	public void onBlockPlacedBy(World w, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {

 

I have overridden

	public void harvestBlock(World worldIn, EntityPlayer playerIn, BlockPos pos, IBlockState state, TileEntity te) {

 

which gives me the string, but I don't know how to put it on the ItemStack's NBT when the player picks the block up. Any help appreciated.

Posted

Here is my getDops modeled on BlockFlowerPot:

 

  Reveal hidden contents

 

 

but te is coming up null (maybe because it was broken?). Do I still need to override harvestBlock and pass string path somehow? Or is there a problem with my TileEntity?

 

 

  Reveal hidden contents

 

Posted

Is there something else I have missed? Now the block does not drop when I break it. (Same behavior when I don't override harvestBlock)

 

 

  Reveal hidden contents

 

 

Here my console. Is it normal that removeByPlayer is called twice with different values for willHarvest?

 

 

  Reveal hidden contents

 

 

 

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.