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.
Methods
Section titled “Methods”section.items()
Section titled “section.items()”Returns an iterator over the present ItemObject values
section.find(item_id)
Section titled “section.find(item_id)”Returns a list of items whose ID matches item_id, or [] if none
section.count(item_id=None)
Section titled “section.count(item_id=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
Examples
Section titled “Examples”for item in player.inventory.hotbar: player.log(f'{item.id}: {item.count}')
has_sword = 'diamond_sword' in player.inventory.hotbar