Class in @minecraft/server
A live handle on one slot of a container or equipment, correct as the item in it changes.
import { ContainerSlot } from '@minecraft/server';Properties
Section titled “Properties”isValid
Section titled “isValid”read-only
readonly isValid: boolean;Whether the slot is still usable.
amount
Section titled “amount”read-only
readonly amount: number;How many items are in the slot, or 0 when it’s empty.
typeId
Section titled “typeId”read-only optional
readonly typeId?: string;The item’s identifier, or undefined when the slot is empty.
read-only
readonly type: ItemType;The slot’s item type, whose id is typeId.
nameTag
Section titled “nameTag”optional
nameTag?: string;The item’s custom name, or undefined.
maxAmount
Section titled “maxAmount”read-only
readonly maxAmount: number;How many of the item fit in one slot.
isStackable
Section titled “isStackable”read-only
readonly isStackable: boolean;Whether the item stacks above 1.
keepOnDeath
Section titled “keepOnDeath”keepOnDeath: boolean;Whether the item stays with a player who dies.
lockMode
Section titled “lockMode”lockMode: ItemLockMode;How the item is held in place.
Methods
Section titled “Methods”getItem
Section titled “getItem”getItem(): ItemStack | undefined;The item in the slot, or undefined if it’s empty.
ItemStack | undefinedsetItem
Section titled “setItem”setItem(itemStack?: ItemStack): void;Puts an item in the slot, or empties it when given no item.
itemStackoptionalItemStack
hasItem
Section titled “hasItem”hasItem(): boolean;Whether the slot holds an item.
booleanisStackableWith
Section titled “isStackableWith”isStackableWith(itemStack: ItemStack): boolean;Whether the two could share a slot.
itemStackItemStack
booleangetLore
Section titled “getLore”getLore(): string[];The lines under the item’s name.
string[]getRawLore
Section titled “getRawLore”getRawLore(): RawMessage[];The same as raw messages.
RawMessage[]setLore
Section titled “setLore”setLore(loreList?: (RawMessage | string)[]): void;Sets the lore; nothing takes it away.
loreListoptional(RawMessage | string)[]
getCanDestroy
Section titled “getCanDestroy”getCanDestroy(): string[];Blocks an adventure player may break with it.
string[]setCanDestroy
Section titled “setCanDestroy”setCanDestroy(blockIdentifiers?: string[]): void;blockIdentifiersoptionalstring[]
getCanPlaceOn
Section titled “getCanPlaceOn”getCanPlaceOn(): string[];Blocks an adventure player may place it on.
string[]setCanPlaceOn
Section titled “setCanPlaceOn”setCanPlaceOn(blockIdentifiers?: string[]): void;blockIdentifiersoptionalstring[]
getTags
Section titled “getTags”getTags(): string[];The item type’s tags.
string[]hasTag
Section titled “hasTag”hasTag(tag: string): boolean;tagstring
booleangetDynamicProperty
Section titled “getDynamicProperty”getDynamicProperty(identifier: string): boolean | number | string | Vector3 | undefined;One of this plugin’s dynamic properties on the item.
identifierstring
boolean | number | string | Vector3 | undefinedgetDynamicPropertyIds
Section titled “getDynamicPropertyIds”getDynamicPropertyIds(): string[];string[]getDynamicPropertyTotalByteCount
Section titled “getDynamicPropertyTotalByteCount”getDynamicPropertyTotalByteCount(): number;numbersetDynamicProperty
Section titled “setDynamicProperty”setDynamicProperty(identifier: string, value?: boolean | number | string | Vector3): void;identifierstringvalueoptionalboolean | number | string | Vector3
setDynamicProperties
Section titled “setDynamicProperties”setDynamicProperties(values: Record<string, boolean | number | string | Vector3 | undefined>): void;valuesRecord<string, boolean | number | string | Vector3 | undefined>
clearDynamicProperties
Section titled “clearDynamicProperties”clearDynamicProperties(): void;Used by
Section titled “Used by”Container.getSlot, EntityEquippableComponent.getEquipmentSlot