Get Position

This module aims to provide apis to locate the position of any actual player.

To use APIs here, you must have set up MCDReforged in your environment.

location_api.pos.get_dimension_from_server_reply(content: str, player: str | None = None, regex: str | None = None) str | None[source]

Extracts a dimension string from a text content, like this:

CleMooling has the following entity data: minecraft:overworld

Parameters:
  • content – The text content to extract the dimension from.

  • player – The name of the player. Defaults to None.

  • regex – The regex pattern to match the dimension. Defaults to None.

Returns:

The extracted dimension string or None if not found.

location_api.pos.get_point3d_from_server_reply(content: str, player_name: str | None = None, regex: str | None = None) Point3D | None[source]

Extracts a Point3D instance from a text content, like this:

CleMooling has the following entity data: [-524.5d, 71.0d, -66.5d]

Parameters:
  • content – The text content to extract the 3d point from.

  • player_name – The name of the player. Defaults to None.

  • regex – The regex pattern to match the 3d point. Defaults to None.

Returns:

  • None – If matches No entity was found or if player name is provided but not found in log content.

  • Point3D – If matches format like example.

Raises:

TypeError – If the 3d point cannot be extracted.

location_api.pos.safe_parse_dim(dim_str: str, player: str) str[source]

A wrapper to get a dimension string from a string(rcon command result as server reply).

Actually calls get_dimension_from_server_reply.

Parameters:
  • dim_str – The string to parse.

  • player – The name of the player.

Returns:

The parsed dimension string, but actually a Result object.

location_api.pos.safe_parse_pos(pos_str: str, player: str) Point3D[source]

A wrapper to get a Point3D instance from a string(rcon command result as server reply).

Actually calls get_point3d_from_server_reply.

Parameters:
  • pos_str – The string to parse.

  • player – The name of the player.

Returns:

The parsed Point3D result, but actually a Result object.

async location_api.pos.get_player_pos(player: str) Result[MCPosition, Exception][source]

Get the position of a player.

Parameters:

player – The name of the player.

Returns:

The position of the player or an exception.