Merge pull request #2939: Add Minecraft 1.21.7/1.21.8 (Protocol 772) Support

Add Minecraft 1.21.7/1.21.8 (Protocol 772) Support
This commit is contained in:
BruceChen 2026-03-21 14:45:13 +08:00 committed by GitHub
commit 60c2b9ea7e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 1455 additions and 14 deletions

File diff suppressed because it is too large Load diff

View file

@ -813,6 +813,7 @@ namespace MinecraftClient.Inventory
MusicDiscCreator,
MusicDiscCreatorMusicBox,
MusicDiscFar,
MusicDiscLavaChicken,
MusicDiscMall,
MusicDiscMellohi,
MusicDiscOtherside,

View file

@ -24,7 +24,7 @@ public abstract class EntityMetadataPalette
<= Protocol18Handler.MC_1_19_3_Version => new EntityMetadataPalette1193(), // 1.19.3
< Protocol18Handler.MC_1_20_6_Version => new EntityMetadataPalette1194(), // 1.19.4 - 1.20.4
<= Protocol18Handler.MC_1_21_4_Version => new EntityMetadataPalette1206(), // 1.20.6 - 1.21.4
<= Protocol18Handler.MC_1_21_6_Version => new EntityMetadataPalette1215(), // 1.21.5 - 1.21.6
<= Protocol18Handler.MC_1_21_7_Version => new EntityMetadataPalette1215(), // 1.21.5 - 1.21.7
_ => throw new NotImplementedException()
};
}

View file

@ -46,7 +46,7 @@ namespace MinecraftClient
public const string Version = MCHighestVersion;
public const string MCLowestVersion = "1.4.6";
public const string MCHighestVersion = "1.21.2";
public const string MCHighestVersion = "1.21.8";
public static readonly string? BuildInfo = null;
private static Tuple<Thread, CancellationTokenSource>? offlinePrompt = null;

View file

@ -48,9 +48,9 @@ namespace MinecraftClient.Protocol.Handlers
{
PacketTypePalette p = protocol switch
{
> Protocol18Handler.MC_1_21_6_Version => throw new NotImplementedException(Translations
> Protocol18Handler.MC_1_21_7_Version => throw new NotImplementedException(Translations
.exception_palette_packet),
<= Protocol18Handler.MC_1_21_6_Version and > Protocol18Handler.MC_1_21_5_Version => new PacketPalette1216(),
<= Protocol18Handler.MC_1_21_7_Version and > Protocol18Handler.MC_1_21_5_Version => new PacketPalette1216(),
<= Protocol18Handler.MC_1_21_5_Version and > Protocol18Handler.MC_1_21_4_Version => new PacketPalette1215(),
<= Protocol18Handler.MC_1_21_4_Version and > Protocol18Handler.MC_1_21_2_Version => new PacketPalette1214(),
<= Protocol18Handler.MC_1_8_Version => new PacketPalette17(),

View file

@ -77,6 +77,7 @@ namespace MinecraftClient.Protocol.Handlers
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;
internal const int MC_1_21_7_Version = 772;
private int compression_treshold = -1;
private int autocomplete_transaction_id = 0;
@ -128,21 +129,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_6_Version)
if (handler.GetTerrainEnabled() && protocolVersion > MC_1_21_7_Version)
{
log.Error($"§c{Translations.extra_terrainandmovement_disabled}");
handler.SetTerrainEnabled(false);
}
if (handler.GetInventoryEnabled() &&
protocolVersion is < MC_1_8_Version or > MC_1_21_6_Version)
protocolVersion is < MC_1_8_Version or > MC_1_21_7_Version)
{
log.Error($"§c{Translations.extra_inventory_disabled}");
handler.SetInventoryEnabled(false);
}
if (handler.GetEntityHandlingEnabled() &&
protocolVersion is < MC_1_8_Version or > MC_1_21_6_Version)
protocolVersion is < MC_1_8_Version or > MC_1_21_7_Version)
{
log.Error($"§c{Translations.extra_entity_disabled}");
handler.SetEntityHandlingEnabled(false);
@ -151,9 +152,9 @@ namespace MinecraftClient.Protocol.Handlers
Block.Palette = protocolVersion switch
{
// Block palette
> MC_1_21_6_Version when handler.GetTerrainEnabled() =>
> MC_1_21_7_Version when handler.GetTerrainEnabled() =>
throw new NotImplementedException(Translations.exception_palette_block),
>= MC_1_21_6_Version => new Palette1216(),
>= MC_1_21_6_Version => new Palette1216(), // 1.21.7 blocks unchanged, reuse 1216
>= MC_1_21_5_Version => new Palette1215(),
>= MC_1_21_4_Version => new Palette1214(),
>= MC_1_21_2_Version => new Palette1212(),
@ -174,9 +175,9 @@ namespace MinecraftClient.Protocol.Handlers
entityPalette = protocolVersion switch
{
// Entity palette
> MC_1_21_6_Version when handler.GetEntityHandlingEnabled() =>
> MC_1_21_7_Version when handler.GetEntityHandlingEnabled() =>
throw new NotImplementedException(Translations.exception_palette_entity),
>= MC_1_21_6_Version => new EntityPalette1216(),
>= MC_1_21_6_Version => new EntityPalette1216(), // 1.21.7 entities unchanged, reuse 1216
>= MC_1_21_5_Version => new EntityPalette1215(),
>= MC_1_21_4_Version => new EntityPalette1214(),
>= MC_1_21_2_Version => new EntityPalette1212(),
@ -201,8 +202,9 @@ namespace MinecraftClient.Protocol.Handlers
itemPalette = protocolVersion switch
{
// Item palette
> MC_1_21_6_Version when handler.GetInventoryEnabled() =>
> MC_1_21_7_Version when handler.GetInventoryEnabled() =>
throw new NotImplementedException(Translations.exception_palette_item),
>= MC_1_21_7_Version => new ItemPalette1217(),
>= MC_1_21_6_Version => new ItemPalette1216(),
>= MC_1_21_5_Version => new ItemPalette1215(),
>= MC_1_21_4_Version => new ItemPalette1214(),
@ -2659,7 +2661,7 @@ namespace MinecraftClient.Protocol.Handlers
// Also make a palette for field? Will be a lot of work
var healthField = protocolVersion switch
{
> MC_1_21_6_Version => throw new NotImplementedException(Translations
> MC_1_21_7_Version => throw new NotImplementedException(Translations
.exception_palette_healthfield),
// 1.17 and above
>= MC_1_17_Version => 9,

View file

@ -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, 771
769, 770, 771, 772
};
if (Array.IndexOf(suppoertedVersionsProtocol18, protocolVersion) > -1)
@ -362,6 +362,9 @@ namespace MinecraftClient.Protocol
return 770;
case "1.21.6":
return 771;
case "1.21.7":
case "1.21.8":
return 772;
default:
return 0;
}
@ -447,6 +450,7 @@ namespace MinecraftClient.Protocol
769 => "1.21.4",
770 => "1.21.5",
771 => "1.21.6",
772 => "1.21.7",
_ => "0.0"
};
}