CoordinateObject
A CoordinateObject is a dict-like coordinate value returned by player.position, player.rotation, player.motion, and player.spawn_position. Two-dimensional coordinates use x and y; three-dimensional coordinates also include z.
Methods
Section titled “Methods”CoordinateObject supports coordinate arithmetic with another compatible vector or a number, including +, -, *, /, //, %, and exponentiation. Arithmetic between two and three-dimensional objects is not supported.
Its string representation joins the coordinate values with spaces for use in Minecraft commands; see the example below.
Attributes
Section titled “Attributes”| Attribute | Type | Description |
|---|---|---|
position.x | int / float | X coordinate or rotation component |
position.y | int / float | Y coordinate or rotation component |
position.z | int / float | Z coordinate, when present |
Examples
Section titled “Examples”Command formatting
Section titled “Command formatting”player = server.get_player('Example')server.execute(f'tp {player} {player.spawn_position}')
# The formatted command would be:>>> 'tp Example 10 20 30'Offset a location
Section titled “Offset a location”location = player.positionserver.log(f'Current position: {location}')server.log(f'Moved point: {location + 5}')Calculate a position delta between two players
Section titled “Calculate a position delta between two players”player_1 = server.get_player('player_1')player_2 = server.get_player('player_2')distance = player_1.position - player_2.position