Script API - v26.60
    Preparing search index...

    Class ItemTypes

    Returns the set of item types registered within Minecraft.

    export class ItemTypes {
    private constructor();
    static get(itemId: string): ItemType | undefined;
    static getAll(): ItemType[];
    }
    Index
    • Parameters

      • itemId: string

      Returns ItemType | undefined

      Returns a specific item type, if available within Minecraft.

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

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

      // Run `/scriptevent example:getappletype` in chat to inspect the apple item type.
      system.afterEvents.scriptEventReceive.subscribe(({ id, sourceEntity }) => {
      if (id !== "example:getappletype" || !(sourceEntity instanceof Player)) return;

      const itemType = ItemTypes.get("minecraft:apple");
      if (!itemType) return;

      sourceEntity.sendMessage(`Found item type: ${itemType.id}`);
      });
    • Returns ItemType[]

      Retrieves all available item types registered within Minecraft.

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

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

      // Run `/scriptevent example:listitemtypes` in chat to list registered item type IDs.
      system.afterEvents.scriptEventReceive.subscribe(({ id, sourceEntity }) => {
      if (id !== "example:listitemtypes" || !(sourceEntity instanceof Player)) return;

      const itemIds = ItemTypes.getAll().map((itemType) => itemType.id);
      sourceEntity.sendMessage(`Item types (${itemIds.length}): ${itemIds.slice(0, 10).join(", ")}`);
      });