Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Saving TileEntity data such as an Integer to Dropped Item when Block is broken


Recommended Posts

Basically just the title

My current idea is that I can use the "getDrops" method like in the ShulkerBoxBlock class and apply a "item tag" with the data, but I am not sure if an "item tag" is even a thing nor how to properly use the "getDrops" method (do I retain the loot table for the block).

Is there another mod that does something like this that isn't related to container items like shulker boxes, just some type of data? If so a link to it would be the only help I need. If not, then would someone mind explaining how this might be done?

Link to comment
Share on other sites

There is a generic tag for items ("BlockEntityTag"). If the item has this tag, it will be applied to the block entity after placement - provided that you haven't overridden onlyOpCanSetNbt or the player is op.

This is what shulker boxes use as well using the copy_nbt loot function. Look at the shulker box loot table to see how it is done.

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.

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