Script API - v1.21.90.25
    Preparing search index...

    Interface BlockCustomComponent

    Contains a set of events that will be raised for a block. This object must be bound using the BlockRegistry.

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

    world.beforeEvents.worldInitialize.subscribe((initEvent) => {
    initEvent.blockComponentRegistry.registerCustomComponent("custom:block", {
    beforeOnPlayerPlace: (event) => {
    const { player, block, face, permutationToPlace, dimension } =
    event;
    event.cancel = true; // include this if canceling block placement
    // Your code here
    },
    onEntityFallOn: (event) => {
    const { entity, block, fallDistance, dimension } = event;
    // Your code here
    },
    onPlace: (event) => {
    const { block, dimension, previousBlock } = event;
    // Your code here
    },
    onPlayerDestroy: (event) => {
    const { player, block, dimension, destroyedBlockPermutation } =
    event;
    // Your code here
    },
    onPlayerInteract: (event) => {
    const { player, block, dimension, face, faceLocation } = event;
    // Your code here
    },
    onRandomTick: (event) => {
    const { block, dimension } = event;
    // Your code here
    },
    onStepOff: (event) => {
    const { entity, block, dimension } = event;
    // Your code here
    },
    onStepOn: (event) => {
    const { entity, block, dimension } = event;
    // Your code here
    },
    onTick: (event) => {
    const { block, dimension } = event;
    // Your code here
    },
    });
    });
    import { system } from "@minecraft/server";

    system.beforeEvents.startup.subscribe((initEvent) => {
    initEvent.blockComponentRegistry.registerCustomComponent("custom:block", {
    beforeOnPlayerPlace: (event) => {
    const { player, block, face, permutationToPlace, dimension } =
    event;
    event.cancel = true; // include this if canceling block placement
    // Your code here
    },
    onEntityFallOn: (event) => {
    const { entity, block, fallDistance, dimension } = event;
    // Your code here
    },
    onPlace: (event) => {
    const { block, dimension, previousBlock } = event;
    // Your code here
    },
    onPlayerDestroy: (event) => {
    const { player, block, dimension, destroyedBlockPermutation } =
    event;
    // Your code here
    },
    onPlayerInteract: (event) => {
    const { player, block, dimension, face, faceLocation } = event;
    // Your code here
    },
    onRandomTick: (event) => {
    const { block, dimension } = event;
    // Your code here
    },
    onStepOff: (event) => {
    const { entity, block, dimension } = event;
    // Your code here
    },
    onStepOn: (event) => {
    const { entity, block, dimension } = event;
    // Your code here
    },
    onTick: (event) => {
    const { block, dimension } = event;
    // Your code here
    },
    });
    });
    interface BlockCustomComponent {
        beforeOnPlayerPlace?: (
            arg0: BlockComponentPlayerPlaceBeforeEvent,
            arg1: CustomComponentParameters,
        ) => void;
        onEntityFallOn?: (
            arg0: BlockComponentEntityFallOnEvent,
            arg1: CustomComponentParameters,
        ) => void;
        onPlace?: (
            arg0: BlockComponentOnPlaceEvent,
            arg1: CustomComponentParameters,
        ) => void;
        onPlayerBreak?: (
            arg0: BlockComponentPlayerBreakEvent,
            arg1: CustomComponentParameters,
        ) => void;
        onPlayerInteract?: (
            arg0: BlockComponentPlayerInteractEvent,
            arg1: CustomComponentParameters,
        ) => void;
        onRandomTick?: (
            arg0: BlockComponentRandomTickEvent,
            arg1: CustomComponentParameters,
        ) => void;
        onStepOff?: (
            arg0: BlockComponentStepOffEvent,
            arg1: CustomComponentParameters,
        ) => void;
        onStepOn?: (
            arg0: BlockComponentStepOnEvent,
            arg1: CustomComponentParameters,
        ) => void;
        onTick?: (
            arg0: BlockComponentTickEvent,
            arg1: CustomComponentParameters,
        ) => void;
    }
    Index

    Properties

    beforeOnPlayerPlace?: (
        arg0: BlockComponentPlayerPlaceBeforeEvent,
        arg1: CustomComponentParameters,
    ) => void

    This function will be called before a player places the block.

    onEntityFallOn?: (
        arg0: BlockComponentEntityFallOnEvent,
        arg1: CustomComponentParameters,
    ) => void

    This function will be called when an entity falls onto the block that this custom component is bound to.

    onPlace?: (
        arg0: BlockComponentOnPlaceEvent,
        arg1: CustomComponentParameters,
    ) => void

    This function will be called when the block that this custom component is bound to is placed.

    onPlayerBreak?: (
        arg0: BlockComponentPlayerBreakEvent,
        arg1: CustomComponentParameters,
    ) => void
    onPlayerInteract?: (
        arg0: BlockComponentPlayerInteractEvent,
        arg1: CustomComponentParameters,
    ) => void

    This function will be called when a player sucessfully interacts with the block that this custom component is bound to.

    onRandomTick?: (
        arg0: BlockComponentRandomTickEvent,
        arg1: CustomComponentParameters,
    ) => void

    This function will be called when a block randomly ticks.

    onStepOff?: (
        arg0: BlockComponentStepOffEvent,
        arg1: CustomComponentParameters,
    ) => void

    This function will be called when an entity steps off the block that this custom component is bound to.

    onStepOn?: (
        arg0: BlockComponentStepOnEvent,
        arg1: CustomComponentParameters,
    ) => void

    This function will be called when an entity steps onto the block that this custom component is bound to.

    onTick?: (
        arg0: BlockComponentTickEvent,
        arg1: CustomComponentParameters,
    ) => void

    This function will be called when a block ticks.