CommandRunner
Runs a Minecraft command on the server thread and captures its chat feedback, for the run_command MCP tool. Vanilla mechanism throughout: a custom CommandSource collects the feedback the command would normally print, attached to a server-level (OP) CommandSourceStack, executed via Commands#performPrefixedCommand.
CommandSource.acceptsSuccess and acceptsFailure must both return true: sendSuccess/sendFailure check them first and silently drop the message otherwise, so feedback would never reach the sink method (sendSystemMessage, or sendMessage on 1.18.2). Returning true also bypasses the sendCommandFeedback gamerule (our source decides, not the world).
Properties
Functions
Runs ON the server thread. command may be multiple lines — executed in order like a .mcfunction: blank lines and # comments are skipped, a failing line does NOT stop the rest. All lines run in this single server-thread task, so they share one tick snapshot. Single line -> just its feedback; multiple -> each line echoed as > cmd above its output.
A CommandSource proxy that appends every feedback Component to sink; the three name sets decide which reflected method is which on this runtime.
The neutral return value for t. An InvocationHandler returning null for a PRIMITIVE return type throws NPE (its own javadoc says so), so this has to be TOTAL over every type the interface can declare — not a ladder that grows a case per MC release. A primitive's neutral value is exactly the JVM's default for a field of that type, read off a fresh one-element array, so there is no table that can go stale (boolean -> false falls out of it, which is why it is no longer written down). void reports isPrimitive == true but has no array type, and a null return for it is ignored by the proxy.