[SPIGOT-7617] getBlock() Returns air for BlockExplodeEvent Created: 23/Apr/24  Updated: 25/Dec/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: Silly lil Goober Assignee: Parker Hawke
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Duplicate
duplicates SPIGOT-6371 Bed explosion bug with BlockExplodeEvent Resolved
Version: 1.20.4-R0.1-SNAPSHOT
Guidelines Read: Yes

 Description   

im trying to get the block that caused the BlockExplodeEvent with getBlock() 

@EventHandler
public void onBlockExplosion(BlockExplodeEvent event)  {
    Block block = event.getBlock();
    getLogger().info("Block Explosion Detected! "+block);
    if (plugin.cancelRespawnAnchorExplosionGrief) {
        getLogger().info("1 ");
        event.blockList().clear();
    }

}

however it returns 

CraftBlock{pos=BlockPosition{x=-28, y=91, z=28},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@5630d714} 

I was told in the discord that this was a bug and to make a ticket or whatever.



 Comments   
Comment by Parker Hawke [ 24/Apr/24 ]

Because of the way explosions are implemented, there's really no solution to this. The best way to provide the block that was exploded would be to pass in BlockData to the event, which is what I'm opting to do instead.

Comment by Silly lil Goober [ 23/Apr/24 ]

This is Fancy

 

Generated at Sun Mar 30 02:36:43 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.