construct BlockPos from tuple
This commit is contained in:
parent
d21a37c28b
commit
fea68999dd
1 changed files with 5 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
from math import sqrt
|
from math import sqrt
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
from typing import Tuple
|
||||||
|
|
||||||
@dataclass # TODO use the one from types
|
@dataclass # TODO use the one from types
|
||||||
class BlockPos:
|
class BlockPos:
|
||||||
|
@ -8,6 +9,10 @@ class BlockPos:
|
||||||
y : float
|
y : float
|
||||||
z : 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'):
|
def distance(self, p:'BlockPos'):
|
||||||
return sqrt(
|
return sqrt(
|
||||||
( self.x - p.x ) ** 2 +
|
( self.x - p.x ) ** 2 +
|
||||||
|
|
Loading…
Reference in a new issue