Jump to content

Recommended Posts

Posted (edited)

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 by TheAwesomeGem
Posted (edited)

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 by jabelar

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted (edited)
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 by TheAwesomeGem
Posted
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/

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

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.