From fd2e3d5797615cd4707ac2db036b93ebb508f2b8 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Tue, 1 Aug 2017 10:34:16 -0700 Subject: [PATCH] Implement 1.12.1 protocol --- MinecraftClient/Program.cs | 4 +- .../Protocol/Handlers/Protocol18.cs | 43 ++++++++++++++++++- MinecraftClient/Protocol/ProtocolHandler.cs | 4 +- 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/MinecraftClient/Program.cs b/MinecraftClient/Program.cs index 0d5fab39..58f232ce 100644 --- a/MinecraftClient/Program.cs +++ b/MinecraftClient/Program.cs @@ -20,9 +20,9 @@ namespace MinecraftClient private static McTcpClient Client; public static string[] startupargs; - public const string Version = "1.12.0 DEV"; + public const string Version = "1.12.1 DEV"; public const string MCLowestVersion = "1.4.6"; - public const string MCHighestVersion = "1.12.0"; + public const string MCHighestVersion = "1.12.1"; private static Thread offlinePrompt = null; private static bool useMcVersionOnce = false; diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index 7a5fae16..6cdb83ca 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -24,6 +24,7 @@ namespace MinecraftClient.Protocol.Handlers private const int MC111Version = 315; private const int MC17w13aVersion = 318; private const int MC112pre5Version = 332; + private const int MC17w31aVersion = 336; private int compression_treshold = 0; private bool autocomplete_received = false; @@ -230,7 +231,7 @@ namespace MinecraftClient.Protocol.Handlers default: return PacketIncomingType.UnknownPacket; } } - else + else if (protocol < MC17w31aVersion) { switch (packetID) { @@ -253,6 +254,29 @@ namespace MinecraftClient.Protocol.Handlers default: return PacketIncomingType.UnknownPacket; } } + else + { + switch (packetID) + { + case 0x1F: return PacketIncomingType.KeepAlive; + case 0x23: return PacketIncomingType.JoinGame; + case 0x0F: return PacketIncomingType.ChatMessage; + case 0x35: return PacketIncomingType.Respawn; + case 0x2F: return PacketIncomingType.PlayerPositionAndLook; + case 0x20: return PacketIncomingType.ChunkData; + case 0x10: return PacketIncomingType.MultiBlockChange; + case 0x0B: return PacketIncomingType.BlockChange; + //MapChunkBulk removed in 1.9 + case 0x1D: return PacketIncomingType.UnloadChunk; + case 0x2E: return PacketIncomingType.PlayerListUpdate; + case 0x0E: return PacketIncomingType.TabCompleteResult; + case 0x18: return PacketIncomingType.PluginMessage; + case 0x1A: return PacketIncomingType.KickPacket; + //NetworkCompressionTreshold removed in 1.9 + case 0x34: return PacketIncomingType.ResourcePackSend; + default: return PacketIncomingType.UnknownPacket; + } + } } /// @@ -324,7 +348,7 @@ namespace MinecraftClient.Protocol.Handlers case PacketOutgoingType.PlayerPositionAndLook: return 0x0E; } } - else + else if (protocol < MC17w31aVersion) { switch (packet) { @@ -339,6 +363,21 @@ namespace MinecraftClient.Protocol.Handlers case PacketOutgoingType.PlayerPositionAndLook: return 0x0F; } } + else + { + switch (packet) + { + case PacketOutgoingType.KeepAlive: return 0x0B; + case PacketOutgoingType.ResourcePackStatus: return 0x17; + case PacketOutgoingType.ChatMessage: return 0x02; + case PacketOutgoingType.ClientStatus: return 0x03; + case PacketOutgoingType.ClientSettings: return 0x04; + case PacketOutgoingType.PluginMessage: return 0x09; + case PacketOutgoingType.TabComplete: return 0x01; + case PacketOutgoingType.PlayerPosition: return 0x0D; + case PacketOutgoingType.PlayerPositionAndLook: return 0x0E; + } + } throw new System.ComponentModel.InvalidEnumArgumentException("Unknown PacketOutgoingType (protocol=" + protocol + ")", (int)packet, typeof(PacketOutgoingType)); } diff --git a/MinecraftClient/Protocol/ProtocolHandler.cs b/MinecraftClient/Protocol/ProtocolHandler.cs index 0a7556fc..a8f797e0 100644 --- a/MinecraftClient/Protocol/ProtocolHandler.cs +++ b/MinecraftClient/Protocol/ProtocolHandler.cs @@ -106,7 +106,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, 210, 315, 316, 335 }; + int[] supportedVersions_Protocol18 = { 4, 5, 47, 107, 108, 109, 110, 210, 315, 316, 335, 338 }; 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."); @@ -185,6 +185,8 @@ namespace MinecraftClient.Protocol case "1.12": case "1.12.0": return 335; + case "1.12.1": + return 338; default: return 0; }