This commit is contained in:
BruceChen 2022-08-28 16:18:29 +08:00
parent dff3f23b03
commit 75e7b0e37d
4 changed files with 26 additions and 6 deletions

View file

@ -36,6 +36,7 @@
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.Windows.Compatibility" Version="5.0.2" /> <PackageReference Include="Microsoft.Windows.Compatibility" Version="5.0.2" />
<PackageReference Include="SingleFileExtractor.Core" Version="1.0.1" /> <PackageReference Include="SingleFileExtractor.Core" Version="1.0.1" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="6.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Remove="config\ChatBots\AutoLook.cs" /> <Compile Remove="config\ChatBots\AutoLook.cs" />

View file

@ -81,6 +81,9 @@ namespace MinecraftClient
// Apply to all other operating systems. // Apply to all other operating systems.
Console.OutputEncoding = Console.InputEncoding = Encoding.UTF8; 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"); ConsoleIO.WriteLine($"Minecraft Console Client v{Version} - for MC {MCLowestVersion} to {MCHighestVersion} - Github.com/MCCTeam");

View file

@ -74,6 +74,16 @@ namespace MinecraftClient.Protocol.Handlers
else return ""; else return "";
} }
/// <summary>
/// Skip a string from a cache of bytes and remove it from the cache
/// </summary>
/// <param name="cache">Cache of bytes to read from</param>
public void SkipNextString(Queue<byte> cache)
{
int length = ReadNextVarInt(cache);
DropData(length, cache);
}
/// <summary> /// <summary>
/// Read a boolean from a cache of bytes and remove it from the cache /// Read a boolean from a cache of bytes and remove it from the cache
/// </summary> /// </summary>

View file

@ -361,7 +361,7 @@ namespace MinecraftClient.Protocol.Handlers
else else
dataTypes.ReadNextByte(packetData); // Max Players - 1.16.1 and below dataTypes.ReadNextByte(packetData); // Max Players - 1.16.1 and below
if (protocolversion < MC_1_16_Version) 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) if (protocolversion >= MC_1_14_Version)
dataTypes.ReadNextVarInt(packetData); // View distance - 1.14 and above dataTypes.ReadNextVarInt(packetData); // View distance - 1.14 and above
if (protocolversion >= MC_1_18_1_Version) if (protocolversion >= MC_1_18_1_Version)
@ -380,7 +380,7 @@ namespace MinecraftClient.Protocol.Handlers
bool hasDeathLocation = dataTypes.ReadNextBool(packetData); // Has death location bool hasDeathLocation = dataTypes.ReadNextBool(packetData); // Has death location
if (hasDeathLocation) if (hasDeathLocation)
{ {
dataTypes.ReadNextString(packetData); // Death dimension name: Identifier dataTypes.SkipNextString(packetData); // Death dimension name: Identifier
dataTypes.ReadNextLocation(packetData); // Death location dataTypes.ReadNextLocation(packetData); // Death location
} }
} }
@ -475,7 +475,7 @@ namespace MinecraftClient.Protocol.Handlers
if (protocolversion >= MC_1_16_Version) if (protocolversion >= MC_1_16_Version)
dataTypes.ReadNextByte(packetData); // Previous Game mode - 1.16 and above dataTypes.ReadNextByte(packetData); // Previous Game mode - 1.16 and above
if (protocolversion < MC_1_16_Version) 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) if (protocolversion >= MC_1_16_Version)
{ {
dataTypes.ReadNextBool(packetData); // Is Debug - 1.16 and above dataTypes.ReadNextBool(packetData); // Is Debug - 1.16 and above
@ -962,7 +962,13 @@ namespace MinecraftClient.Protocol.Handlers
break; break;
case 0x03: //Update display name case 0x03: //Update display name
if (dataTypes.ReadNextBool(packetData)) 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; break;
case 0x04: //Player Leave case 0x04: //Player Leave
handler.OnPlayerLeave(uuid); handler.OnPlayerLeave(uuid);
@ -1002,7 +1008,7 @@ namespace MinecraftClient.Protocol.Handlers
{ {
// Skip optional tooltip for each tab-complete result // Skip optional tooltip for each tab-complete result
if (dataTypes.ReadNextBool(packetData)) 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)); string forcedMessage = ChatParser.ParseText(dataTypes.ReadNextString(packetData));
bool hasPromptMessage = dataTypes.ReadNextBool(packetData); // Has Prompt Message (Boolean) - 1.17 and above bool hasPromptMessage = dataTypes.ReadNextBool(packetData); // Has Prompt Message (Boolean) - 1.17 and above
if (hasPromptMessage) 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) // 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 if (!url.StartsWith("http") && hash.Length != 40) // Some server may have null hash value