Skip to content

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.

View the source

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.

AttributeTypeDescription
position.xint / floatX coordinate or rotation component
position.yint / floatY coordinate or rotation component
position.zint / floatZ coordinate, when present
player = server.get_player('Example')
server.execute(f'tp {player} {player.spawn_position}')
# The formatted command would be:
>>> 'tp Example 10 20 30'
location = player.position
server.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