Jump to content

[SOLVED] How do I Make a Chest Drop it's Contents When it's Destroyed by My Item?


Recommended Posts

I have an item that on right-click destroys blocks in a 3x3x3 volume. Blocks are dropped as intended, but chests do not drop their contents. I've tried world.destroyBlock and block.harvestBlock but neither of them do the trick. Other containers don't drop their contents either, and I've also noticed that a jukebox that is playing a disc will continue playing music after being destroyed with this item, so I must be missing something important. What's the appropriate way to destroy blocks by using an item?

Edited by octa
Link to comment
Share on other sites

It seems like onRemove is deprecated according to the docs, and it doesn't exist in Block or AbstractBlock according to my IDE. onReplaced is the closest I could find, (although it is also deprecated) and that's  where I drop the inventory of my custom containers, so maybe that's what you meant?. onReplaced doesn't really fit what I'm trying to do here either. I was hoping there was some convenient method that handles breaking blocks in any context but that doesn't seem to be the case. Could you clarify how you might go about doing this?

Link to comment
Share on other sites

Thanks for the insight. I was able to resolve all my problems. Perhaps if I posted my code one of you would have noticed this before me, but I was removing any tile entities within the volume before destroying the blocks, which of course meant there was no inventory left to drop. Thanks for the help. 

Link to comment
Share on other sites

  • octa changed the title to [SOLVED] How do I Make a Chest Drop it's Contents When it's Destroyed by My Item?

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.