From 650398255b57d45992d1a80d0a5ded2ba7f367b6 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Sun, 25 Apr 2021 00:59:43 +0000 Subject: [PATCH] Detect being forced to wake up --- mosfet/bot.py | 2 +- mosfet/jobs/sleep_with_bed.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mosfet/bot.py b/mosfet/bot.py index f45155a..cc079e7 100644 --- a/mosfet/bot.py +++ b/mosfet/bot.py @@ -206,8 +206,8 @@ def tick(global_state): 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) - g.game.tick() g.job.tick() + g.game.tick() # order important for correction_count def init(global_state): diff --git a/mosfet/jobs/sleep_with_bed.py b/mosfet/jobs/sleep_with_bed.py index fa3a093..9b2ebbe 100644 --- a/mosfet/jobs/sleep_with_bed.py +++ b/mosfet/jobs/sleep_with_bed.py @@ -164,13 +164,16 @@ class SleepWithBedStates: def sleep_bed(self): w = self.g.world p = utils.pint(self.g.pos) - threats = w.find_threats(p, 10) + if threats: print('Waking up due to threats:') print(threats) self.g.game.leave_bed() self.state = self.cleanup + elif self.g.correction_count: + print('Forcefully woke up') + self.state = self.collect_bed elif self.g.time < 100: print('Woke up time') self.state = self.break_bed