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

    Contains information and methods that can be used at the initialization of the scripting environment for a World. Also, use the supplied blockRegistry object to register block custom components within the scope of the World Initialize execution.

    Index

    Properties

    blockTypeRegistry: BlockComponentRegistry
    itemComponentRegistry: ItemComponentRegistry
    import {
    BlockPermutation,
    ItemComponentMineBlockEvent,
    ItemCustomComponent,
    world,
    } from "@minecraft/server";

    class MineDiamondComponent implements ItemCustomComponent {
    onMineBlock(e: ItemComponentMineBlockEvent): void {
    const { minedBlockPermutation, block } = e;
    if (minedBlockPermutation.matches("minecraft:diamond_ore")) {
    block.setPermutation(BlockPermutation.resolve("minecraft:stone"));
    }
    }
    }

    world.beforeEvents.worldInitialize.subscribe((event) => {
    event.itemComponentRegistry.registerCustomComponent(
    "jayly:custom_item",
    new MineDiamondComponent()
    );
    });