Manages callbacks that are connected to when an explosion occurs, as it impacts individual blocks.

Example

blockExplodeEvent.ts

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 });
});

Hierarchy

  • BlockExplodeAfterEventSignal

Constructors

Methods

Constructors

Methods

  • Parameters

    Returns ((arg) => void)

      • (arg): void
      • Parameters

        Returns void

        Remarks

        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.

    Remarks

    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.

  • Parameters

    Returns void

    Remarks

    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.

    This function can be called in early-execution mode.