Class ContainerSlotBeta

Represents a slot within a broader container (e.g., entity inventory.)

Hierarchy

  • ContainerSlot

Constructors

Properties

amount: number

Remarks

Number of the items in the stack. Valid values range between 1-255. The provided value will be clamped to the item's maximum stack size.

This property can't be edited in read-only mode.

Throws

Throws if the value is outside the range of 1-255.

isStackable: boolean

Remarks

Returns whether the item is stackable. An item is considered stackable if the item's maximum stack size is greater than 1 and the item does not contain any custom data or properties.

Throws

Throws if the slot's container is invalid.

isValid: boolean
keepOnDeath: boolean

Remarks

Gets or sets whether the item is kept on death.

This property can't be edited in read-only mode.

Throws

Throws if the slot's container is invalid.

lockMode: ItemLockMode

Remarks

Gets or sets the item's lock mode. The default value is ItemLockMode.none.

This property can't be edited in read-only mode.

Throws

Throws if the slot's container is invalid.

maxAmount: number

Remarks

The maximum stack size. This value varies depending on the type of item. For example, torches have a maximum stack size of 64, while eggs have a maximum stack size of 16.

Throws

Throws if the slot's container is invalid.

nameTag?: string

Remarks

Given name of this stack of items. The name tag is displayed when hovering over the item. Setting the name tag to an empty string or undefined will remove the name tag.

This property can't be edited in read-only mode.

Throws

Throws if the slot's container is invalid. Also throws if the length exceeds 255 characters.

type: ItemType

Remarks

The type of the item.

Throws

Throws if the slot's container is invalid.

typeId?: string

Remarks

Identifier of the type of items for the stack. If a namespace is not specified, 'minecraft:' is assumed. Examples include 'wheat' or 'apple'.

Throws

Throws if the slot's container is invalid.

Methods

  • Returns ItemStack

    Remarks

    Creates an exact copy of the item stack, including any custom data or properties.

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

    Throws

    Throws if the slot's container is invalid.

  • Returns ItemStack

    Remarks

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

    Throws

    This function can throw errors.

  • Returns string[]

    An array of lore strings. If the item does not have lore, returns an empty array.

    Remarks

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

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

    Throws

    Throws if the slot's container is invalid.

  • Returns string[]

    Remarks

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

    Throws

    This function can throw errors.

  • Parameters

    • tag: string

    Returns boolean

    Remarks

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

    Throws

    This function can throw errors.

  • Parameters

    Returns boolean

    Remarks

    Returns whether this item stack can be stacked with the given itemStack. This is determined by comparing the item type and any custom data and properties associated with the item stacks. The amount of each item stack is not taken into consideration.

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

    Throws

    Throws if the slot's container is invalid.

  • Parameters

    • Optional blockIdentifiers: string[]

    Returns void

    Remarks

    The list of block types this item can break in Adventure mode. The block names are displayed in the item's tooltip. Setting the value to undefined will clear the list.

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

    Throws

    Throws if the slot's container is invalid. Also throws if any of the provided block identifiers are invalid.

  • Parameters

    • Optional blockIdentifiers: string[]

    Returns void

    Remarks

    The list of block types this item can be placed on in Adventure mode. This is only applicable to block items. The block names are displayed in the item's tooltip. Setting the value to undefined will clear the list.

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

    Throws

    Throws if the slot's container is invalid. Also throws if any of the provided block identifiers are invalid.

  • Parameters

    Returns void

    Remarks

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

    Throws

    This function can throw errors.

  • Parameters

    • Optional loreList: string[]

    Returns void

    Remarks

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

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

    Throws

    Throws if the slot's container is invalid.