[SPIGOT-6371] Bed explosion bug with BlockExplodeEvent Created: 19/Feb/21  Updated: 29/Apr/24  Resolved: 29/Apr/24

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Frank van der Heijden Assignee: Unassigned
Resolution: Done Votes: 1
Labels: None

Issue Links:
Duplicate
is duplicated by SPIGOT-7617 getBlock() Returns air for BlockExplo... Resolved
Version: 3013-Spigot-73fb609-0cd8f19 (MC: 1.16.5)
Guidelines Read: Yes

 Description   

Whenever a bed is exploded in the nether, the block thats included in the BlockExplodeEvent is AIR. It's possible to get the block anyway by checking the PlayerInteractEvent & caching the location of a bed right click from the nether.



 Comments   
Comment by md_5 [ 29/Apr/24 ]

I think SPIGOT-7617 being fixed makes this unnecessary

Comment by Michael Botsko [ 03/Jun/22 ]

I'd like to add that this is inconsistent with how EntityExplodeEvent works. event.getEntity() returns the entity, TNT, Creeper, etc.

Comment by Michael Botsko [ 03/Jun/22 ]

This used to work, I have a plugin that relied on it but am noticing it no longer works. There's no easy way to identify the "cause" of the explosion if the getBlock is always AIR. There's no indication if it was a bed, respawn anchor, etc. Maybe the change was intentional, but it's not ideal it can't tell me what the original block was. 

Comment by Martoph [ 02/May/21 ]

I believe you're describing intended behavior.

If you prime and explode TNT, the TNT entity and block goes away. If you want to prevent this, just cancel the interact event.

Why should this work differently with a bed?

Comment by Julian v.d Berkmortel [ 10/Apr/21 ]

Inside "net.minecraft.world.level.block.BlockBed#explodeBed" the block which is the bed is set to air before the explosion is actually created, keeping it from even being destroyed by the explosion and thus appear in the list of blocks passed to the event.

I moved the explosion to the beginning of the method, before any block is set to air and I also removed the code which set the block to air in the first place. I came up with the questions below which should be answered before a solution can be thought of.

  • What should happen if the explosion (by chance) does not destroy the bed itself?
  • What should happen if the bed (by chance) is dropped as an item after being destroyed?
  • If we were to set the original block to air after the explosion was created, this would override any changes made in the "BlockExplodeEvent" event
  • Because a bed consists of two blocks, this causes there to be two bed blocks in the list of blocks passed to the "BlockExplodeEvent" event, which might be confusing and problematic for some
Generated at Sat Apr 05 09:53:30 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.