From 315bc212dcf81902adb4d2810cae9a4926586e4b Mon Sep 17 00:00:00 2001 From: Tanner Date: Tue, 10 Nov 2026 18:45:53 +0000 Subject: [PATCH] Make sign policy distance unlimited --- mosfet/world.py | 5 +++-- tests/test_signs.py | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/mosfet/world.py b/mosfet/world.py index 39b2e5b..83b31e0 100644 --- a/mosfet/world.py +++ b/mosfet/world.py @@ -67,7 +67,8 @@ class World: if hasattr(chunks, 'block_entities_snapshot') else dict(chunks.block_entities)) for position, entity in entities.items(): - if utils.phyp(center, position) > distance: + if (distance is not None and + utils.phyp(center, position) > distance): continue get_block_at = getattr(self.g.chunks, 'get_block_at', None) if callable(get_block_at): @@ -313,7 +314,7 @@ class World: result.sort(key=lambda chest: utils.phyp(center, chest['position'])) return result - def sign_policies(self, bot_name, distance=64): + def sign_policies(self, bot_name, distance=None): """Parse sign policies addressed to this bot or its numbered group.""" bot_name = str(bot_name).casefold() group_name = (bot_name[:-1] if len(bot_name) > 1 and diff --git a/tests/test_signs.py b/tests/test_signs.py index e3a2baa..e5c688d 100644 --- a/tests/test_signs.py +++ b/tests/test_signs.py @@ -107,6 +107,22 @@ class SignReadingTests(unittest.TestCase): individual_world.sign_policies('mosfet2')], ['circle']) self.assertEqual(individual_world.sign_policies('mosfet1'), []) + def test_sign_policies_read_any_distance_within_loaded_signs(self): + position = (100, 64, 0) + chunks = Munch(block_entities={position: { + 'data': {'front_text': {'messages': [ + 'mosfet2', 'stay within 35 square', '', '', + ]}}, + }}) + world = World(Munch(chunks=chunks, pos=(0, 64, 0))) + + policies = world.sign_policies('mosfet2') + + self.assertEqual(policies, [{ + 'position': position, 'distance': 35, + 'shape': 'square', 'side': 'front', + }]) + def test_nearest_sign_policy_overrides_farther_matching_sign(self): chunks = Munch(block_entities={ (-138, 71, -268): {'data': {'front_text': {'messages': [