mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
Handle non-interactive terminal environments gracefully
When MCC runs in non-interactive terminals (e.g. CI runners, IDE embedded shells, piped input), several Console APIs throw exceptions because there is no real console attached. Changes: - Program.cs: Wrap Console.KeyAvailable / Console.ReadKey in HandleFailure() with try-catch so MCC does not crash on startup failure in headless environments. - Chunk.cs: Wrap Console.BufferWidth / BufferHeight in try-catch with fallback values (120x50) to prevent exceptions when rendering chunk maps without a console buffer. - Map.cs: Same treatment for the map rendering path - use safe fallback values when Console.BufferWidth/Height are unavailable. - ReplayHandler.cs: Replace Array.Reverse() (returns void in newer .NET) with .AsEnumerable().Reverse() to fix compilation with .NET 10 SDK where the void return breaks the fluent chain. Made-with: Cursor
This commit is contained in:
parent
494be0930b
commit
ff1c570a78
4 changed files with 21 additions and 12 deletions
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
|
@ -239,8 +239,8 @@ namespace MinecraftClient.Protocol
|
|||
// format: timestamp + packetLength + RawPacket
|
||||
List<byte> line = new();
|
||||
int nowTime = Convert.ToInt32((lastPacketTime - recordStartTime).TotalMilliseconds);
|
||||
line.AddRange(BitConverter.GetBytes((Int32)nowTime).Reverse().ToArray());
|
||||
line.AddRange(BitConverter.GetBytes((Int32)rawPacket.Count).Reverse().ToArray());
|
||||
line.AddRange(BitConverter.GetBytes((Int32)nowTime).AsEnumerable().Reverse().ToArray());
|
||||
line.AddRange(BitConverter.GetBytes((Int32)rawPacket.Count).AsEnumerable().Reverse().ToArray());
|
||||
line.AddRange(rawPacket.ToArray());
|
||||
// Write out to the file
|
||||
recordStream!.Write(line.ToArray());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue