Make sign policy distance unlimited

This commit is contained in:
Tanner committed 2026-11-10 18:45:53 +00:00
1 parent 5c6c08e3c0
commit 315bc212dc
2 files changed
+19 -2

No files matched your search

+3 -2
View File
@@ -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
+16
View File
@@ -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': [