feat: add version routing, structured components, and metadata for MC 1.21.11

- Add MC_1_21_11_Version constant (protocol 774)
- Create StructuredComponentsRegistry12111 with 104 components (8 new:
  use_effects, minimum_attack_charge, damage_type, attack_range,
  piercing_weapon, kinetic_weapon, swing_animation, zombie_nautilus/variant)
- Add 6 new component classes for 1.21.11 wire formats
- Add RegistryEitherHolderComponent for holderRegistry-backed EitherHolder
- Add ZombieNautilusVariant and HumanoidArm cases in DataTypes.ReadNextMetadata
- Update all version routing in Protocol18, PacketType18Handler,
  EntityMetadataPalette, StructuredComponentsHandler, and ProtocolHandler
- Bump MCHighestVersion to 1.21.11

Made-with: Cursor
This commit is contained in:
BruceChen 2026-03-22 00:56:04 +08:00
parent 50b4b3c8fe
commit 6c36dc341a
14 changed files with 361 additions and 12 deletions

View file

@ -79,6 +79,7 @@ namespace MinecraftClient.Protocol.Handlers
internal const int MC_1_21_6_Version = 771;
internal const int MC_1_21_7_Version = 772;
internal const int MC_1_21_9_Version = 773;
internal const int MC_1_21_11_Version = 774;
private int compression_treshold = -1;
private int autocomplete_transaction_id = 0;
@ -130,21 +131,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_9_Version)
if (handler.GetTerrainEnabled() && protocolVersion > MC_1_21_11_Version)
{
log.Error($"§c{Translations.extra_terrainandmovement_disabled}");
handler.SetTerrainEnabled(false);
}
if (handler.GetInventoryEnabled() &&
protocolVersion is < MC_1_8_Version or > MC_1_21_9_Version)
protocolVersion is < MC_1_8_Version or > MC_1_21_11_Version)
{
log.Error($"§c{Translations.extra_inventory_disabled}");
handler.SetInventoryEnabled(false);
}
if (handler.GetEntityHandlingEnabled() &&
protocolVersion is < MC_1_8_Version or > MC_1_21_9_Version)
protocolVersion is < MC_1_8_Version or > MC_1_21_11_Version)
{
log.Error($"§c{Translations.extra_entity_disabled}");
handler.SetEntityHandlingEnabled(false);
@ -153,7 +154,7 @@ namespace MinecraftClient.Protocol.Handlers
Block.Palette = protocolVersion switch
{
// Block palette
> MC_1_21_9_Version when handler.GetTerrainEnabled() =>
> MC_1_21_11_Version when handler.GetTerrainEnabled() =>
throw new NotImplementedException(Translations.exception_palette_block),
>= MC_1_21_9_Version => new Palette1219(),
>= MC_1_21_6_Version => new Palette1216(), // 1.21.7/1.21.8 blocks unchanged, reuse 1216
@ -177,8 +178,9 @@ namespace MinecraftClient.Protocol.Handlers
entityPalette = protocolVersion switch
{
// Entity palette
> MC_1_21_9_Version when handler.GetEntityHandlingEnabled() =>
> MC_1_21_11_Version when handler.GetEntityHandlingEnabled() =>
throw new NotImplementedException(Translations.exception_palette_entity),
>= MC_1_21_11_Version => new EntityPalette12111(),
>= MC_1_21_9_Version => new EntityPalette1219(),
>= MC_1_21_6_Version => new EntityPalette1216(), // 1.21.7/1.21.8 entities unchanged, reuse 1216
>= MC_1_21_5_Version => new EntityPalette1215(),
@ -205,8 +207,9 @@ namespace MinecraftClient.Protocol.Handlers
itemPalette = protocolVersion switch
{
// Item palette
> MC_1_21_9_Version when handler.GetInventoryEnabled() =>
> MC_1_21_11_Version when handler.GetInventoryEnabled() =>
throw new NotImplementedException(Translations.exception_palette_item),
>= MC_1_21_11_Version => new ItemPalette12111(),
>= MC_1_21_9_Version => new ItemPalette1219(),
>= MC_1_21_7_Version => new ItemPalette1217(),
>= MC_1_21_6_Version => new ItemPalette1216(),
@ -2665,7 +2668,7 @@ namespace MinecraftClient.Protocol.Handlers
// Also make a palette for field? Will be a lot of work
var healthField = protocolVersion switch
{
> MC_1_21_9_Version => throw new NotImplementedException(Translations
> MC_1_21_11_Version => throw new NotImplementedException(Translations
.exception_palette_healthfield),
// 1.17 and above
>= MC_1_17_Version => 9,