Skip to content
BasaltSoftware
Bedrock 1.26.60

Site colour

Discord
Esc

    ↑↓ moveEnter openEsc close

    Keyboard shortcuts
    Ctrl K
    Search the whole site, from any page
    /
    Jump to the sidebar search, or search the whole site where there isn't one
    Enter
    Open the top search result
    Esc
    Clear the search, or close this panel
    ?
    Show these shortcuts

    Class in @minecraft/server

    A player’s 36 inventory slots, the hotbar first, or the slots inside an item.

    import { Container } from '@minecraft/server';

    read-only

    readonly size: number;

    read-only

    readonly isValid: boolean;

    read-only

    readonly emptySlotsCount: number;

    read-only

    readonly weight: number;

    The combined bundle weight of the contents.

    read-only optional

    readonly containerRules?: ContainerRules;

    The rules on what the container accepts, if any.

    getItem(slot: number): ItemStack | undefined;
    Parameters
    slot
    number
    Returns
    ItemStack | undefined
    setItem(slot: number, itemStack?: ItemStack): void;

    Puts an item in a slot, or empties it with undefined.

    Parameters
    slot
    number
    itemStackoptional
    ItemStack
    addItem(itemStack: ItemStack): ItemStack | undefined;

    Gives the item, dropping what doesn’t fit. Basalt doesn’t say what was left.

    Parameters
    itemStack
    ItemStack
    Returns
    ItemStack | undefined
    clearAll(): void;
    contains(itemStack: ItemStack): boolean;

    Whether a slot holds this item, whatever the amount.

    Parameters
    itemStack
    ItemStack
    Returns
    boolean
    find(itemStack: ItemStack): number | undefined;

    The first slot holding this item, whatever the amount.

    Parameters
    itemStack
    ItemStack
    Returns
    number | undefined
    findLast(itemStack: ItemStack): number | undefined;

    The last slot holding this item.

    Parameters
    itemStack
    ItemStack
    Returns
    number | undefined
    firstEmptySlot(): number | undefined;

    The first empty slot, or undefined if it’s full.

    Returns
    number | undefined
    firstItem(): number | undefined;

    The first slot holding anything.

    Returns
    number | undefined
    swapItems(slot: number, otherSlot: number, otherContainer: Container): void;

    Swaps a slot of this container with one of another, or of this one again.

    Parameters
    slot
    number
    otherSlot
    number
    otherContainer
    Container
    getSlot(slot: number): ContainerSlot;

    A live handle on a slot.

    Parameters
    slot
    number
    Returns
    ContainerSlot
    moveItem(fromSlot: number, toSlot: number, toContainer: Container): void;

    Moves an item to another slot of a container.

    Parameters
    fromSlot
    number
    toSlot
    number
    toContainer
    Container
    transferItem(fromSlot: number, toContainer: Container): ItemStack | undefined;

    Transfers an item into the first fitting slot of a container.

    Parameters
    fromSlot
    number
    toContainer
    Container
    Returns
    ItemStack | undefined

    ItemInventoryComponent.container, EntityInventoryComponent.container, BlockInventoryComponent.container, EntityEnderInventoryComponent.container