Posted January 19, 20187 yr So there are events to check before an explosion starts and before explosion affects blocks. How to check when an explosion is done(including all the calls to the HarvestDropEvent)? I need this to check if the block harvested was from an explosion or not. Basically I need a way to hook into this event: /** * Called when this Block is destroyed by an Explosion */ public void onBlockDestroyedByExplosion(World worldIn, BlockPos pos, Explosion explosionIn) { } Edited January 19, 20187 yr by TheAwesomeGem New Channel: https://www.youtube.com/theawesomegemily'>https://www.youtube.com/theawesomegemily My Group: https://www.youtube.com/officialpixelgem Old Channel: https://www.youtube.com/theawesomegem
January 19, 20187 yr Hmmm. There isn't any nice way to do it. If you are looking for explosions from a custom explosive then you could probably extend the Explosion class and override the behavior to give yourself a hook. But if you want to handle vanilla explosions basically I think what you will need to do is to handle the explosion detonate event and copy the list of affected blocks from the event and store it in a public field. Then in the harvest block event you should check if the block position is in that list. Then you should clear the copy of the list every tick, probably in a server tick handler. Edited January 19, 20187 yr by jabelar Check out my tutorials here: http://jabelarminecraft.blogspot.com/
January 19, 20187 yr Author 2 hours ago, jabelar said: Hmmm. There isn't any nice way to do it. If you are looking for explosions from a custom explosive then you could probably extend the Explosion class and override the behavior to give yourself a hook. But if you want to handle vanilla explosions basically I think what you will need to do is to handle the explosion detonate event and copy the list of affected blocks from the event and store it in a public field. Then in the harvest block event you should check if the block position is in that list. Then you should clear the copy of the list every tick, probably in a server tick handler. Sadly, that's the way I am doing it but it's not working well if there are multiple explosions on top of each other. I wish there was a unique identifier for explosion. Thanks btw! Edited January 19, 20187 yr by TheAwesomeGem New Channel: https://www.youtube.com/theawesomegemily'>https://www.youtube.com/theawesomegemily My Group: https://www.youtube.com/officialpixelgem Old Channel: https://www.youtube.com/theawesomegem
January 19, 20187 yr 13 minutes ago, TheAwesomeGem said: Sadly, that's the way I am doing it but it's not working well if there are multiple explosions on top of each other. I wish there was a unique identifier for explosion. Thanks btw! It should be unique for each explosion, the event should be called each time the explosion is called. So you can create a unique list of blocks from the affected blocks in each event. What exactly are you trying to achieve anyway? Check out my tutorials here: http://jabelarminecraft.blogspot.com/
January 19, 20187 yr Author 4 minutes ago, jabelar said: It should be unique for each explosion, the event should be called each time the explosion is called. So you can create a unique list of blocks from the affected blocks in each event. What exactly are you trying to achieve anyway? Change block drop if there was explosion. I know there is an event for each explosion but how do I tag which explosion is which? I am using Chunk capability to store a list of affected blocks from an explosion. However whenever the tick interval ends, I don't know which explosion caused the block affected. So sometimes i clear the affected blocks before it even gets to the HarvestBlock event where I customize the block drop. New Channel: https://www.youtube.com/theawesomegemily'>https://www.youtube.com/theawesomegemily My Group: https://www.youtube.com/officialpixelgem Old Channel: https://www.youtube.com/theawesomegem
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.