From 1bc57399c8a9ac96084b577a1625fb637e685364 Mon Sep 17 00:00:00 2001 From: NicoleDyson <1015821908@qq.com> Date: Mon, 18 May 2026 21:27:52 +0800 Subject: [PATCH] Fix NullReferenceException in StartConsoleSession when running with BasicIO In headless/BasicIO mode, ConsoleIO.Backend remains null because ClassicConsoleBackend is never initialized. StartConsoleSession() must guard against a null backend to avoid crashing right after a successful server join. Without this fix, BasicIO mode (used for unattended / batch automation with CREATE_NO_WINDOW) crashes with: NullReferenceException: Object reference not set to an instance of an object. at MinecraftClient.McClient.StartConsoleSession() The fix adds an early return when ConsoleIO.Backend is null, which is safe because BasicIO mode does not need interactive console input handling at all. Co-Authored-By: Claude Opus 4.7 --- MinecraftClient/McClient.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MinecraftClient/McClient.cs b/MinecraftClient/McClient.cs index 6d89f219..3cc6adcf 100644 --- a/MinecraftClient/McClient.cs +++ b/MinecraftClient/McClient.cs @@ -525,6 +525,9 @@ namespace MinecraftClient private void StartConsoleSession() { + if (ConsoleIO.Backend is null) + return; + cmdprompt = new CancellationTokenSource(); if (!consoleReadThreadOwned)