Reset the bot on death
This commit is contained in:
parent
433e35e79b
commit
221d497204
|
@ -377,8 +377,8 @@ class Game:
|
||||||
self.g.name = packet.Username
|
self.g.name = packet.Username
|
||||||
|
|
||||||
def handle_join_game(self, packet):
|
def handle_join_game(self, packet):
|
||||||
|
print('Received join game packet')
|
||||||
print('Connected.')
|
print('Connected.')
|
||||||
print(packet)
|
|
||||||
self.g.info = packet
|
self.g.info = packet
|
||||||
self.g.eid = packet.entity_id
|
self.g.eid = packet.entity_id
|
||||||
self.g.dimension = packet.world_name.replace('minecraft:', '')
|
self.g.dimension = packet.world_name.replace('minecraft:', '')
|
||||||
|
@ -947,8 +947,8 @@ class Game:
|
||||||
elif g.window:
|
elif g.window:
|
||||||
g.window.contents[packet.slot] = packet.slot_data
|
g.window.contents[packet.slot] = packet.slot_data
|
||||||
|
|
||||||
if packet.window_id >= 0 and not packet.slot_data.present:
|
if g.item_lock and packet.window_id >= 0 and not packet.slot_data.present:
|
||||||
print('unlocking item lock')
|
print('Unlocking item lock')
|
||||||
g.item_lock = False
|
g.item_lock = False
|
||||||
|
|
||||||
def break_block(self, location):
|
def break_block(self, location):
|
||||||
|
@ -1301,6 +1301,12 @@ class Game:
|
||||||
self.g.health = packet.health
|
self.g.health = packet.health
|
||||||
self.g.food = packet.food
|
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):
|
def use_item(self, hand):
|
||||||
packet = serverbound.play.UseItemPacket()
|
packet = serverbound.play.UseItemPacket()
|
||||||
packet.hand = hand
|
packet.hand = hand
|
||||||
|
|
Loading…
Reference in New Issue
Block a user