Convert switch statements to expressions and adopt collection expressions

- DirectionExtensions.cs: Convert GetOpposite() to switch expression,
  use file-scoped namespace, use collection expression for HORIZONTAL
- McClient.cs: Convert InteractType switch to expression, use collection
  expressions for array literals
- Protocol18.cs: Replace Array.Empty<byte>() with [], use collection
  expressions for byte/int array literals
- DataTypes.cs: Use collection expression for TAG_End byte array
- ChatBot.cs: Use collection expressions for string/char arrays
- Location.cs: Use collection expressions and modernize null check

Co-authored-by: milutinke <441903+milutinke@users.noreply.github.com>
Agent-Logs-Url: https://github.com/milutinke/Minecraft-Console-Client/sessions/4e9bd25b-22c5-47c2-98f9-6025d927b1d6
This commit is contained in:
copilot-swe-agent[bot] 2026-03-24 00:34:00 +00:00
parent c5df6a49c6
commit 2ae31e269f
6 changed files with 66 additions and 92 deletions

View file

@ -116,7 +116,7 @@ namespace MinecraftClient.Mapping
public static bool TryParse(string x, string y, string z, out Location? location)
{
string[] coord_str = new string[] { x.Trim(), y.Trim(), z.Trim() };
string[] coord_str = [x.Trim(), y.Trim(), z.Trim()];
double[] coord_res = new double[3];
for (int i = 0; i < 3; ++i)
@ -144,7 +144,7 @@ namespace MinecraftClient.Mapping
public static Location Parse(Location current, string x, string y, string z)
{
Location.TryParse(current, x, y, z, out Location? res);
if (res == null)
if (res is null)
throw new FormatException();
else
return (Location)res;
@ -152,9 +152,9 @@ namespace MinecraftClient.Mapping
public static bool TryParse(Location current, string x, string y, string z, out Location? location)
{
string[] coord_str = new string[] { x.Trim(), y.Trim(), z.Trim() };
string[] coord_str = [x.Trim(), y.Trim(), z.Trim()];
double[] coord_res = new double[3];
double[] coord_cur = new double[] { current.X, current.Y, current.Z };
double[] coord_cur = [current.X, current.Y, current.Z];
for (int i = 0; i < 3; ++i)
{