Calculate the correct block breaking time

This commit is contained in:
2020-09-16 00:49:15 -06:00
parent 179359d0ee
commit 13770fab24
3 changed files with 62 additions and 22 deletions

12
bot.py
View File

@@ -33,7 +33,6 @@ importlib.reload(utils)
import path
importlib.reload(path)
TICK = 0.05
last_tick = time.time()
PITCH_ANGLE_DIR = LVector3f(x=0, y=1, z=0)
@@ -87,8 +86,8 @@ def tick(global_state):
l.path.pop(0)
if l.y_v or l.y_a:
p.y += l.y_v * TICK
l.y_v += l.y_a * TICK
p.y += l.y_v * utils.TICK
l.y_v += l.y_a * utils.TICK
block_below = g.chunks.get_block_at(floor(p.x), ceil(p.y-1), floor(p.z))
in_air = block_below in blocks.NON_SOLID_IDS
@@ -151,6 +150,7 @@ def init(global_state):
l.pitch = 0
l.breaking = None
l.break_time = 0
#l.jobstate = JobStates(connection, player_info)
#l.jobstate.run()
@@ -184,12 +184,12 @@ def bot(global_state):
try:
while not g.pos:
time.sleep(TICK)
time.sleep(utils.TICK)
print('Player loaded.')
x, y, z = utils.pint(g.pos)
while (floor(x/16), floor(y/16), floor(z/16)) not in g.chunks.chunks:
time.sleep(TICK)
time.sleep(utils.TICK)
print('Chunks loaded.')
init(g)
@@ -198,7 +198,7 @@ def bot(global_state):
tick(g)
global last_tick
sleep_time = TICK + last_tick - time.time()
sleep_time = utils.TICK + last_tick - time.time()
if sleep_time < 0: sleep_time = 0
time.sleep(sleep_time)
last_tick = time.time()