From ce9613c00ce0b28a86d02603d0ba627e347ce32f Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Sat, 24 Apr 2021 23:37:11 +0000 Subject: [PATCH] Index blocks on change --- mosfet/protocol/managers.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mosfet/protocol/managers.py b/mosfet/protocol/managers.py index 1a26130..4ab9c0b 100644 --- a/mosfet/protocol/managers.py +++ b/mosfet/protocol/managers.py @@ -7,6 +7,7 @@ from minecraft.networking.packets import clientbound, serverbound from mosfet.protocol import packets from mosfet import utils +from mosfet.info import blocks class DataManager: def __init__(self, directory): @@ -42,7 +43,7 @@ class ChunksManager: def __init__(self, data_manager): self.data = data_manager self.chunks = {} - self.biomes = {} + #self.biomes = {} self.index = {} self.loading = False @@ -74,7 +75,7 @@ class ChunksManager: coords = (dx + l%16, dy + l//256, dz + l%256//16) self.index[item_id].append(coords) - self.biomes[(chunk_packet.x, None, chunk_packet.z)] = chunk_packet.biomes # FIXME + #self.biomes[(chunk_packet.x, None, chunk_packet.z)] = chunk_packet.biomes # FIXME if self.loading: print('.', end='', flush=True) @@ -116,6 +117,11 @@ class ChunksManager: if not c: return None c.set_block_at(x%16, y%16, z%16, block) + if block in blocks.INDEXED_IDS: + if block not in self.index: + self.index[block] = [] + self.index[block].append((x, y, z)) + def check_loaded(self, position, steps=1): x, y, z = utils.pint(position) player_chunk = (x//16, 1, z//16)