mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
https://github.com/ORelio/Minecraft-Console-Client/issues/493: UUID not properly storing due to GUID conversion (need to convert a Java big-endian Guid to a C# little-endian Guid)
This commit is contained in:
parent
33edd15c9b
commit
b57630a5e4
1 changed files with 33 additions and 1 deletions
|
|
@ -1368,7 +1368,39 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
/// <returns>The uuid</returns>
|
||||
private static Guid readNextUUID(List<byte> cache)
|
||||
{
|
||||
return new Guid(readData(16, cache));
|
||||
byte[] javaUUID = readData(16, cache);
|
||||
Guid guid;
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
guid = ToLittleEndian(javaUUID);
|
||||
}
|
||||
else
|
||||
{
|
||||
guid = new Guid(javaUUID);
|
||||
}
|
||||
return guid;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// convert a Java big-endian Guid to a .NET little-endian Guid.
|
||||
/// </summary>
|
||||
/// <returns>GUID in little endian.</returns>
|
||||
private static Guid ToLittleEndian(byte[] java)
|
||||
{
|
||||
byte[] net = new byte[16];
|
||||
for (int i = 8; i < 16; i++)
|
||||
{
|
||||
net[i] = java[i];
|
||||
}
|
||||
net[3] = java[0];
|
||||
net[2] = java[1];
|
||||
net[1] = java[2];
|
||||
net[0] = java[3];
|
||||
net[5] = java[4];
|
||||
net[4] = java[5];
|
||||
net[6] = java[7];
|
||||
net[7] = java[6];
|
||||
return new Guid(net);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue