diff --git a/litemapy/minecraft.py b/litemapy/minecraft.py index ec78ae1..d46c496 100644 --- a/litemapy/minecraft.py +++ b/litemapy/minecraft.py @@ -8,6 +8,13 @@ from typing import Any, Optional, Union +EntityPosition = tuple[float, float, float] +EntityRotation = tuple[float, float] +EntityMotion = tuple[float, float, float] + +BlockPosition = tuple[int, int, int] + + class BlockState: """ Represents an in-game block. @@ -157,9 +164,9 @@ class Entity: """ _data: Compound - _position: tuple[float, float, float] - _rotation: tuple[float, float] - _motion: tuple[float, float, float] + _position: EntityPosition + _rotation: EntityRotation + _motion: EntityMotion # TODO Needs unit tests @@ -259,38 +266,38 @@ def id(self, id: str) -> None: self._data['id'] = String(self._id) @property - def position(self) -> tuple[float, float, float]: + def position(self) -> EntityPosition: """ The position of the entity. """ return self._position @position.setter - def position(self, position: tuple[float, float, float]) -> None: + def position(self, position: EntityPosition) -> None: self._position = position self._data['Pos'] = List[Double]([Double(coord) for coord in self._position]) @property - def rotation(self) -> tuple[float, float]: + def rotation(self) -> EntityRotation: """ The rotation of the entity. """ return self._rotation @rotation.setter - def rotation(self, rotation: tuple[float, float]) -> None: + def rotation(self, rotation: EntityRotation) -> None: self._rotation = rotation self._data['Rotation'] = List[Double]([Double(coord) for coord in self._rotation]) @property - def motion(self) -> tuple[float, float, float]: + def motion(self) -> EntityMotion: """ The velocity vector of the entity. """ return self._motion @motion.setter - def motion(self, motion: tuple[float, float, float]) -> None: + def motion(self, motion: EntityMotion) -> None: self._motion = motion self._data['Motion'] = List[Double]([Double(coord) for coord in self._motion]) @@ -306,7 +313,7 @@ class TileEntity: The ID can be inferred by looking up the :class:`BlockState` as the same position in the :class:`Region`. """ _data: Compound - _position: tuple[int, int, int] + _position: BlockPosition def __init__(self, nbt: Compound) -> None: # TODO Not documented because it only exposes NBT @@ -369,14 +376,14 @@ def data(self, data: Compound): self._position = (position[0], position[1], position[2]) @property - def position(self) -> tuple[int, int, int]: + def position(self) -> BlockPosition: """ The tile entity's position within the :class:`Region`/ """ return self._position @position.setter - def position(self, position: tuple[int, int, int]): + def position(self, position: BlockPosition): self._position = position for coord, index in [('x', 0), ('y', 1), ('z', 2)]: self._data[coord] = Int(self._position[index])