octa Posted May 20, 2021 Share Posted May 20, 2021 (edited) 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 May 20, 2021 by octa Quote Link to comment Share on other sites More sharing options...
ChampionAsh5357 Posted May 20, 2021 Share Posted May 20, 2021 The inventory of a block is dropped by #onRemove in all vanilla cases. Quote Link to comment Share on other sites More sharing options...
octa Posted May 20, 2021 Author Share Posted May 20, 2021 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? Quote Link to comment Share on other sites More sharing options...
octa Posted May 20, 2021 Author Share Posted May 20, 2021 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.