Jump to content

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


Cakestory

Recommended Posts

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?

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

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!
}

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.

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

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

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.