mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
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:
parent
2ae31e269f
commit
446c6e7739
8 changed files with 23 additions and 23 deletions
|
|
@ -50,8 +50,8 @@ namespace MinecraftClient.Inventory
|
|||
ID = id;
|
||||
Type = type;
|
||||
Title = title;
|
||||
Items = new Dictionary<int, Item>();
|
||||
Properties = new Dictionary<int, short>();
|
||||
Items = new();
|
||||
Properties = new();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -67,7 +67,7 @@ namespace MinecraftClient.Inventory
|
|||
Type = type;
|
||||
Title = title;
|
||||
Items = items;
|
||||
Properties = new Dictionary<int, short>();
|
||||
Properties = new();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -81,8 +81,8 @@ namespace MinecraftClient.Inventory
|
|||
ID = id;
|
||||
Title = title;
|
||||
Type = ConvertType.ToNew(type);
|
||||
Items = new Dictionary<int, Item>();
|
||||
Properties = new Dictionary<int, short>();
|
||||
Items = new();
|
||||
Properties = new();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -96,8 +96,8 @@ namespace MinecraftClient.Inventory
|
|||
ID = id;
|
||||
Type = GetContainerType(typeID);
|
||||
Title = title;
|
||||
Items = new Dictionary<int, Item>();
|
||||
Properties = new Dictionary<int, short>();
|
||||
Items = new();
|
||||
Properties = new();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -109,8 +109,8 @@ namespace MinecraftClient.Inventory
|
|||
ID = -1;
|
||||
Type = type;
|
||||
Title = null;
|
||||
Items = new Dictionary<int, Item>();
|
||||
Properties = new Dictionary<int, short>();
|
||||
Items = new();
|
||||
Properties = new();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -124,7 +124,7 @@ namespace MinecraftClient.Inventory
|
|||
Type = type;
|
||||
Title = null;
|
||||
Items = items;
|
||||
Properties = new Dictionary<int, short>();
|
||||
Properties = new();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ namespace MinecraftClient.Inventory
|
|||
/// </summary>
|
||||
public static void SetDynamicEnchantmentIdMap(Dictionary<int, string> idMap)
|
||||
{
|
||||
dynamicEnchantmentIdMap = new Dictionary<int, Enchantments>();
|
||||
dynamicEnchantmentIdMap = new();
|
||||
foreach (var kvp in idMap)
|
||||
{
|
||||
var name = kvp.Value.StartsWith("minecraft:") ? kvp.Value.Substring("minecraft:".Length) : kvp.Value;
|
||||
|
|
@ -284,7 +284,7 @@ namespace MinecraftClient.Inventory
|
|||
{
|
||||
if (reverseEnchantmentMappings == null)
|
||||
{
|
||||
reverseEnchantmentMappings = new Dictionary<Enchantments, short>();
|
||||
reverseEnchantmentMappings = new();
|
||||
if (dynamicEnchantmentIdMap != null)
|
||||
{
|
||||
foreach (var kvp in dynamicEnchantmentIdMap)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace MinecraftClient.Mapping.EntityPalettes
|
|||
/// </summary>
|
||||
public class EntityPalette112 : EntityPalette
|
||||
{
|
||||
private static Dictionary<int, EntityType> mappingsObjects = new Dictionary<int, EntityType>()
|
||||
private static Dictionary<int, EntityType> mappingsObjects = new()
|
||||
{
|
||||
// https://wiki.vg/Entity_metadata#Objects
|
||||
{ 1, EntityType.Boat },
|
||||
|
|
@ -41,7 +41,7 @@ namespace MinecraftClient.Mapping.EntityPalettes
|
|||
{ 93, EntityType.DragonFireball },
|
||||
};
|
||||
|
||||
private static Dictionary<int, EntityType> mappingsMobs = new Dictionary<int, EntityType>()
|
||||
private static Dictionary<int, EntityType> mappingsMobs = new()
|
||||
{
|
||||
{ 1, EntityType.Item },
|
||||
{ 2, EntityType.ExperienceOrb },
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace MinecraftClient.Mapping.EntityPalettes
|
|||
/// </summary>
|
||||
public class EntityPalette113 : EntityPalette
|
||||
{
|
||||
private static Dictionary<int, EntityType> mappingsObjects = new Dictionary<int, EntityType>()
|
||||
private static Dictionary<int, EntityType> mappingsObjects = new()
|
||||
{
|
||||
// https://wiki.vg/Entity_metadata#Objects
|
||||
{ 1, EntityType.Boat },
|
||||
|
|
@ -42,7 +42,7 @@ namespace MinecraftClient.Mapping.EntityPalettes
|
|||
{ 94, EntityType.Trident },
|
||||
};
|
||||
|
||||
private static Dictionary<int, EntityType> mappingsMobs = new Dictionary<int, EntityType>()
|
||||
private static Dictionary<int, EntityType> mappingsMobs = new()
|
||||
{
|
||||
// https://wiki.vg/Entity_metadata#Mobs
|
||||
{ 0, EntityType.AreaEffectCloud },
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace MinecraftClient.Mapping.EntityPalettes
|
|||
/// </summary>
|
||||
public class EntityPalette18 : EntityPalette
|
||||
{
|
||||
private static Dictionary<int, EntityType> mappingsObjects = new Dictionary<int, EntityType>()
|
||||
private static Dictionary<int, EntityType> mappingsObjects = new()
|
||||
{
|
||||
// https://wiki.vg/Entity_metadata#Objects
|
||||
{ 1, EntityType.Boat },
|
||||
|
|
@ -39,7 +39,7 @@ namespace MinecraftClient.Mapping.EntityPalettes
|
|||
{ 93, EntityType.DragonFireball },
|
||||
};
|
||||
|
||||
private static Dictionary<int, EntityType> mappingsMobs = new Dictionary<int, EntityType>() {
|
||||
private static Dictionary<int, EntityType> mappingsMobs = new() {
|
||||
{ 1, EntityType.Item },
|
||||
{ 2, EntityType.ExperienceOrb },
|
||||
{ 8, EntityType.LeashKnot },
|
||||
|
|
|
|||
|
|
@ -338,8 +338,8 @@ namespace MinecraftClient.Mapping
|
|||
|
||||
public BinaryHeap()
|
||||
{
|
||||
heapList = new List<Node>();
|
||||
locationList = new HashSet<Location>();
|
||||
heapList = new();
|
||||
locationList = new();
|
||||
MinHScoreNode = null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 },
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue