Class: ContainerSlot
Represents a slot within a broader container (e.g., entity inventory.)
Constructors
new ContainerSlot()
private
new ContainerSlot():ContainerSlot
Returns
Properties
amount
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
readonly
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.
keepOnDeath
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
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
readonly
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?
optional
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
readonly
type:ItemType
Remarks
The type of the item.
Throws
Throws if the slot's container is invalid.
minecraftcommon.EngineError
typeId
readonly
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
clearDynamicProperties()
clearDynamicProperties():
void
Returns
void
Remarks
Clears all dynamic properties that have been set on this item stack.
Throws
Throws if the slot's container is invalid.
getCanDestroy()
getCanDestroy():
string
[]
Returns
string
[]
Throws
This function can throw errors.
getCanPlaceOn()
getCanPlaceOn():
string
[]
Returns
string
[]
Throws
This function can throw errors.
getDynamicProperty()
getDynamicProperty(
identifier
):string
|number
|boolean
|Vector3
Parameters
Parameter | Type | Description |
---|---|---|
identifier | string | The property identifier. |
Returns
string
| number
| boolean
| Vector3
Returns the value for the property, or undefined if the property has not been set.
Remarks
Returns a property value.
Throws
Throws if the slot's container is invalid.
getDynamicPropertyIds()
getDynamicPropertyIds():
string
[]
Returns
string
[]
A string array of the dynamic properties set on this entity.
Remarks
Returns the available set of dynamic property identifiers that have been used on this item stack.
Throws
Throws if the slot's container is invalid.
getDynamicPropertyTotalByteCount()
getDynamicPropertyTotalByteCount():
number
Returns
number
Remarks
Returns the total size, in bytes, of all the dynamic properties that are currently stored for this entity. This includes the size of both the key and the value. This can be useful for diagnosing performance warning signs - if, for example, an entity has many megabytes of associated dynamic properties, it may be slow to load on various devices.
Throws
Throws if the slot's container is invalid.
getItem()
getItem():
ItemStack
Returns
Returns a copy of the item in the slot. Returns undefined if the slot is empty.
Remarks
Creates an exact copy of the item stack, including any custom data or properties.
Throws
Throws if the slot's container is invalid.
getLore()
getLore():
string
[]
Returns
string
[]
An array of lore strings. If the item does not have lore, returns an empty array.