ClientCommandRunner

Runs a command AS THE PLAYER, for the run_command tool's target=client — i.e. exactly what typing it into the chat box does.

It calls the SAME vanilla method the chat screen uses — ClientPacketListener#sendCommand on MC >=1.19, else LocalPlayer#chat("/"+cmd) on <=1.18.2 (the 1.19 secure-chat rework split the send path; see org.js.lolifamily.minecraftmcp.compat.ClientCommandCompat) — so every loader's client-command interception fires automatically: Fabric mixes into that method, NeoForge/Forge consult ClientCommandHandler on that path. A client-only mod command (Baritone, clientcommands, ...) is caught and run locally; anything else goes to the connected server, executed with THIS PLAYER's permission.

Feedback is captured by the ChatComponent mixins at the public chat entries (best-effort — see those classes). This class opens a ChatCapture window for CAPTURE_WINDOW_MS around the send: unrelated chat during the window mixes in, and a reply slower than the window is missed. What lands in the window is filtered by ChatTrust unless allowUntrusted.

Loaded on the client only — by its tick heartbeat and by the client path — so it never touches client classes on a dedicated server.

Constructors

Link copied to clipboard
private constructor()

Companion properties

Link copied to clipboard
private val CAPTURE_WINDOW_MS: Long = 500
How long the chat-capture window stays open after the send goes out, collecting feedback.
Link copied to clipboard
private val NOTE: String = "[mcp]"
Prefix on every line THIS class inserts, so a reader (the LLM) can tell our notes from real captured game output, which is never prefixed.
Link copied to clipboard
private val PENDING: Queue<Runnable>
Sends waiting for the next client tick; only drain runs them.

Companion functions

Link copied to clipboard
open fun drain()
Run the sends queued since the last client tick.
Link copied to clipboard
open fun run(command: String, allowUntrusted: Boolean): String
Send command as the player and collect chat-window feedback for CAPTURE_WINDOW_MS.
Link copied to clipboard
private open fun split(command: String): List<String>
One command per line (like .