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

Constructors

Properties

amount: number

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 if the value is outside the range of 1-255.

isStackable: boolean

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 if the slot's container is invalid.

InvalidContainerSlotError

isValid: boolean

Returns whether the ContainerSlot is valid. The container slot is valid if the container exists and is loaded, and the slot index is valid.

keepOnDeath: boolean

Gets or sets whether the item is kept on death.

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

Throws if the slot's container is invalid.

lockMode: ItemLockMode

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 if the slot's container is invalid.

maxAmount: number

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 if the slot's container is invalid.

InvalidContainerSlotError

nameTag?: string

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 if the slot's container is invalid. Also throws if the length exceeds 255 characters.

type: ItemType

The type of the item.

Throws if the slot's container is invalid.

minecraftcommon.EngineError

InvalidContainerSlotError

typeId: string

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

Throws if the slot's container is invalid.

InvalidContainerSlotError

Methods