Use a set for the block index to limit size

This commit is contained in:
Tanner Collin 2021-05-07 00:29:41 +00:00
parent e5fd062a4a
commit 343268af24

View File

@ -69,10 +69,10 @@ class ChunksManager:
for item_id, locations in chunk.sub_index.items(): for item_id, locations in chunk.sub_index.items():
if item_id not in self.index: if item_id not in self.index:
self.index[item_id] = [] self.index[item_id] = set()
for l in locations: for l in locations:
coords = (dx + l%16, dy + l//256, dz + l%256//16) coords = (dx + l%16, dy + l//256, dz + l%256//16)
self.index[item_id].append(coords) self.index[item_id].add(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: if self.loading:
@ -118,8 +118,8 @@ class ChunksManager:
if block in blocks.INDEXED_IDS: if block in blocks.INDEXED_IDS:
if block not in self.index: if block not in self.index:
self.index[block] = [] self.index[block] = set()
self.index[block].append((x, y, z)) self.index[block].add((x, y, z))
def check_loaded(self, chunk_distance): def check_loaded(self, chunk_distance):
num = (chunk_distance * 2 + 1) ** 2 num = (chunk_distance * 2 + 1) ** 2