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 event
world.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 });
});

Methods

  • Parameters

    Returns void

    Removes a callback from being called when an explosion occurs, as it impacts individual blocks.

    This function can't be called in read-only mode.