Port sand gathering to 26.3

This commit is contained in:
Tanner committed 2026-11-16 22:55:06 +00:00
1 parent f28269f71c
commit 3e8b95c895
9 files changed
+424 -158

No files matched your search

+21
View File
@@ -6,6 +6,27 @@ from mosfet.world import World
class IndexedSearchTests(unittest.TestCase):
def test_sand_search_targets_safe_blocks_in_3x3_slice_only(self):
sand_position = (1, 64, 1)
class SandChunks:
def get_block_at(self, x, y, z):
position = (x, y, z)
if position == sand_position:
return blocks.SAND
if y < sand_position[1]:
return blocks.STONE
return blocks.AIR
world = World(Munch(chunks=SandChunks()))
self.assertTrue(world.check_sand_slice((0, 64, 0)))
self.assertEqual(
world.find_sand((0, 64, 0), 2, (0, 64, 0)),
[sand_position])
sand_position = (2, 64, 0)
self.assertFalse(world.check_sand_slice((0, 64, 0)))
def test_index_deduplication_is_linear_and_sort_is_optional(self):
far = (10, 64, 0)
near = (1, 64, 0)
+25
View File
@@ -107,6 +107,31 @@ class SignReadingTests(unittest.TestCase):
individual_world.sign_policies('mosfet2')], ['circle'])
self.assertEqual(individual_world.sign_policies('mosfet1'), [])
def test_sand_origin_signs_match_bot_and_numbered_group_addresses(self):
chunks = Munch(block_entities={
(1, 64, 0): {'data': {'front_text': {'messages': [
'mosfet', 'sand origin', '', '',
]}}},
(3, 64, 0): {'data': {'back_text': {'messages': [
'mosfet1 sand', 'origin', '', '',
]}}},
(2, 64, 0): {'data': {'front_text': {'messages': [
'mosfet2 sand origin', '', '', '',
]}}},
})
world = World(Munch(chunks=chunks))
origins = world.find_sand_origins((0, 64, 0), 'mosfet1')
self.assertEqual([origin['position'] for origin in origins], [
(1, 64, 0), (3, 64, 0),
])
self.assertEqual(
[origin['position'] for origin in
world.find_sand_origins((0, 64, 0), 'mosfet2')],
[(1, 64, 0), (2, 64, 0)],
)
def test_sign_policies_read_any_distance_within_loaded_signs(self):
position = (100, 64, 0)
chunks = Munch(block_entities={position: {