diff --git a/bot.py b/bot.py index 9a8d4c3..f85c2be 100644 --- a/bot.py +++ b/bot.py @@ -173,7 +173,7 @@ def tick(global_state): g.pitch += utils.cap(target_pitch_d, 10) packet = serverbound.play.PositionAndLookPacket(x=p.x, feet_y=p.y, z=p.z, pitch=g.pitch, yaw=g.yaw, on_ground=(not in_air)) - g.connection.write_packet(packet, force=True) + g.connection.write_packet(packet) g.game.tick() g.job.tick() diff --git a/game.py b/game.py index fdb7f1e..8f01ee9 100644 --- a/game.py +++ b/game.py @@ -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') diff --git a/jobs.py b/jobs.py index f091529..91c7439 100644 --- a/jobs.py +++ b/jobs.py @@ -906,8 +906,9 @@ class ClearLeavesStates: def find_leaves(self): w = self.g.world p = utils.pint(self.g.pos) + pos = utils.padd(p, path.BLOCK_ABOVE) - for l in w.find_leaves(p, blocks.BREAK_DISTANCE): + for l in w.find_leaves(pos, blocks.BREAK_DISTANCE): self.leaves.append(l) self.state = self.break_leaves