From 7327d4764dafc8055d3726dee66e44d6ae64e3d9 Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 15 Mar 2023 23:01:43 +0100 Subject: [PATCH] feat: utility method to compare BlockPos --- aiocraft/mc/definitions.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/aiocraft/mc/definitions.py b/aiocraft/mc/definitions.py index 62692b4..a453e9b 100644 --- a/aiocraft/mc/definitions.py +++ b/aiocraft/mc/definitions.py @@ -92,6 +92,11 @@ class BlockPos: and self.y == other.y \ and self.z == other.z + def close(self, other:'BlockPos', threshold:float = 0.1) -> bool: + return (self.x - other.x) < threshold \ + and (self.y - other.y) < threshold \ + and (self.z - other.z) < threshold + def __repr__(self) -> str: return f"{self.__class__.__name__}(x={self.x},y={self.y},z={self.z})"