Skip to content

InventorySection

Represents one section of a player’s inventory, such as player.inventory.hotbar, player.inventory.inventory, or player.inventory.armor. An InventorySection behaves like a dict-like slot collection with integer indexing, iteration, membership checks, and boolean tests for non-empty sections.

View the source

Returns an iterator over the present ItemObject values

Returns a list of items whose ID matches item_id, or [] if none

Counts the total quantity of an item (if item_id is str), the combined quantity of several items (if item_id is a list / tuple of str), or the total number of all items when unspecified. Returns int of the count

for item in player.inventory.hotbar:
player.log(f'{item.id}: {item.count}')
has_sword = 'diamond_sword' in player.inventory.hotbar