Don't sleep near monsters

This commit is contained in:
2020-12-12 21:11:00 +00:00
parent 86846a5c02
commit af88f68e66
3 changed files with 11 additions and 4 deletions
+8 -2
View File
@@ -150,7 +150,7 @@ class MCWorld:
bed_clearance = 25 # 5x5 area
clear_distance = 3
for a in self.find_blocks_3d(center, [0], distance, 10):
for a in self.find_blocks_3d(center, [0], distance, 50):
# check for air around the area
if len(self.find_blocks(a, clear_distance, [0], bed_clearance)) < bed_clearance:
continue
@@ -163,6 +163,11 @@ class MCWorld:
if len(self.find_blocks(utils.padd(a, path.BLOCK_ABOVE), clear_distance, [0], bed_clearance)) < bed_clearance:
continue
# ensure there's no monsters within 20 blocks
# can't sleep if they are within 10, good to have a buffer
if self.find_monsters(a, 20):
continue
yield a
def find_cache_areas(self, center, distance):
@@ -343,7 +348,8 @@ class Game:
if solution:
solution = list(solution)
self.g.path = solution
self.g.job.stop()
if self.g.job:
self.g.job.stop()
print(len(solution))
print(solution)
print(round(time.time() - start, 3), 'seconds')