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.

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

Featured Replies

Posted

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

  • Author

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?

  • Author

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. 

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

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.