fix: abs for distance, limit decimal points
This commit is contained in:
parent
97870d0b10
commit
42a03b0e57
1 changed files with 4 additions and 4 deletions
|
@ -107,15 +107,15 @@ class BlockPos:
|
||||||
and self.z == other.z
|
and self.z == other.z
|
||||||
|
|
||||||
def close(self, other:'BlockPos', threshold:float = 0.1) -> bool:
|
def close(self, other:'BlockPos', threshold:float = 0.1) -> bool:
|
||||||
return (self.x - other.x) < threshold \
|
return abs(self.x - other.x) < threshold \
|
||||||
and (self.y - other.y) < threshold \
|
and abs(self.y - other.y) < threshold \
|
||||||
and (self.z - other.z) < threshold
|
and abs(self.z - other.z) < threshold
|
||||||
|
|
||||||
def clone(self) -> 'BlockPos':
|
def clone(self) -> 'BlockPos':
|
||||||
return BlockPos(self.x, self.y, self.z)
|
return BlockPos(self.x, self.y, self.z)
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return f"{self.__class__.__name__}(x={self.x},y={self.y},z={self.z})"
|
return f"{self.__class__.__name__}(x={self.x:.1f},y={self.y:.1f},z={self.z:.1f})"
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return repr(self)
|
return repr(self)
|
||||||
|
|
Loading…
Reference in a new issue