From 96a7e4a659f817c099293f0d491a1054075e4c63 Mon Sep 17 00:00:00 2001 From: BruceChen Date: Sat, 21 Mar 2026 11:34:20 +0800 Subject: [PATCH] feat: add MC 1.21.6 (protocol 771) version constants and enum values - Add protocol 771 constant MC_1_21_6_Version in Protocol18.cs - Register 1.21.6 in ProtocolHandler (version map, supported list) - Extend upper-bound checks from MC_1_21_5 to MC_1_21_6 - Add 19 new ItemType entries (16 colored Harnesses, DriedGhast, HappyGhastSpawnEgg, MusicDiscTears) - Add HappyGhast to EntityType enum - Add DriedGhast to Material enum - Add new packet types: Waypoint, ClearDialog, ShowDialog (clientbound), ChangeGameMode, CustomClickAction (serverbound), ClearDialog, ShowDialog (config clientbound), CustomClickAction (config serverbound) Made-with: Cursor --- MinecraftClient/Inventory/ItemType.cs | 19 +++++++++++++++++++ MinecraftClient/Mapping/EntityType.cs | 1 + MinecraftClient/Mapping/Material.cs | 1 + .../Handlers/ConfigurationPacketTypesIn.cs | 2 ++ .../Handlers/ConfigurationPacketTypesOut.cs | 1 + .../Protocol/Handlers/PacketTypesIn.cs | 3 +++ .../Protocol/Handlers/PacketTypesOut.cs | 2 ++ .../Protocol/Handlers/Protocol18.cs | 15 ++++++++------- MinecraftClient/Protocol/ProtocolHandler.cs | 5 ++++- 9 files changed, 41 insertions(+), 8 deletions(-) diff --git a/MinecraftClient/Inventory/ItemType.cs b/MinecraftClient/Inventory/ItemType.cs index 1809b7ab..a51d9d0f 100644 --- a/MinecraftClient/Inventory/ItemType.cs +++ b/MinecraftClient/Inventory/ItemType.cs @@ -122,6 +122,7 @@ namespace MinecraftClient.Inventory BlackTerracotta, BlackWool, BlackBundle, + BlackHarness, Blackstone, BlackstoneSlab, BlackstoneStairs, @@ -148,6 +149,7 @@ namespace MinecraftClient.Inventory BlueTerracotta, BlueWool, BlueBundle, + BlueHarness, BoggedSpawnEgg, BoltArmorTrimSmithingTemplate, Bone, @@ -188,6 +190,7 @@ namespace MinecraftClient.Inventory BrownTerracotta, BrownWool, BrownBundle, + BrownHarness, Brush, BubbleCoral, BubbleCoralBlock, @@ -352,6 +355,7 @@ namespace MinecraftClient.Inventory CyanTerracotta, CyanWool, CyanBundle, + CyanHarness, DamagedAnvil, Dandelion, DangerPotterySherd, @@ -438,6 +442,7 @@ namespace MinecraftClient.Inventory DragonBreath, DragonEgg, DragonHead, + DriedGhast, DriedKelp, DriedKelpBlock, DripstoneBlock, @@ -566,6 +571,7 @@ namespace MinecraftClient.Inventory GrayTerracotta, GrayWool, GrayBundle, + GrayHarness, GreenBanner, GreenBed, GreenCandle, @@ -580,12 +586,14 @@ namespace MinecraftClient.Inventory GreenTerracotta, GreenWool, GreenBundle, + GreenHarness, Grindstone, GuardianSpawnEgg, Gunpowder, GusterBannerPattern, GusterPotterySherd, HangingRoots, + HappyGhastSpawnEgg, HayBlock, HeartOfTheSea, HeartPotterySherd, @@ -689,6 +697,7 @@ namespace MinecraftClient.Inventory LightBlueTerracotta, LightBlueWool, LightBlueBundle, + LightBlueHarness, LightGrayBanner, LightGrayBed, LightGrayCandle, @@ -703,6 +712,7 @@ namespace MinecraftClient.Inventory LightGrayTerracotta, LightGrayWool, LightGrayBundle, + LightGrayHarness, LightWeightedPressurePlate, LightningRod, Lilac, @@ -722,6 +732,7 @@ namespace MinecraftClient.Inventory LimeTerracotta, LimeWool, LimeBundle, + LimeHarness, LingeringPotion, LlamaSpawnEgg, Lodestone, @@ -741,6 +752,7 @@ namespace MinecraftClient.Inventory MagentaTerracotta, MagentaWool, MagentaBundle, + MagentaHarness, MagmaBlock, MagmaCream, MagmaCubeSpawnEgg, @@ -809,6 +821,7 @@ namespace MinecraftClient.Inventory MusicDiscRelic, MusicDiscStal, MusicDiscStrad, + MusicDiscTears, MusicDiscWait, MusicDiscWard, Mutton, @@ -881,6 +894,7 @@ namespace MinecraftClient.Inventory OrangeTulip, OrangeWool, OrangeBundle, + OrangeHarness, OxeyeDaisy, OxidizedChiseledCopper, OxidizedCopper, @@ -944,6 +958,7 @@ namespace MinecraftClient.Inventory PinkTulip, PinkWool, PinkBundle, + PinkHarness, Piston, PitcherPlant, PitcherPod, @@ -1018,6 +1033,7 @@ namespace MinecraftClient.Inventory PurpleTerracotta, PurpleWool, PurpleBundle, + PurpleHarness, PurpurBlock, PurpurPillar, PurpurSlab, @@ -1069,6 +1085,7 @@ namespace MinecraftClient.Inventory RedTulip, RedWool, RedBundle, + RedHarness, Redstone, RedstoneBlock, RedstoneLamp, @@ -1373,6 +1390,7 @@ namespace MinecraftClient.Inventory WhiteTulip, WhiteWool, WhiteBundle, + WhiteHarness, WildArmorTrimSmithingTemplate, Wildflowers, // wildflowers WindCharge, @@ -1404,6 +1422,7 @@ namespace MinecraftClient.Inventory YellowTerracotta, YellowWool, YellowBundle, + YellowHarness, ZoglinSpawnEgg, ZombieHead, ZombieHorseSpawnEgg, diff --git a/MinecraftClient/Mapping/EntityType.cs b/MinecraftClient/Mapping/EntityType.cs index 2dc813c8..6e75efce 100644 --- a/MinecraftClient/Mapping/EntityType.cs +++ b/MinecraftClient/Mapping/EntityType.cs @@ -79,6 +79,7 @@ namespace MinecraftClient.Mapping GlowSquid, Goat, Guardian, + HappyGhast, Hoglin, HopperMinecart, Horse, diff --git a/MinecraftClient/Mapping/Material.cs b/MinecraftClient/Mapping/Material.cs index 9485e760..d0c71840 100644 --- a/MinecraftClient/Mapping/Material.cs +++ b/MinecraftClient/Mapping/Material.cs @@ -364,6 +364,7 @@ namespace MinecraftClient.Mapping DragonEgg, DragonHead, DragonWallHead, + DriedGhast, DriedKelpBlock, DripstoneBlock, Dropper, diff --git a/MinecraftClient/Protocol/Handlers/ConfigurationPacketTypesIn.cs b/MinecraftClient/Protocol/Handlers/ConfigurationPacketTypesIn.cs index 0648601a..edc48e82 100644 --- a/MinecraftClient/Protocol/Handlers/ConfigurationPacketTypesIn.cs +++ b/MinecraftClient/Protocol/Handlers/ConfigurationPacketTypesIn.cs @@ -19,6 +19,8 @@ public enum ConfigurationPacketTypesIn StoreCookie, Transfer, UpdateTags, + ClearDialog, // Added in 1.21.6 + ShowDialog, // Added in 1.21.6 Unknown } diff --git a/MinecraftClient/Protocol/Handlers/ConfigurationPacketTypesOut.cs b/MinecraftClient/Protocol/Handlers/ConfigurationPacketTypesOut.cs index 32a99ec2..d3f7dd0b 100644 --- a/MinecraftClient/Protocol/Handlers/ConfigurationPacketTypesOut.cs +++ b/MinecraftClient/Protocol/Handlers/ConfigurationPacketTypesOut.cs @@ -10,6 +10,7 @@ public enum ConfigurationPacketTypesOut ResourcePackResponse, CookieResponse, KnownDataPacks, + CustomClickAction, // Added in 1.21.6 Unknown } \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/PacketTypesIn.cs b/MinecraftClient/Protocol/Handlers/PacketTypesIn.cs index 7defe5e7..7e257b27 100644 --- a/MinecraftClient/Protocol/Handlers/PacketTypesIn.cs +++ b/MinecraftClient/Protocol/Handlers/PacketTypesIn.cs @@ -161,5 +161,8 @@ namespace MinecraftClient.Protocol.Handlers WorldBorderSize, // WorldBorderWarningDelay, // WorldBorderWarningReach, // + Waypoint, // Added in 1.21.6 + ClearDialog, // Added in 1.21.6 + ShowDialog, // Added in 1.21.6 } } diff --git a/MinecraftClient/Protocol/Handlers/PacketTypesOut.cs b/MinecraftClient/Protocol/Handlers/PacketTypesOut.cs index 3b1523eb..111f3653 100644 --- a/MinecraftClient/Protocol/Handlers/PacketTypesOut.cs +++ b/MinecraftClient/Protocol/Handlers/PacketTypesOut.cs @@ -76,5 +76,7 @@ namespace MinecraftClient.Protocol.Handlers UseItem, // VehicleMove, // WindowConfirmation, // + ChangeGameMode, // Added in 1.21.6 + CustomClickAction, // Added in 1.21.6 } } diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index 9beae52e..8f4f0d99 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -76,6 +76,7 @@ namespace MinecraftClient.Protocol.Handlers internal const int MC_1_21_2_Version = 768; internal const int MC_1_21_4_Version = 769; internal const int MC_1_21_5_Version = 770; + internal const int MC_1_21_6_Version = 771; private int compression_treshold = -1; private int autocomplete_transaction_id = 0; @@ -127,21 +128,21 @@ namespace MinecraftClient.Protocol.Handlers lastSeenMessagesCollector = protocolVersion >= MC_1_19_3_Version ? new(20) : new(5); chunkBatchStartTime = GetNanos(); - if (handler.GetTerrainEnabled() && protocolVersion > MC_1_21_5_Version) + if (handler.GetTerrainEnabled() && protocolVersion > MC_1_21_6_Version) { log.Error($"§c{Translations.extra_terrainandmovement_disabled}"); handler.SetTerrainEnabled(false); } if (handler.GetInventoryEnabled() && - protocolVersion is < MC_1_8_Version or > MC_1_21_5_Version) + protocolVersion is < MC_1_8_Version or > MC_1_21_6_Version) { log.Error($"§c{Translations.extra_inventory_disabled}"); handler.SetInventoryEnabled(false); } if (handler.GetEntityHandlingEnabled() && - protocolVersion is < MC_1_8_Version or > MC_1_21_5_Version) + protocolVersion is < MC_1_8_Version or > MC_1_21_6_Version) { log.Error($"§c{Translations.extra_entity_disabled}"); handler.SetEntityHandlingEnabled(false); @@ -150,7 +151,7 @@ namespace MinecraftClient.Protocol.Handlers Block.Palette = protocolVersion switch { // Block palette - > MC_1_21_5_Version when handler.GetTerrainEnabled() => + > MC_1_21_6_Version when handler.GetTerrainEnabled() => throw new NotImplementedException(Translations.exception_palette_block), >= MC_1_21_5_Version => new Palette1215(), >= MC_1_21_4_Version => new Palette1214(), @@ -172,7 +173,7 @@ namespace MinecraftClient.Protocol.Handlers entityPalette = protocolVersion switch { // Entity palette - > MC_1_21_5_Version when handler.GetEntityHandlingEnabled() => + > MC_1_21_6_Version when handler.GetEntityHandlingEnabled() => throw new NotImplementedException(Translations.exception_palette_entity), >= MC_1_21_5_Version => new EntityPalette1215(), >= MC_1_21_4_Version => new EntityPalette1214(), @@ -198,7 +199,7 @@ namespace MinecraftClient.Protocol.Handlers itemPalette = protocolVersion switch { // Item palette - > MC_1_21_5_Version when handler.GetInventoryEnabled() => + > MC_1_21_6_Version when handler.GetInventoryEnabled() => throw new NotImplementedException(Translations.exception_palette_item), >= MC_1_21_5_Version => new ItemPalette1215(), >= MC_1_21_4_Version => new ItemPalette1214(), @@ -2655,7 +2656,7 @@ namespace MinecraftClient.Protocol.Handlers // Also make a palette for field? Will be a lot of work var healthField = protocolVersion switch { - > MC_1_21_5_Version => throw new NotImplementedException(Translations + > MC_1_21_6_Version => throw new NotImplementedException(Translations .exception_palette_healthfield), // 1.17 and above >= MC_1_17_Version => 9, diff --git a/MinecraftClient/Protocol/ProtocolHandler.cs b/MinecraftClient/Protocol/ProtocolHandler.cs index 684e351b..7c7d69ba 100644 --- a/MinecraftClient/Protocol/ProtocolHandler.cs +++ b/MinecraftClient/Protocol/ProtocolHandler.cs @@ -154,7 +154,7 @@ namespace MinecraftClient.Protocol { 4, 5, 47, 107, 108, 109, 110, 210, 315, 316, 335, 338, 340, 393, 401, 404, 477, 480, 485, 490, 498, 573, 575, 578, 735, 736, 751, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, - 769, 770 + 769, 770, 771 }; if (Array.IndexOf(suppoertedVersionsProtocol18, protocolVersion) > -1) @@ -360,6 +360,8 @@ namespace MinecraftClient.Protocol return 769; case "1.21.5": return 770; + case "1.21.6": + return 771; default: return 0; } @@ -444,6 +446,7 @@ namespace MinecraftClient.Protocol 768 => "1.21.2", 769 => "1.21.4", 770 => "1.21.5", + 771 => "1.21.6", _ => "0.0" }; }