Skip to content

Inventory

endstone.inventory

Classes:

Name Description
Inventory

Interface to the various inventories.

ItemStack

Represents a stack of items.

PlayerInventory

Interface to the inventory of a Player, including the four armor slots and any extra slots.

Inventory

Interface to the various inventories.

Methods:

Name Description
add_item

Stores the given ItemStacks in the inventory. This will try to fill existing stacks and empty slots as well as it can.

clear

Clears out the whole Inventory.

first

Returns the first slot in the inventory containing an ItemStack with the given stack.

get_item

Returns the ItemStack found in the slot at the given index

set_item

Stores the ItemStack at the given index of the inventory.

Attributes:

Name Type Description
contents list[ItemStack]

Returns all ItemStacks from the inventory

is_empty bool

Check whether this inventory is empty. An inventory is considered to be empty if there are no ItemStacks in any slot of this inventory.

max_stack_size int

Returns the maximum stack size for an ItemStack in this inventory.

size int

Returns the size of the inventory

contents property

contents: list[ItemStack]

Returns all ItemStacks from the inventory

is_empty property

is_empty: bool

Check whether this inventory is empty. An inventory is considered to be empty if there are no ItemStacks in any slot of this inventory.

max_stack_size property

max_stack_size: int

Returns the maximum stack size for an ItemStack in this inventory.

size property

size: int

Returns the size of the inventory

add_item

add_item(item: ItemStack) -> None

Stores the given ItemStacks in the inventory. This will try to fill existing stacks and empty slots as well as it can.

clear

clear() -> None

Clears out the whole Inventory.

first

first(item: ItemStack) -> int

Returns the first slot in the inventory containing an ItemStack with the given stack.

get_item

get_item(index: int) -> ItemStack

Returns the ItemStack found in the slot at the given index

set_item

set_item(index: int, item: ItemStack | None) -> None

Stores the ItemStack at the given index of the inventory.

ItemStack

ItemStack(type: str = 'minecraft:air', amount: int = 1)

Represents a stack of items.

Attributes:

Name Type Description
amount int

Gets or sets the amount of items in this stack.

type str

Gets or sets the type of this item.

amount property writable

amount: int

Gets or sets the amount of items in this stack.

type property writable

type: str

Gets or sets the type of this item.

PlayerInventory

Bases: Inventory

Interface to the inventory of a Player, including the four armor slots and any extra slots.