Skip to content

utils

position_to_chunk_relative

Python
position_to_chunk_relative(
    position: Vector3D[int],
) -> Tuple[Vector2D[int], Vector3D[int], int]

Split absolute world position into chunk, relative block position, and section.

PARAMETER DESCRIPTION
position

Absolute world position (x, y, z).

TYPE: Vector3D[int]

RETURNS DESCRIPTION
Tuple[Vector2D[int], Vector3D[int], int]

Chunk coordinates (chunk_x, chunk_z), Relative position in chunk and section (rel_x, rel_y, rel_z), Section Y coordinate.


calculate_block_face

Python
calculate_block_face(
    observer: Vector3D[float], block: Vector3D[int]
) -> int

Calculate which face of a block the observer is most likely targeting.

PARAMETER DESCRIPTION
observer

Observer's current position (usually eye level).

TYPE: Vector3D[float]

block

Block position (x, y, z).

TYPE: Vector3D[int]

RETURNS DESCRIPTION
int

Face being targeted: - 0: down - 1: up - 2: north - 3: south - 4: west - 5: east