From 221d4972045d7998f1f4c6af2bd53fde391d0652 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Fri, 23 Apr 2021 00:05:56 +0000 Subject: [PATCH] Reset the bot on death --- mosfet/game.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mosfet/game.py b/mosfet/game.py index ceaff85..5ae33f0 100644 --- a/mosfet/game.py +++ b/mosfet/game.py @@ -377,8 +377,8 @@ class Game: self.g.name = packet.Username def handle_join_game(self, packet): + print('Received join game packet') print('Connected.') - print(packet) self.g.info = packet self.g.eid = packet.entity_id self.g.dimension = packet.world_name.replace('minecraft:', '') @@ -947,8 +947,8 @@ class Game: elif g.window: g.window.contents[packet.slot] = packet.slot_data - if packet.window_id >= 0 and not packet.slot_data.present: - print('unlocking item lock') + if g.item_lock and packet.window_id >= 0 and not packet.slot_data.present: + print('Unlocking item lock') g.item_lock = False def break_block(self, location): @@ -1301,6 +1301,12 @@ class Game: self.g.health = packet.health self.g.food = packet.food + if packet.health == 0: + print('Died, stopping') + print('Use 1respawn to respawn the bot') + self.close_window() + bot.init(self.g) + def use_item(self, hand): packet = serverbound.play.UseItemPacket() packet.hand = hand