Class ItemStack

Defines a collection of items.

Hierarchy

  • ItemStack

Constructors

  • Parameters

    • itemType: ItemType

      Type of item to create. See the MinecraftItemTypes enumeration for a list of standard item types in Minecraft experiences.

    • Optional amount: number

      Number of items to place in the stack, between 1 and 64. Note that certain items can only have one item in the stack.

    • Optional data: number

      Optional data value used for creating the item, or 0 if no data value is specified.

    Returns ItemStack

    Remarks

    Creates a new instance of a stack of items for use in the world.

Properties

amount: number

Number of the items in the stack. Valid values range between 0 and 64.

data: number

A data value used to configure alternate states of the item.

nameTag?: string

Given name of this stack of items.

typeId: string

Methods

  • Parameters

    • componentId: string

      The identifier of the component (e.g., 'minecraft:food') to retrieve. If no namespace prefix is specified, 'minecraft:' is assumed. If the component is not present on the item stack, undefined is returned.

    Returns any

    Remarks

    Gets a component (that represents additional capabilities) for an item stack.

  • Returns any[]

    Remarks

    Returns all components that are both present on this item stack and supported by the API.

  • Returns string[]

    Remarks

    Returns the lore value - a secondary display string - for an ItemStack.

  • Parameters

    • componentId: string

      The identifier of the component (e.g., 'minecraft:food') to retrieve. If no namespace prefix is specified, 'minecraft:' is assumed.

    Returns boolean

    Remarks

    Returns true if the specified component is present on this item stack.

  • Parameters

    • loreList: string[]

    Returns void

    Remarks

    Sets the lore value - a secondary display string - for an ItemStack.

  • Parameters

    • eventName: string

      Name of the item type event to trigger. If a namespace is not specified, minecraft: is assumed.

    Returns void

    Remarks

    Triggers an item type event. For custom items, a number of events are defined in an items' definition for key item behaviors.