Manages callbacks that are connected to when an explosion occurs, as it impacts individual blocks.
import { world, BlockExplodeAfterEvent } from "@minecraft/server";// Subscribe to the blockExplode eventworld.afterEvents.blockExplode.subscribe((event: BlockExplodeAfterEvent) => { const { source, block, explodedBlockPermutation, dimension } = event; // Log details of the explosion event console.log(`Block exploded at position: ${block.location}`); console.log(`Block type: ${explodedBlockPermutation.type.id}`); console.log(`Dimension: ${dimension.id}`); if (source) { console.log(`Explosion caused by: ${source.id}`); } else { console.log(`Explosion caused by an unknown source`); } // Example: Create an explosion at the block location dimension.createExplosion(block.location, 5, { causesFire: true });}); Copy
import { world, BlockExplodeAfterEvent } from "@minecraft/server";// Subscribe to the blockExplode eventworld.afterEvents.blockExplode.subscribe((event: BlockExplodeAfterEvent) => { const { source, block, explodedBlockPermutation, dimension } = event; // Log details of the explosion event console.log(`Block exploded at position: ${block.location}`); console.log(`Block type: ${explodedBlockPermutation.type.id}`); console.log(`Dimension: ${dimension.id}`); if (source) { console.log(`Explosion caused by: ${source.id}`); } else { console.log(`Explosion caused by an unknown source`); } // Example: Create an explosion at the block location dimension.createExplosion(block.location, 5, { causesFire: true });});
Adds a callback that will be called when an explosion occurs, as it impacts individual blocks.
This function can't be called in read-only mode.
This function can be called in early-execution mode.
Removes a callback from being called when an explosion occurs, as it impacts individual blocks.
Manages callbacks that are connected to when an explosion occurs, as it impacts individual blocks.
Example: blockExplodeEvent.ts