tool: EXPLOSION
Zarius opened this issue · 11 comments
Change drops from exploded blocks (idea from cyklo's issues page)
Additional to this idea: (onEntityExplode)
EntityListener.onEntityExplode(EntityExplodeEvent event)
Useful for allow creepers to drop something after an explosion (diamonds, zombies, tree, etc)
I thought there was a DAMAGE_EXPLOSION or something like that; would that cover this?
Yeah, but I thought this only triggered why an entity was damaged by an explosion - not blocks. Could still use DAMAGE_EXPLOSION when extending to blocks but need a way to distinguish between a creeper being hit with an explosion and itself exploding.
Note for posterity... it's EXPLOSION@, where is TNT, FIRE[BALL], or CREEPER (or some other creature). Also I think there's ANY_EXPLOSION. Not sure how well it works, though you've been testing it, right?
Well, I thought testing this was how you'd exposed the danger of recursive explosions. <_<
Nope - my test was with events:
GRASS:
- tool: ANY
event: EXPLOSION
chance: 5%
- drop: DIAMOND
Makes quite a nice sized hole in the ground without overloading the server too much :D 100% destroys every connected grass block within the currently connected & loaded chunks and lags the server to death :)
With the improved fix in 985e2e4 allows the first explosion as there is an entity (tntprimed) whereas subsequent explosions use world.createExplosion and have no entity.
I'll test out tool: EXPLOSION soon as I'm sure there's cool stuff to be done with it too.
Oh, I see, you had tool ANY so explosions also matched that.
Your improved fix still isn't perfect (I added a comment in the source). Personally I think the flag-based method for temporarily disabling explosion drops is better, though possibly not quite as naïvely as I initially implemented it.
Noting Celtics comment for future reference: 7d8e989#L14R139
Again not perfect but should work for the vast majority of cases:
With the "power" of an explosion being a float we could perhaps add a "signature" to the end - ie. power = power + 0.0000000000789897 (or whatever the precision of a float allows on all systems) - when we create the explosion and then check those bits in the explosion event.
The best way would be for bukkit itself to allow a tag to be added to explosions so that you can later identify which plugin/event created them (automatically including the plugin name that initiated the explosion would be great).