diff --git a/MinecraftClient/MinecraftClient.csproj b/MinecraftClient/MinecraftClient.csproj
index 4ea125d4..6641d0cf 100644
--- a/MinecraftClient/MinecraftClient.csproj
+++ b/MinecraftClient/MinecraftClient.csproj
@@ -36,6 +36,7 @@
+
diff --git a/MinecraftClient/Program.cs b/MinecraftClient/Program.cs
index 3dd50064..434ee8d5 100644
--- a/MinecraftClient/Program.cs
+++ b/MinecraftClient/Program.cs
@@ -81,6 +81,9 @@ namespace MinecraftClient
// Apply to all other operating systems.
Console.OutputEncoding = Console.InputEncoding = Encoding.UTF8;
}
+
+ // Fix issue #2119
+ Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
});
ConsoleIO.WriteLine($"Minecraft Console Client v{Version} - for MC {MCLowestVersion} to {MCHighestVersion} - Github.com/MCCTeam");
diff --git a/MinecraftClient/Protocol/Handlers/DataTypes.cs b/MinecraftClient/Protocol/Handlers/DataTypes.cs
index d1a90d94..0b908055 100644
--- a/MinecraftClient/Protocol/Handlers/DataTypes.cs
+++ b/MinecraftClient/Protocol/Handlers/DataTypes.cs
@@ -74,6 +74,16 @@ namespace MinecraftClient.Protocol.Handlers
else return "";
}
+ ///
+ /// Skip a string from a cache of bytes and remove it from the cache
+ ///
+ /// Cache of bytes to read from
+ public void SkipNextString(Queue cache)
+ {
+ int length = ReadNextVarInt(cache);
+ DropData(length, cache);
+ }
+
///
/// Read a boolean from a cache of bytes and remove it from the cache
///
diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs
index 3de1909e..26cc8de7 100644
--- a/MinecraftClient/Protocol/Handlers/Protocol18.cs
+++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs
@@ -361,7 +361,7 @@ namespace MinecraftClient.Protocol.Handlers
else
dataTypes.ReadNextByte(packetData); // Max Players - 1.16.1 and below
if (protocolversion < MC_1_16_Version)
- dataTypes.ReadNextString(packetData); // Level Type - 1.15 and below
+ dataTypes.SkipNextString(packetData); // Level Type - 1.15 and below
if (protocolversion >= MC_1_14_Version)
dataTypes.ReadNextVarInt(packetData); // View distance - 1.14 and above
if (protocolversion >= MC_1_18_1_Version)
@@ -380,7 +380,7 @@ namespace MinecraftClient.Protocol.Handlers
bool hasDeathLocation = dataTypes.ReadNextBool(packetData); // Has death location
if (hasDeathLocation)
{
- dataTypes.ReadNextString(packetData); // Death dimension name: Identifier
+ dataTypes.SkipNextString(packetData); // Death dimension name: Identifier
dataTypes.ReadNextLocation(packetData); // Death location
}
}
@@ -475,7 +475,7 @@ namespace MinecraftClient.Protocol.Handlers
if (protocolversion >= MC_1_16_Version)
dataTypes.ReadNextByte(packetData); // Previous Game mode - 1.16 and above
if (protocolversion < MC_1_16_Version)
- dataTypes.ReadNextString(packetData); // Level Type - 1.15 and below
+ dataTypes.SkipNextString(packetData); // Level Type - 1.15 and below
if (protocolversion >= MC_1_16_Version)
{
dataTypes.ReadNextBool(packetData); // Is Debug - 1.16 and above
@@ -962,7 +962,13 @@ namespace MinecraftClient.Protocol.Handlers
break;
case 0x03: //Update display name
if (dataTypes.ReadNextBool(packetData))
- dataTypes.ReadNextString(packetData);
+ {
+ PlayerInfo? player = handler.GetPlayerInfo(uuid);
+ if (player != null)
+ player.DisplayName = dataTypes.ReadNextString(packetData);
+ else
+ dataTypes.SkipNextString(packetData);
+ }
break;
case 0x04: //Player Leave
handler.OnPlayerLeave(uuid);
@@ -1002,7 +1008,7 @@ namespace MinecraftClient.Protocol.Handlers
{
// Skip optional tooltip for each tab-complete result
if (dataTypes.ReadNextBool(packetData))
- dataTypes.ReadNextString(packetData);
+ dataTypes.SkipNextString(packetData);
}
}
@@ -1122,7 +1128,7 @@ namespace MinecraftClient.Protocol.Handlers
string forcedMessage = ChatParser.ParseText(dataTypes.ReadNextString(packetData));
bool hasPromptMessage = dataTypes.ReadNextBool(packetData); // Has Prompt Message (Boolean) - 1.17 and above
if (hasPromptMessage)
- dataTypes.ReadNextString(packetData); // Prompt Message (Optional Chat) - 1.17 and above
+ dataTypes.SkipNextString(packetData); // Prompt Message (Optional Chat) - 1.17 and above
}
// Some server plugins may send invalid resource packs to probe the client and we need to ignore them (issue #1056)
if (!url.StartsWith("http") && hash.Length != 40) // Some server may have null hash value