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.

Featured Replies

Posted

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

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/

  • 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 by TheAwesomeGem

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/

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

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.