Player
Represents a player on the server and allows changing their properties like their view, speed, or gravity.
Each player has an Inventory which can be accessed via the inventory property.
- Example:
>>> lt.players.MyPlayer.position <<< Point(x=10, y=5, z=-20)
- class miney.Player(luanti: Luanti, name)[source]
A player of the Luanti server.
- property creative: bool
Get and set the player’s creative mode.
Note
The implementation of this property is game-dependent. For games like MineClone2, it uses the native
mcl_gamemodesystem. For other games, it falls back to granting or revoking thecreativeprivilege.- Returns:
Trueif the player is in creative mode,Falseotherwise.
- property gravity
Get or set the players gravity. Default is 1.
- Returns:
Float
- property hp
Get and set the number of hitpoints (2 * number of hearts) between 0 and 20. By setting his hitpoint to zero you instantly kill this player.
- Returns:
- inventory: Inventory
Manipulate player’s inventory.
- Example to add 99 dirt to player “IloveDirt“‘s inventory:
>>> import miney >>> lt = miney.Luanti() >>> lt.players.IloveDirt.inventory.add(lt.nodes.names.default.dirt, 99)
- Example to remove 99 dirt from player “IhateDirt“‘s inventory:
>>> import miney >>> lt = miney.Luanti() >>> lt.players.IhateDirt.inventory.remove(lt.nodes.names.default.dirt, 99)
- property invisible: bool
Get or set the player’s visibility.
When set to
True, the player model, nametag, and minimap marker are hidden. WhenFalse, restores normal appearance.Note
This feature may not work for mobs in some games, so they may still attack the player. Maybe it’s better to move the player to a safe spot.
- Returns:
Trueif the player is currently invisible,Falseotherwise.
- property jump
Get or set the players jump height. Default is 1.
- Returns:
Float
- property look: dict
Get and set look in radians. Horizontal angle is counter-clockwise from the +z direction. Vertical angle ranges between -pi/2 (~-1.563) and pi/2 (~1.563), which are straight up and down respectively.
- Returns:
A dict like {‘v’: 0.34, ‘h’: 2.50} where h is horizontal and v = vertical
- property look_dir: Vector
Get or set the player’s look direction as a normalized vector.
- Returns:
A
Vectorrepresenting the look direction.
- property look_horizontal
Get and set yaw in radians. Angle is counter-clockwise from the +z direction.
- Returns:
Pitch in radians
- property look_vertical
Get and set pitch in radians. Angle ranges between -pi/2 (~-1.563) and pi/2 (~1.563), which are straight up and down respectively.
- Returns:
Pitch in radians
- move(destination: Point | None = None, distance: float | None = None, look_at: Point | None = None, yaw: float | None = None, pitch: float | None = None, smooth: bool = False, duration: float = 1.0, step_interval: float = 0.05)[source]
Moves the player and/or changes their look direction, with an option for smooth animation.
This versatile function can perform several actions: 1. Instantly teleport the player (smooth=False). 2. Instantly change the player’s look direction (smooth=False). 3. Animate the player’s movement to a new location (smooth=True). 4. Animate the player’s view to a new orientation (smooth=True). 5. Combine movement and look changes, either instantly or animated.
Examples:
import miney from miney.point import Point import math lt = miney.Luanti() player = lt.players["some_player"] # 1. Instant teleport to a specific coordinate player.move(destination=Point(10, 20, 30)) # 2. Smoothly fly the player to a destination over 3 seconds player.move(destination=Point(50, 40, 50), smooth=True, duration=3) # 3. Instantly make the player look at a point player.move(look_at=Point(0, 20, 0)) # 4. Smoothly turn the player to face North (yaw=PI) over 2 seconds player.move(yaw=math.pi, smooth=True, duration=2) # 5. Move 10 nodes forward smoothly player.move(distance=10, smooth=True) # 6. Smoothly move to a destination while turning to look at another point player.move( destination=Point(100, 25, 100), look_at=Point(0, 20, 0), smooth=True, duration=5 )
- Parameters:
destination – The target position as a
Point.distance – The distance to move forward (alternative to destination).
look_at – A
Pointto look at (alternative to yaw/pitch).yaw – The final horizontal look angle (yaw) in radians. The angle is measured counter-clockwise from the positive Z-axis (South). Common values are: -
0: South (+Z) -math.pi / 2: East (+X) -math.pi: North (-Z) -3 * math.pi / 2: West (-X)pitch – The final vertical look angle (pitch) in radians. It ranges from
-math.pi / 2(looking straight up) tomath.pi / 2(looking straight down).0is looking horizontally forward.smooth – If
True, the action is animated over duration. IfFalse, it’s instant.duration – The total time for the animation in seconds (if smooth=True).
step_interval – The time between each animation step (if smooth=True).
- Raises:
ValueError – If conflicting or no parameters are provided.
- property position: Point
Get or set the players current position.
To place a player on top of a specific node, add 0.5 to the y value and his feet will touch this node. A player needs two blocks in the y axis (he’s around 1,5 node tall), or he is stuck.
- Returns:
- property privileges: PrivilegeManager
Get, set, or modify player privileges using a list-like interface.
This property provides an intuitive way to manage permissions on the server. It returns a special
PrivilegeManagerobject that behaves like a list of strings.Examples:
# Get a player object player = lt.player["some_player"] # 1. List all privileges # Returns a list of strings, e.g., ['interact', 'shout'] current_privs = player.privileges.list() print(f"Current privileges: {current_privs}") # You can also iterate over it directly for priv in player.privileges: print(f"Player has privilege: {priv}") # 2. Check for a specific privilege if "fly" in player.privileges: print("Player can fly!") else: print("Player cannot fly.") # 3. Grant (append) a new privilege # This sends a command to the server to add 'fly'. player.privileges.append("fly") assert "fly" in player.privileges # 4. Revoke (remove) a privilege # This sends a command to the server to remove 'fly'. player.privileges.remove("fly") assert "fly" not in player.privileges # 5. Overwrite all privileges # This replaces all existing privileges with the new list. player.privileges = ["interact", "fast", "noclip"] assert player.privileges.list() == ["interact", "fast", "noclip"]
- Returns:
A
PrivilegeManagerinstance.