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.

[1.7.2] [S] Explosion resistant block destroyed by explosion (PlayerDropsEvent)

Featured Replies

Posted

Hi,

I have a block with the same resistance as bedrock that is explosion proof when placed in the world and trying to destroy it with tnt or creepers.

This block is placed (with a TileEntity containing the players drops) when the player dies in PlayerDropsEvent with world.setBlock(x,y,z, block).

It is working fine but when the player dies from an explosion by a creeper or tnt, the placed block seems to be destroyed by that explosion, also it is explosion resistant.

 

Does anyone know how to fix this?

Hi,

 

If you are not relying on metadata for explosion resistance, then that is pretty strange. Perhaps put a println in the onBlockExploded method to see if it is actually getting blown up, or perhaps it is trying to place itself on a block that gets destroyed, and is affected (for example if you require it to be on a solid block and not on air).

 

Tough to say without seeing the block and event code, and tile entity, too, if it has anything to do with the explosion resistance.

 

If you ARE using metadata for explosion resistance, read on:

 

 

I posted a bug report about a possibly related issue on the Mojang Bug Tracker some time ago:

 

https://bugs.mojang.com/browse/MC-50079

 

My problem was that I was using the block metadata to determine explosion resistance, which was being calculated incorrectly from the vanilla method passing the incorrect coordinates; I resolved it by overriding the onBlockExploded method (since that of course has the correct coordinates), and re-checking my metadata value to make sure the block could actually explode.

 

 

  • Author

That was a perfect idea. It indeed was destroyed by the explosion. And telling me to use the onBlockExploded method was exactly the right thing. I just leave it empty.

As the super method which sets the block to air, is overriden this way, the block is not destroyed anymore.

Thank you coolAlias.

 

Solution:

@Override
public void onBlockExploded(World world, int x, int y, int z, Explosion explosion) {
// Do not call super.onBlockExploded(...) here!
}

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.