From d3a54e8caf03592c5992314f7565a096b7bcf53e Mon Sep 17 00:00:00 2001 From: ORelio Date: Thu, 9 Jun 2016 21:10:45 +0200 Subject: [PATCH] Add support for MC 1.10.0 See #159 --- MinecraftClient/Protocol/Handlers/Protocol18.cs | 11 ++++++++--- MinecraftClient/Protocol/ProtocolHandler.cs | 4 +++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index 81c16321..94a75ff5 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -13,13 +13,14 @@ using MinecraftClient.Mapping; namespace MinecraftClient.Protocol.Handlers { /// - /// Implementation for Minecraft 1.7.X, 1.8.X, 1.9.X Protocols + /// Implementation for Minecraft 1.7.X, 1.8.X, 1.9.X, 1.10.X Protocols /// class Protocol18Handler : IMinecraftCom { private const int MC18Version = 47; private const int MC19Version = 107; + private const int MC110Version = 210; private int compression_treshold = 0; private bool autocomplete_received = false; @@ -555,8 +556,12 @@ namespace MinecraftClient.Protocol.Handlers string url = readNextString(packetData); string hash = readNextString(packetData); //Send back "accepted" and "successfully loaded" responses for plugins making use of resource pack mandatory - SendPacket(protocolversion >= MC19Version ? 0x16 : 0x19, concatBytes(getVarInt(hash.Length), Encoding.UTF8.GetBytes(hash), getVarInt(3))); - SendPacket(protocolversion >= MC19Version ? 0x16 : 0x19, concatBytes(getVarInt(hash.Length), Encoding.UTF8.GetBytes(hash), getVarInt(0))); + byte[] responseHeader = new byte[0]; + if (protocolversion < MC110Version) //MC 1.10 does not include resource pack hash in responses + responseHeader = concatBytes(getVarInt(hash.Length), Encoding.UTF8.GetBytes(hash)); + int packResponsePid = protocolversion >= MC19Version ? 0x16 : 0x19; //ID changed in 1.9 + SendPacket(packResponsePid, concatBytes(responseHeader, getVarInt(3))); //Accepted pack + SendPacket(packResponsePid, concatBytes(responseHeader, getVarInt(0))); //Successfully loaded break; default: return false; //Ignored packet diff --git a/MinecraftClient/Protocol/ProtocolHandler.cs b/MinecraftClient/Protocol/ProtocolHandler.cs index cbfcf3b9..fdd2c12a 100644 --- a/MinecraftClient/Protocol/ProtocolHandler.cs +++ b/MinecraftClient/Protocol/ProtocolHandler.cs @@ -71,7 +71,7 @@ namespace MinecraftClient.Protocol int[] supportedVersions_Protocol16 = { 51, 60, 61, 72, 73, 74, 78 }; if (Array.IndexOf(supportedVersions_Protocol16, ProtocolVersion) > -1) return new Protocol16Handler(Client, ProtocolVersion, Handler); - int[] supportedVersions_Protocol18 = { 4, 5, 47, 107, 108, 109, 110 }; + int[] supportedVersions_Protocol18 = { 4, 5, 47, 107, 108, 109, 110, 210 }; if (Array.IndexOf(supportedVersions_Protocol18, ProtocolVersion) > -1) return new Protocol18Handler(Client, ProtocolVersion, Handler, forgeInfo); throw new NotSupportedException("The protocol version no." + ProtocolVersion + " is not supported."); @@ -134,6 +134,8 @@ namespace MinecraftClient.Protocol case "1.9.3": case "1.9.4": return 110; + case "1.10.0": + return 210; default: return 0; }