diff --git a/MinecraftClient/Protocol/Handlers/Protocol17.cs b/MinecraftClient/Protocol/Handlers/Protocol17.cs index 387c8bfc..2ab483b7 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol17.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol17.cs @@ -6,6 +6,7 @@ using System.Net.Sockets; using System.Threading; using MinecraftClient.Crypto; using MinecraftClient.Proxy; +using System.Security.Cryptography; namespace MinecraftClient.Protocol.Handlers { @@ -96,6 +97,17 @@ namespace MinecraftClient.Protocol.Handlers case 0x02: handler.OnTextReceived(ChatParser.ParseText(readNextString())); break; + case 0x38: + string name = readNextString(); + bool online = readNextBool(); + short ping = readNextShort(); + Guid FakeUUID = new Guid(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(name)).Take(16).ToArray()); + if (online) + { + handler.OnPlayerJoin(FakeUUID, name); + } + else handler.OnPlayerLeave(FakeUUID); + break; case 0x3A: int autocomplete_count = readNextVarInt(); string tab_list = ""; @@ -186,6 +198,44 @@ namespace MinecraftClient.Protocol.Handlers else return ""; } + /// + /// Read a uuid from the network + /// + /// Cache of bytes to read from + /// The uuid + + private Guid readNextUUID() + { + byte[] cache = new byte[16]; + Receive(cache, 0, 16, SocketFlags.None); + return new Guid(cache); + } + + /// + /// Read a short from the network + /// + /// + + private short readNextShort() + { + byte[] tmp = new byte[2]; + Receive(tmp, 0, 2, SocketFlags.None); + Array.Reverse(tmp); + return BitConverter.ToInt16(tmp, 0); + } + + /// + /// Read a boolean from the network + /// + /// + + private bool readNextBool() + { + byte[] tmp = new byte[1]; + Receive(tmp, 0, 1, SocketFlags.None); + return tmp[0] != 0x00; + } + /// /// Read a byte array from the network ///