Display when the bot is loading chunks

This commit is contained in:
2021-02-23 21:37:14 +00:00
parent cf8677ee65
commit 1d8d473e26
2 changed files with 12 additions and 5 deletions

14
bot.py
View File

@@ -55,10 +55,18 @@ def tick(global_state):
target = None
# make sure current chunks are loaded for physics
if not g.chunks.check_loaded(p, 9):
if not g.chunks.check_loaded(p, 288):
if not g.chunks.loading:
print('Loading chunks', end='', flush=True)
g.chunks.loading = True
packet = serverbound.play.PositionAndLookPacket(x=p.x, feet_y=p.y, z=p.z, pitch=0, yaw=0, on_ground=True)
g.connection.write_packet(packet, force=True)
return
else:
if g.chunks.loading:
print()
print('Chunks loaded.')
g.chunks.loading = False
g.chunks.unload_chunks(p)
@@ -246,10 +254,6 @@ def bot(global_state):
time.sleep(utils.TICK)
print('Player loaded.')
while not g.chunks.check_loaded(g.pos, 288):
time.sleep(utils.TICK)
print('Chunks loaded.')
init(g)
g.game.close_window()
print('Initialized.')