From ca18387cff0a037c1353bdea65a632cdb3621368 Mon Sep 17 00:00:00 2001 From: alemidev Date: Fri, 10 Dec 2021 23:14:12 +0100 Subject: [PATCH] allow to serialize to tuple --- aiocraft/mc/definitions.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/aiocraft/mc/definitions.py b/aiocraft/mc/definitions.py index e80f46f..c406969 100644 --- a/aiocraft/mc/definitions.py +++ b/aiocraft/mc/definitions.py @@ -10,8 +10,11 @@ class BlockPos: z : float @classmethod - def from_tuple(cls, t:Tuple[int, int, int]): - return cls(x=t[0], y=t[1], z=t[2]) + def from_tuple(cls, t:Tuple[float, float, float]): + return cls(x=float(t[0]), y=float(t[1]), z=float(t[2])) + + def to_tuple(self, cast=float) -> Tuple[float, float, float]: + return (cast(self.x), cast(self.y), cast(self.z)) def distance(self, p:'BlockPos'): return sqrt(