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)
|
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))
|
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.game.tick()
|
||||||
g.job.tick()
|
g.job.tick()
|
||||||
|
|
8
game.py
8
game.py
|
@ -150,7 +150,7 @@ class MCWorld:
|
||||||
bed_clearance = 25 # 5x5 area
|
bed_clearance = 25 # 5x5 area
|
||||||
clear_distance = 3
|
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
|
# check for air around the area
|
||||||
if len(self.find_blocks(a, clear_distance, [0], bed_clearance)) < bed_clearance:
|
if len(self.find_blocks(a, clear_distance, [0], bed_clearance)) < bed_clearance:
|
||||||
continue
|
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:
|
if len(self.find_blocks(utils.padd(a, path.BLOCK_ABOVE), clear_distance, [0], bed_clearance)) < bed_clearance:
|
||||||
continue
|
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
|
yield a
|
||||||
|
|
||||||
def find_cache_areas(self, center, distance):
|
def find_cache_areas(self, center, distance):
|
||||||
|
@ -343,6 +348,7 @@ class Game:
|
||||||
if solution:
|
if solution:
|
||||||
solution = list(solution)
|
solution = list(solution)
|
||||||
self.g.path = solution
|
self.g.path = solution
|
||||||
|
if self.g.job:
|
||||||
self.g.job.stop()
|
self.g.job.stop()
|
||||||
print(len(solution))
|
print(len(solution))
|
||||||
print(solution)
|
print(solution)
|
||||||
|
|
3
jobs.py
3
jobs.py
|
@ -906,8 +906,9 @@ class ClearLeavesStates:
|
||||||
def find_leaves(self):
|
def find_leaves(self):
|
||||||
w = self.g.world
|
w = self.g.world
|
||||||
p = utils.pint(self.g.pos)
|
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.leaves.append(l)
|
||||||
|
|
||||||
self.state = self.break_leaves
|
self.state = self.break_leaves
|
||||||
|
|
Loading…
Reference in New Issue
Block a user