allow to serialize to tuple
This commit is contained in:
parent
fea68999dd
commit
ca18387cff
1 changed files with 5 additions and 2 deletions
|
@ -10,8 +10,11 @@ class BlockPos:
|
||||||
z : float
|
z : float
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_tuple(cls, t:Tuple[int, int, int]):
|
def from_tuple(cls, t:Tuple[float, float, float]):
|
||||||
return cls(x=t[0], y=t[1], z=t[2])
|
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'):
|
def distance(self, p:'BlockPos'):
|
||||||
return sqrt(
|
return sqrt(
|
||||||
|
|
Loading…
Reference in a new issue