refactor: convert redundant new TypeName() to target-typed new()

Replace explicit constructor calls with target-typed new() expressions
where the type is already specified on the left side of the assignment.
This is a C# 9+ feature that reduces redundancy.

Files changed:
- Container.cs: field assignments in constructors
- EntityPalette18/112/113.cs: static field initializers
- ChatParser.cs: StringBuilder local variable
- Movement.cs: field assignments in constructor
- PacketPalette18.cs: field initializers
- EnchantmentMapping.cs: field reassignments

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-03-24 00:37:35 +00:00
parent 2ae31e269f
commit 446c6e7739
8 changed files with 23 additions and 23 deletions

View file

@ -4,7 +4,7 @@ namespace MinecraftClient.Protocol.Handlers.PacketPalettes
{
public class PacketPalette18 : PacketTypePalette
{
private Dictionary<int, PacketTypesIn> typeIn = new Dictionary<int, PacketTypesIn>()
private Dictionary<int, PacketTypesIn> typeIn = new()
{
{ 0x00, PacketTypesIn.KeepAlive },
{ 0x01, PacketTypesIn.JoinGame },
@ -80,7 +80,7 @@ namespace MinecraftClient.Protocol.Handlers.PacketPalettes
{ 0x49, PacketTypesIn.UpdateEntityNBT }
};
private Dictionary<int, PacketTypesOut> typeOut = new Dictionary<int, PacketTypesOut>()
private Dictionary<int, PacketTypesOut> typeOut = new()
{
{ 0x00, PacketTypesOut.TeleportConfirm },
{ 0x01, PacketTypesOut.Unknown },

View file

@ -511,7 +511,7 @@ namespace MinecraftClient.Protocol.Message
string message = string.Empty;
string colorCode = string.Empty;
StringBuilder extraBuilder = new StringBuilder();
StringBuilder extraBuilder = new();
foreach (var kvp in nbt)
{
string key = kvp.Key;