mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
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:
parent
c5df6a49c6
commit
2ae31e269f
6 changed files with 66 additions and 92 deletions
|
|
@ -1010,9 +1010,9 @@ namespace MinecraftClient
|
|||
b.SetHandler(this);
|
||||
bots.Add(b);
|
||||
if (init)
|
||||
DispatchBotEvent(bot => bot.Initialize(), new ChatBot[] { b });
|
||||
DispatchBotEvent(bot => bot.Initialize(), [b]);
|
||||
if (handler is not null)
|
||||
DispatchBotEvent(bot => bot.AfterGameJoined(), new ChatBot[] { b });
|
||||
DispatchBotEvent(bot => bot.AfterGameJoined(), [b]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1205,7 +1205,7 @@ namespace MinecraftClient
|
|||
/// <returns></returns>
|
||||
public static char[] GetDisallowedChatCharacters()
|
||||
{
|
||||
return new char[] { (char)167, (char)127 }; // Minecraft color code and ASCII code DEL
|
||||
return [(char)167, (char)127]; // Minecraft color code and ASCII code DEL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -2381,23 +2381,18 @@ namespace MinecraftClient
|
|||
|
||||
if (entities.ContainsKey(entityID))
|
||||
{
|
||||
switch (type)
|
||||
return type switch
|
||||
{
|
||||
case InteractType.Interact:
|
||||
return handler.SendInteractEntity(entityID, (int)type, (int)hand);
|
||||
|
||||
case InteractType.InteractAt:
|
||||
return handler.SendInteractEntity(
|
||||
EntityID: entityID,
|
||||
type: (int)type,
|
||||
X: (float)entities[entityID].Location.X,
|
||||
Y: (float)entities[entityID].Location.Y,
|
||||
Z: (float)entities[entityID].Location.Z,
|
||||
hand: (int)hand);
|
||||
|
||||
default:
|
||||
return handler.SendInteractEntity(entityID, (int)type);
|
||||
}
|
||||
InteractType.Interact => handler.SendInteractEntity(entityID, (int)type, (int)hand),
|
||||
InteractType.InteractAt => handler.SendInteractEntity(
|
||||
EntityID: entityID,
|
||||
type: (int)type,
|
||||
X: (float)entities[entityID].Location.X,
|
||||
Y: (float)entities[entityID].Location.Y,
|
||||
Z: (float)entities[entityID].Location.Z,
|
||||
hand: (int)hand),
|
||||
_ => handler.SendInteractEntity(entityID, (int)type),
|
||||
};
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue