Don't sleep near monsters
This commit is contained in:
parent
86846a5c02
commit
af88f68e66
2
bot.py
2
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()
|
||||
|
|
8
game.py
8
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,6 +348,7 @@ class Game:
|
|||
if solution:
|
||||
solution = list(solution)
|
||||
self.g.path = solution
|
||||
if self.g.job:
|
||||
self.g.job.stop()
|
||||
print(len(solution))
|
||||
print(solution)
|
||||
|
|
3
jobs.py
3
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user