Reimplement !drain command
This commit is contained in:
+19
-2
@@ -116,7 +116,8 @@ def tick(global_state):
|
||||
print('Chunks loaded in', round(time.time() - g.chunks.loading, 2), 's')
|
||||
g.chunks.loading = False
|
||||
g.chunk_wait_report_at = 0
|
||||
status = 'following_path' if g.path else 'running_job'
|
||||
status = ('draining_inventory' if g.get('draining') else
|
||||
'following_path' if g.path else 'running_job')
|
||||
if g.get('movement_status') != status:
|
||||
print('[movement] status={}'.format(status), flush=True)
|
||||
g.movement_status = status
|
||||
@@ -394,6 +395,12 @@ def start_automation(global_state, initialize=True):
|
||||
g.players = g.get('players') or {}
|
||||
g.breaking = None
|
||||
g.break_time = 0.0
|
||||
g.draining = False
|
||||
g.drain_slots = []
|
||||
g.drain_waiting = None
|
||||
g.drain_dropped = 0
|
||||
g.drain_total = 0
|
||||
g.drain_error = None
|
||||
g.correction_count = g.get('correction_count', 0)
|
||||
g.yaw = float(g.get('yaw', 0.0) or 0.0)
|
||||
g.pitch = float(g.get('pitch', 0.0) or 0.0)
|
||||
@@ -408,6 +415,15 @@ def start_automation(global_state, initialize=True):
|
||||
g.game = Game(g)
|
||||
g.job = JobStates(g)
|
||||
|
||||
# Preserve active work during hot reloads, but give the worker all fields
|
||||
# introduced by the currently migrated inventory controls.
|
||||
g.setdefault('draining', False)
|
||||
g.setdefault('drain_slots', [])
|
||||
g.setdefault('drain_waiting', None)
|
||||
g.setdefault('drain_dropped', 0)
|
||||
g.setdefault('drain_total', 0)
|
||||
g.setdefault('drain_error', None)
|
||||
|
||||
old_stop = g.get('movement_stop_event')
|
||||
old_worker = g.get('movement_thread')
|
||||
if old_stop is not None:
|
||||
@@ -444,7 +460,8 @@ def start_automation(global_state, initialize=True):
|
||||
# of gating itself forever on a momentary missing column.
|
||||
movement_ready = initial_world_ready
|
||||
job_active = (g.job is not None and g.job.state != g.job.idle)
|
||||
has_work = bool(g.path) or job_active or bool(g.breaking)
|
||||
has_work = (bool(g.path) or job_active or bool(g.breaking) or
|
||||
bool(g.draining))
|
||||
if g.get('movement_paused'):
|
||||
set_status('paused')
|
||||
elif has_work and not movement_ready:
|
||||
|
||||
Reference in New Issue
Block a user