Inventory

Management of items in an inventory, such as a player’s inventory or a chest.

An Inventory object is not created directly. It is accessed through the inventory property of other objects, like Player or a container Node.

class miney.Inventory(luanti: Luanti, parent: object)[source]

Inventories are places to store items, like Chests or player inventories.

You do not create this yourself - you get one from inventory or inventory.

add(item: str, amount: int = 1) None[source]

Add an item to an inventory. Possible items can be obtained from names.

Parameters:
  • item – item type

  • amount – item amount

Returns:

None

Raises:

TypeError – If this inventory belongs to neither a player nor a node

get_list(name: str = 'main') list[str][source]

Get the content of an inventory list.

Only the occupied slots come back, as strings like "mcl_core:apple 5" - the empty ones are left out rather than filling the answer with placeholders.

Parameters:

name – The name of the list to get (e.g., “main”).

Returns:

A list of item strings, empty if the inventory list is.

Raises:

TypeError – If this inventory belongs to neither a player nor a node

get_lists() list[str][source]

Get the names of all available inventory lists.

Returns:

A list of inventory list names (e.g., [“main”, “craft”]), empty if there are none.

Raises:

TypeError – If this inventory belongs to neither a player nor a node

remove(item: str, amount: int = 1) None[source]

Remove an item from an inventory. Possible items can be obtained from lt.nodes.names.

Parameters:
  • item – item type

  • amount – item amount

Returns:

None

Raises:

TypeError – If this inventory belongs to neither a player nor a node