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

    Class PlayerCursorInventoryComponent

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

    system.runInterval(() => {
    for (const player of world.getPlayers()) {
    const cursorInventory = player.getComponent("minecraft:cursor_inventory");
    const item = cursorInventory.item;
    if (!item) continue;

    player.sendMessage("You selected " + item.typeId);
    }
    }, 20);

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    entity: Entity

    This property can throw errors.

    InvalidEntityError

    This property can't be read in early-execution mode.

    isValid: boolean
    item?: ItemStack

    This property can throw errors.

    This property can't be read in early-execution mode.

    typeId: string

    Methods

    • Returns void

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

      This function can throw errors.

      This function can't be called in early-execution mode.