Consolidate bot runtime on Minecraft 26.3

This commit is contained in:
Tanner
2026-11-04 03:05:23 +00:00
parent b6f7ce9948
commit f7f58f5d07
15 changed files with 706 additions and 537 deletions
+13 -8
View File
@@ -6,10 +6,10 @@ import os
import threading
from minecraft.networking.connection import Connection
from minecraft.networking.modern import (
CancelPostjoinDialog, ChatCommand, PlayShowDialog,
CancelPostjoinDialog, ChatCommand, PlayGameEventPacket, PlayShowDialog,
PlayLogin, SubmitPostjoinLoginDialog, SystemChat, TeleportPosition,
)
from mosfet.world_26_3 import WorldState
from mosfet.protocol.managers import WorldState
from mosfet.vector import Point3D
@@ -71,6 +71,7 @@ def main(global_state=None):
global_state.connected = True
global_state.connection_status = 'in_game'
global_state.player_id = packet.player_id
global_state.game_mode = packet.game_mode
global_state.dimension = packet.dimension.removeprefix('minecraft:')
packet.render_distance = packet.chunk_radius
global_state.info = packet
@@ -79,15 +80,14 @@ def main(global_state=None):
from mosfet.world import World
from mosfet.commands import Commands
from mosfet.protocol.modern import ModernChatManager
from mosfet.protocol.entities_26_3 import ModernEntityManager
from mosfet.protocol.inventory_26_3 import ModernInventoryManager
from mosfet.automation_26_3 import start as start_modern_movement
from mosfet.protocol.managers import EntityManager, InventoryManager
from mosfet.bot import start_automation
global_state.world = World(global_state)
global_state.chat = ModernChatManager(global_state)
global_state.entities = ModernEntityManager(global_state)
global_state.inventory = ModernInventoryManager(global_state)
global_state.entities = EntityManager(global_state)
global_state.inventory = InventoryManager(global_state)
global_state.commands = Commands(global_state)
start_modern_movement(global_state)
start_automation(global_state)
def send_auth_command(action):
@@ -100,6 +100,11 @@ def main(global_state=None):
connection.write_packet(ChatCommand(command=command.lstrip('/')),
force=True)
@connection.listener(PlayGameEventPacket)
def on_game_event(packet):
if global_state is not None and packet.event == 3:
global_state.game_mode = int(packet.value)
@connection.listener(TeleportPosition)
def on_spawn(packet):
if global_state is not None: