Cache items into trapped chests

This commit is contained in:
2020-12-01 00:48:02 +00:00
parent efcefc8192
commit eabb0a04d1
5 changed files with 93 additions and 16 deletions
+23 -2
View File
@@ -47,6 +47,25 @@ class MCWorld:
if self.block_at(*check) in block_ids:
yield check
def find_blocks_indexed(self, center, block_ids, distance=0):
print('finding', block_ids)
index = []
for bid in block_ids:
index.extend(self.g.chunks.index.get(bid, []))
print('index', index)
result = []
for block in index:
if self.block_at(*block) not in block_ids:
continue
if distance and utils.phyp(center, block) > distance:
continue
result.append(block)
result.sort(key=lambda x: utils.phyp(center, x))
return result
def find_blocks(self, center, distance, block_ids, limit=0):
# search in a spiral from center to all blocks with ID
result = []
@@ -477,8 +496,10 @@ class Game:
packet.location = self.g.breaking
packet.face = 1
self.g.connection.write_packet(packet)
self.g.chunks.set_block_at(*self.g.breaking, 0)
self.g.breaking = None
#self.g.chunks.set_block_at(*self.g.breaking, 0)
if self.g.chunks.get_block_at(*self.g.breaking) == 0:
self.g.breaking = None
def handle_break_animation(self, packet):
print(packet)