From fea68999ddb5c3af9b6e4eba7b96773502255c08 Mon Sep 17 00:00:00 2001 From: alemidev Date: Fri, 10 Dec 2021 23:11:19 +0100 Subject: [PATCH] construct BlockPos from tuple --- aiocraft/mc/definitions.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/aiocraft/mc/definitions.py b/aiocraft/mc/definitions.py index c08897f..e80f46f 100644 --- a/aiocraft/mc/definitions.py +++ b/aiocraft/mc/definitions.py @@ -1,6 +1,7 @@ from math import sqrt from enum import Enum from dataclasses import dataclass +from typing import Tuple @dataclass # TODO use the one from types class BlockPos: @@ -8,6 +9,10 @@ class BlockPos: y : float z : float + @classmethod + def from_tuple(cls, t:Tuple[int, int, int]): + return cls(x=t[0], y=t[1], z=t[2]) + def distance(self, p:'BlockPos'): return sqrt( ( self.x - p.x ) ** 2 +