@minecraft/server
    Preparing search index...

    Class WorldBeforeEventsBeta

    A set of events that fire before an actual action occurs. In most cases, you can potentially cancel or modify the impending event. Note that in before events any APIs that modify gameplay state will not function and will throw an error. (e.g., dimension.spawnEntity)

    Index

    Properties

    This event is triggered after a chat message has been broadcast or sent to players.

    This property can be read in early-execution mode.

    import { world, DimensionLocation } from "@minecraft/server";

    function customCommand(targetLocation: DimensionLocation) {
    const chatCallback = world.beforeEvents.chatSend.subscribe((eventData) => {
    if (eventData.message.includes("cancel")) {
    // Cancel event if the message contains "cancel"
    eventData.cancel = true;
    } else {
    const args = eventData.message.split(" ");

    if (args.length > 0) {
    switch (args[0].toLowerCase()) {
    case "echo":
    // Send a modified version of chat message
    world.sendMessage(`Echo '${eventData.message.substring(4).trim()}'`);
    break;
    case "help":
    world.sendMessage(`Available commands: echo <message>`);
    break;
    }
    }
    }
    });
    }

    This event is triggered after an event has been added to an entity.

    This property can be read in early-execution mode.

    Fires before an entity is removed from the world (for example, unloaded or removed after being killed.)

    This property can be read in early-execution mode.

    This event is fired after an explosion occurs.

    This property can be read in early-execution mode.

    This event fires when an item is successfully used by a player.

    This property can be read in early-execution mode.

    This event fires before a block is broken by a player.

    This property can be read in early-execution mode.

    This property can be read in early-execution mode.

    Fires before a player interacts with a block.

    This property can be read in early-execution mode.

    Fires before a player interacts with an entity.

    This property can be read in early-execution mode.

    Fires when a player leaves the game.

    This property can be read in early-execution mode.

    This event fires before a block is placed by a player.

    This property can be read in early-execution mode.

    This property can be read in early-execution mode.