Index blocks on change
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user