Consolidate bot runtime on Minecraft 26.3
This commit is contained in:
@@ -3,6 +3,7 @@ import json
|
||||
import threading
|
||||
import time
|
||||
import traceback
|
||||
import sys
|
||||
|
||||
import logging
|
||||
log = logging.getLogger('werkzeug')
|
||||
@@ -64,13 +65,22 @@ def root():
|
||||
def main():
|
||||
"""Connect with offline/AuthMe and enable only the migrated 26.3 features.
|
||||
|
||||
Current gameplay support is read-only world/entity/inventory state plus
|
||||
path following; inventory actions, block interactions, and legacy job
|
||||
packet handlers remain disabled until migrated.
|
||||
Current gameplay support includes path following and a crop-only harvest /
|
||||
replant job. General inventory actions, other block interactions, and
|
||||
legacy jobs remain disabled until migrated.
|
||||
"""
|
||||
reload_timeout = time.time()
|
||||
reload_requested = False
|
||||
|
||||
def reload_modules():
|
||||
manager_module = sys.modules.get('mosfet.protocol.managers')
|
||||
if manager_module is not None:
|
||||
importlib.reload(manager_module)
|
||||
bot_module = sys.modules.get('mosfet.bot')
|
||||
if bot_module is not None:
|
||||
importlib.reload(bot_module)
|
||||
importlib.reload(connect)
|
||||
|
||||
def reload_bot(event):
|
||||
nonlocal reload_timeout, reload_requested
|
||||
if time.time() - reload_timeout > 2.0:
|
||||
@@ -94,7 +104,7 @@ def main():
|
||||
if not reload_requested:
|
||||
break
|
||||
reload_requested = False
|
||||
importlib.reload(connect)
|
||||
reload_modules()
|
||||
except KeyboardInterrupt:
|
||||
break
|
||||
except BaseException:
|
||||
@@ -104,7 +114,7 @@ def main():
|
||||
while g.running:
|
||||
time.sleep(1)
|
||||
reload_requested = False
|
||||
importlib.reload(connect)
|
||||
reload_modules()
|
||||
finally:
|
||||
g.running = False
|
||||
observer.stop()
|
||||
|
||||
Reference in New Issue
Block a user