Synchronize world chunk index updates

This commit is contained in:
Tanner
2026-11-08 17:14:22 +00:00
parent c79ee932a3
commit ea887c7019
3 changed files with 154 additions and 100 deletions
+19
View File
@@ -39,6 +39,25 @@ class TestSectionBlockUpdates(unittest.TestCase):
self.assertEqual(packet.id, 0x56)
self.assertEqual(packet.changes, [(-173, 70, -311, bed_id)])
def test_unload_chunk_prunes_index_and_block_entities_safely(self):
bed_id = next(iter(blocks.BED_IDS))
inside = (1, 64, 1)
outside = (17, 64, 1)
world = WorldState()
world.chunks[(0, 0)] = ChunkColumn(0, 0, [], world.min_section)
world.index[bed_id] = {inside, outside}
world.block_entities = {
inside: {'type': 1, 'data': {}},
outside: {'type': 1, 'data': {}},
}
snapshot = world.indexed_positions({bed_id})
world.unload_chunk(0, 0)
self.assertEqual(set(snapshot), {inside, outside})
self.assertEqual(world.index[bed_id], {outside})
self.assertEqual(set(world.block_entities), {outside})
def test_section_update_replaces_old_block_and_index_entry(self):
section_x, section_y, section_z = -11, 4, -20
x, y, z = -173, 70, -311