Nodes

The Nodes object provides methods to get and manipulate nodes in the game world. When you retrieve a node, it is returned as a Node object, which contains its position, name, and other properties.

class miney.Nodes(luanti: Luanti)[source]

Manipulate and get information’s about node.

Nodes manipulation is currently tested for up to 25.000 node, more optimization will come later

get(point: Point | Node | Iterable) Node | list[Any] | None[source]

Get the node at the given position. It returns a node object. This contains the “x”, “y”, “z”, “param1”, “param2” and “name” attributes, where “name” is the node type like “default:dirt”.

If instead of a single point/node a list or tuple with 2 points/nodes is given, this function returns a list of nodes. This list contains a cuboid of nodes with the diagonal between the given points.

Tip: You can get a list of all available node types with type.

Parameters:

point – A Point object

Returns:

The node type on this position

property names: NameIterable

In Luanti, the type of the node, something like “dirt”, is the “name” of this node.

This property returns all available node names in the game, sorted by categories. In the end it just returns the corresponding Luanti name string, so lt.nodes.names.default.dirt returns the string ‘default:dirt’. It’s a nice shortcut in REPL, cause with auto completion you have only pressed 2-4 keys to get to your type.

Examples:

Directly access a type:

>>> lt.nodes.names.default.dirt
'default:dirt'

Iterate over all available types:

>>> for node_type in lt.nodes.names:
>>>     print(node_type)
default:pine_tree
default:dry_grass_5
farming:desert_sand_soil
... (there should be over 400 different types)
>>> print(len(lt.nodes.names))
421

Get a list of all types:

>>> list(lt.nodes.names)
['default:pine_tree', 'default:dry_grass_5', 'farming:desert_sand_soil', ...

Add 99 dirt to player “IloveDirt“‘s inventory:

>>> lt.players.IloveDirt.inventory.add(lt.nodes.names.default.dirt, 99)
Return type:

NameIterable

Returns:

TypeIterable object with categories. Look at the examples above for usage.

set(node: Node | list) None[source]

Set a single or multiple nodes at a given position.

You can get a list of all available node names with name.

The `node` parameter can be a single Node object or a list of Node objects for bulk setting.

Examples:

Replace the node under the first player’s feet with dirt:

>>> from miney import Node, Point
>>> player_pos = lt.players[0].position
>>> pos_under_player = player_pos - Point(0, 1, 0)
>>> dirt_node = Node(pos_under_player.x, pos_under_player.y, pos_under_player.z, name="default:dirt")
>>> lt.nodes.set(dirt_node)

Set multiple nodes to create a 2x1 stone platform:

>>> from miney import Node
>>> player_pos = lt.players[0].position
>>> nodes_to_set = [
...     Node(player_pos.x + 2, player_pos.y -1, player_pos.z, name="default:stone"),
...     Node(player_pos.x + 3, player_pos.y -1, player_pos.z, name="default:stone")
... ]
>>> lt.nodes.set(nodes_to_set)
Parameters:

node – A single Node object or a list of Node objects.