Skip to content

Inventory

endstone.inventory

Classes:

Name Description
Inventory

Interface to the various inventories.

ItemMeta

Represents the metadata of a generic item.

ItemStack

Represents a stack of items.

MapMeta

Represents the metadata for a map item.

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

Stores the ItemStack at the given index of the inventory.

ItemMeta

Represents the metadata of a generic item.

Methods:

Name Description
clone

Creates a clone of the current metadata.

Attributes:

Name Type Description
damage int

Gets or sets the damage.

display_name str | None

Gets or sets the display name.

has_damage bool

Checks to see if this item has damage

has_display_name bool

Checks for existence of a display name.

has_lore bool

Checks for existence of lore.

lore list[str] | None

Gets or sets the lore for this item.

damage property writable

damage: int

Gets or sets the damage.

display_name property writable

display_name: str | None

Gets or sets the display name.

has_damage property

has_damage: bool

Checks to see if this item has damage

has_display_name property

has_display_name: bool

Checks for existence of a display name.

has_lore property

has_lore: bool

Checks for existence of lore.

lore property writable

lore: list[str] | None

Gets or sets the lore for this item.

clone

clone() -> ItemMeta

Creates a clone of the current metadata.

ItemStack

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

Represents a stack of items.

Methods:

Name Description
set_item_meta

Set the ItemMeta of this ItemStack.

Attributes:

Name Type Description
amount int

Gets or sets the amount of items in this stack.

item_meta ItemMeta

Gets a copy of the ItemMeta of this ItemStack.

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.

item_meta property

item_meta: ItemMeta

Gets a copy of the ItemMeta of this ItemStack.

type property writable

type: str

Gets or sets the type of this item.

set_item_meta

set_item_meta(meta: ItemMeta) -> bool

Set the ItemMeta of this ItemStack.

MapMeta

Bases: ItemMeta

Represents the metadata for a map item.

PlayerInventory

Bases: Inventory

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

Attributes:

Name Type Description
boots ItemStack

Gets or sets the ItemStack in the boots slot

chestplate ItemStack

Gets or sets the ItemStack in the chestplate slot

held_item_slot int

Gets or sets the slot number of the currently held item

helmet ItemStack

Gets or sets the ItemStack in the helmet slot

item_in_main_hand ItemStack

Gets or sets the item the player is currently holding in their main hand.

item_in_off_hand ItemStack

Gets or sets the item the player is currently holding in their off hand.

leggings ItemStack

Gets or sets the ItemStack in the leg slot

boots property writable

boots: ItemStack

Gets or sets the ItemStack in the boots slot

chestplate property writable

chestplate: ItemStack

Gets or sets the ItemStack in the chestplate slot

held_item_slot property writable

held_item_slot: int

Gets or sets the slot number of the currently held item

helmet property writable

helmet: ItemStack

Gets or sets the ItemStack in the helmet slot

item_in_main_hand property writable

item_in_main_hand: ItemStack

Gets or sets the item the player is currently holding in their main hand.

item_in_off_hand property writable

item_in_off_hand: ItemStack

Gets or sets the item the player is currently holding in their off hand.

leggings property writable

leggings: ItemStack

Gets or sets the ItemStack in the leg slot