Fix structured components: audit fixes, codec helpers, and serialize implementations

- Fix 5 class naming typos: Unbrekable->Unbreakable, Blook->Book,
  Omnious->Ominous, FoodComponentComponent->FoodComponent
- Fix IntangibleProjectileComponent: extends EmptyComponent (Unit type)
- Delete dead code JukeBoxPlayableComponent.cs (duplicated)
- Implement proper Serialize() on BlocksAttacksComponent,
  KineticWeaponComponent, PiercingWeaponComponent
- Extract shared SoundEventHolder/HolderSet codec helpers into
  StructuredComponentCodecHelpers
- Add TypedEntityDataComponent/TypedBlockEntityDataComponent base classes
  for 1.21.9+ typed entity data format
- Fix variable name: uses1218AttributeAndEquippableFormats ->
  uses1216AttributeAndEquippableFormats
- Add entity data version gate (1.21.9+) to v1215 registry
- Fix chicken/variant and zombie_nautilus/variant component types
- Fix empty packet hang in Protocol18 ReadNextPacket loop
- Add structured components integration test harness
This commit is contained in:
Anon 2026-06-11 21:33:48 +02:00
parent 16637f7eba
commit de96462659
22 changed files with 761 additions and 260 deletions

View file

@ -13,7 +13,7 @@ public class StructuredComponentsRegistry1206 : StructuredComponentRegistry
RegisterComponent<MaxStackSizeComponent>(1, "minecraft:max_stack_size");
RegisterComponent<MaxDamageComponent>(2, "minecraft:max_damage");
RegisterComponent<DamageComponent>(3, "minecraft:damage");
RegisterComponent<UnbrekableComponent1206>(4, "minecraft:unbreakable");
RegisterComponent<UnbreakableComponent1206>(4, "minecraft:unbreakable");
RegisterComponent<CustomNameComponent>(5, "minecraft:custom_name");
RegisterComponent<ItemNameComponent>(6, "minecraft:item_name");
RegisterComponent<LoreNameComponent1206>(7, "minecraft:lore");
@ -29,7 +29,7 @@ public class StructuredComponentsRegistry1206 : StructuredComponentRegistry
RegisterComponent<CreativeSlotLockComponent>(17, "minecraft:creative_slot_lock");
RegisterComponent<EnchantmentGlintOverrideComponent>(18, "minecraft:enchantment_glint_override");
RegisterComponent<IntangibleProjectileComponent>(19, "minecraft:intangible_projectile");
RegisterComponent<FoodComponentComponent>(20, "minecraft:food");
RegisterComponent<FoodComponent>(20, "minecraft:food");
RegisterComponent<FireResistantComponent>(21, "minecraft:fire_resistant");
RegisterComponent<ToolComponent>(22, "minecraft:tool");
RegisterComponent<StoredEnchantmentsComponent>(23, "minecraft:stored_enchantments");
@ -42,15 +42,15 @@ public class StructuredComponentsRegistry1206 : StructuredComponentRegistry
RegisterComponent<BundleContentsComponent>(30, "minecraft:bundle_contents");
RegisterComponent<PotionContentsComponent>(31, "minecraft:potion_contents");
RegisterComponent<SuspiciousStewEffectsComponent>(32, "minecraft:suspicious_stew_effects");
RegisterComponent<WritableBlookContentComponent>(33, "minecraft:writable_book_content");
RegisterComponent<WrittenBlookContentComponent>(34, "minecraft:written_book_content");
RegisterComponent<WritableBookContentComponent>(33, "minecraft:writable_book_content");
RegisterComponent<WrittenBookContentComponent>(34, "minecraft:written_book_content");
RegisterComponent<TrimComponent>(35, "minecraft:trim");
RegisterComponent<DebugStickStateComponent>(36, "minecraft:debug_stick_state");
RegisterComponent<EntityDataComponent>(37, "minecraft:entity_data");
RegisterComponent<BucketEntityDataComponent>(38, "minecraft:bucket_entity_data");
RegisterComponent<BlockEntityDataComponent>(39, "minecraft:block_entity_data");
RegisterComponent<InstrumentComponent>(40, "minecraft:instrument");
RegisterComponent<OmniousBottleAmplifierComponent>(41, "minecraft:ominous_bottle_amplifier");
RegisterComponent<OminousBottleAmplifierComponent>(41, "minecraft:ominous_bottle_amplifier");
RegisterComponent<RecipesComponent>(42, "minecraft:recipes");
RegisterComponent<LodestoneTrackerComponent>(43, "minecraft:lodestone_tracker");
RegisterComponent<FireworkExplosionComponent>(44, "minecraft:firework_explosion");

View file

@ -14,7 +14,7 @@ public class StructuredComponentsRegistry121 : StructuredComponentRegistry
RegisterComponent<MaxStackSizeComponent>(1, "minecraft:max_stack_size");
RegisterComponent<MaxDamageComponent>(2, "minecraft:max_damage");
RegisterComponent<DamageComponent>(3, "minecraft:damage");
RegisterComponent<UnbrekableComponent1206>(4, "minecraft:unbreakable");
RegisterComponent<UnbreakableComponent1206>(4, "minecraft:unbreakable");
RegisterComponent<CustomNameComponent>(5, "minecraft:custom_name");
RegisterComponent<ItemNameComponent>(6, "minecraft:item_name");
RegisterComponent<LoreNameComponent1206>(7, "minecraft:lore");
@ -30,7 +30,7 @@ public class StructuredComponentsRegistry121 : StructuredComponentRegistry
RegisterComponent<CreativeSlotLockComponent>(17, "minecraft:creative_slot_lock");
RegisterComponent<EnchantmentGlintOverrideComponent>(18, "minecraft:enchantment_glint_override");
RegisterComponent<IntangibleProjectileComponent>(19, "minecraft:intangible_projectile");
RegisterComponent<FoodComponentComponent>(20, "minecraft:food");
RegisterComponent<FoodComponent>(20, "minecraft:food");
RegisterComponent<FireResistantComponent>(21, "minecraft:fire_resistant");
RegisterComponent<ToolComponent>(22, "minecraft:tool");
RegisterComponent<StoredEnchantmentsComponent>(23, "minecraft:stored_enchantments");
@ -43,15 +43,15 @@ public class StructuredComponentsRegistry121 : StructuredComponentRegistry
RegisterComponent<BundleContentsComponent>(30, "minecraft:bundle_contents");
RegisterComponent<PotionContentsComponent>(31, "minecraft:potion_contents");
RegisterComponent<SuspiciousStewEffectsComponent>(32, "minecraft:suspicious_stew_effects");
RegisterComponent<WritableBlookContentComponent>(33, "minecraft:writable_book_content");
RegisterComponent<WrittenBlookContentComponent>(34, "minecraft:written_book_content");
RegisterComponent<WritableBookContentComponent>(33, "minecraft:writable_book_content");
RegisterComponent<WrittenBookContentComponent>(34, "minecraft:written_book_content");
RegisterComponent<TrimComponent>(35, "minecraft:trim");
RegisterComponent<DebugStickStateComponent>(36, "minecraft:debug_stick_state");
RegisterComponent<EntityDataComponent>(37, "minecraft:entity_data");
RegisterComponent<BucketEntityDataComponent>(38, "minecraft:bucket_entity_data");
RegisterComponent<BlockEntityDataComponent>(39, "minecraft:block_entity_data");
RegisterComponent<InstrumentComponent>(40, "minecraft:instrument");
RegisterComponent<OmniousBottleAmplifierComponent>(41, "minecraft:ominous_bottle_amplifier");
RegisterComponent<OminousBottleAmplifierComponent>(41, "minecraft:ominous_bottle_amplifier");
RegisterComponent<JukeBoxPlayableComponent121>(42, "minecraft:jukebox_playable");
RegisterComponent<RecipesComponent>(43, "minecraft:recipes");
RegisterComponent<LodestoneTrackerComponent>(44, "minecraft:lodestone_tracker");

View file

@ -69,16 +69,16 @@ public class StructuredComponentsRegistry12111 : StructuredComponentRegistry
RegisterComponent<PotionContentsComponent1212>(49, "minecraft:potion_contents");
RegisterComponent<PotionDurationScaleComponent>(50, "minecraft:potion_duration_scale");
RegisterComponent<SuspiciousStewEffectsComponent>(51, "minecraft:suspicious_stew_effects");
RegisterComponent<WritableBlookContentComponent>(52, "minecraft:writable_book_content");
RegisterComponent<WrittenBlookContentComponent>(53, "minecraft:written_book_content");
RegisterComponent<WritableBookContentComponent>(52, "minecraft:writable_book_content");
RegisterComponent<WrittenBookContentComponent>(53, "minecraft:written_book_content");
RegisterComponent<TrimComponent1215>(54, "minecraft:trim");
RegisterComponent<DebugStickStateComponent>(55, "minecraft:debug_stick_state");
RegisterComponent<TypedEntityDataComponent261>(56, "minecraft:entity_data");
RegisterComponent<TypedEntityDataComponent>(56, "minecraft:entity_data");
RegisterComponent<BucketEntityDataComponent>(57, "minecraft:bucket_entity_data");
RegisterComponent<BlockEntityDataComponent261>(58, "minecraft:block_entity_data");
RegisterComponent<TypedBlockEntityDataComponent>(58, "minecraft:block_entity_data");
RegisterComponent<InstrumentComponent1215>(59, "minecraft:instrument");
RegisterComponent<ProvidesTrimMaterialComponent>(60, "minecraft:provides_trim_material");
RegisterComponent<OmniousBottleAmplifierComponent>(61, "minecraft:ominous_bottle_amplifier");
RegisterComponent<OminousBottleAmplifierComponent>(61, "minecraft:ominous_bottle_amplifier");
RegisterComponent<JukeBoxPlayableComponent1215>(62, "minecraft:jukebox_playable");
RegisterComponent<ProvidesBannerPatternsComponent>(63, "minecraft:provides_banner_patterns");
RegisterComponent<RecipesComponent>(64, "minecraft:recipes");
@ -111,7 +111,7 @@ public class StructuredComponentsRegistry12111 : StructuredComponentRegistry
RegisterComponent<VarIntComponent>(90, "minecraft:rabbit/variant");
RegisterComponent<VarIntComponent>(91, "minecraft:pig/variant");
RegisterComponent<VarIntComponent>(92, "minecraft:cow/variant");
RegisterComponent<EitherHolderComponent>(93, "minecraft:chicken/variant");
RegisterComponent<RegistryEitherHolderComponent>(93, "minecraft:chicken/variant");
RegisterComponent<RegistryEitherHolderComponent>(94, "minecraft:zombie_nautilus/variant");
RegisterComponent<VarIntComponent>(95, "minecraft:frog/variant");
RegisterComponent<VarIntComponent>(96, "minecraft:horse/variant");

View file

@ -15,7 +15,7 @@ public class StructuredComponentsRegistry1212 : StructuredComponentRegistry
RegisterComponent<MaxStackSizeComponent>(1, "minecraft:max_stack_size");
RegisterComponent<MaxDamageComponent>(2, "minecraft:max_damage");
RegisterComponent<DamageComponent>(3, "minecraft:damage");
RegisterComponent<UnbrekableComponent1206>(4, "minecraft:unbreakable");
RegisterComponent<UnbreakableComponent1206>(4, "minecraft:unbreakable");
RegisterComponent<CustomNameComponent>(5, "minecraft:custom_name");
RegisterComponent<ItemNameComponent>(6, "minecraft:item_name");
RegisterComponent<ItemModelComponent>(7, "minecraft:item_model");
@ -57,15 +57,15 @@ public class StructuredComponentsRegistry1212 : StructuredComponentRegistry
RegisterComponent<BundleContentsComponent>(40, "minecraft:bundle_contents");
RegisterComponent<PotionContentsComponent1212>(41, "minecraft:potion_contents");
RegisterComponent<SuspiciousStewEffectsComponent>(42, "minecraft:suspicious_stew_effects");
RegisterComponent<WritableBlookContentComponent>(43, "minecraft:writable_book_content");
RegisterComponent<WrittenBlookContentComponent>(44, "minecraft:written_book_content");
RegisterComponent<WritableBookContentComponent>(43, "minecraft:writable_book_content");
RegisterComponent<WrittenBookContentComponent>(44, "minecraft:written_book_content");
RegisterComponent<TrimComponent>(45, "minecraft:trim");
RegisterComponent<DebugStickStateComponent>(46, "minecraft:debug_stick_state");
RegisterComponent<EntityDataComponent>(47, "minecraft:entity_data");
RegisterComponent<BucketEntityDataComponent>(48, "minecraft:bucket_entity_data");
RegisterComponent<BlockEntityDataComponent>(49, "minecraft:block_entity_data");
RegisterComponent<InstrumentComponent>(50, "minecraft:instrument");
RegisterComponent<OmniousBottleAmplifierComponent>(51, "minecraft:ominous_bottle_amplifier");
RegisterComponent<OminousBottleAmplifierComponent>(51, "minecraft:ominous_bottle_amplifier");
RegisterComponent<JukeBoxPlayableComponent121>(52, "minecraft:jukebox_playable");
RegisterComponent<RecipesComponent>(53, "minecraft:recipes");
RegisterComponent<LodestoneTrackerComponent>(54, "minecraft:lodestone_tracker");

View file

@ -6,6 +6,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_21_2;
using MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_21_5;
using MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_21_8;
using MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_21_9;
using MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_21_11;
using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Registries;
@ -15,8 +16,9 @@ public class StructuredComponentsRegistry1215 : StructuredComponentRegistry
public StructuredComponentsRegistry1215(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: base(dataTypes, itemPalette, subComponentRegistry)
{
var uses1218AttributeAndEquippableFormats = dataTypes.ProtocolVersion >= Protocol18Handler.MC_1_21_6_Version;
var uses1216AttributeAndEquippableFormats = dataTypes.ProtocolVersion >= Protocol18Handler.MC_1_21_6_Version;
var usesTypedBeesFormat = dataTypes.ProtocolVersion >= Protocol18Handler.MC_1_21_9_Version;
var usesTypedEntityDataFormat = dataTypes.ProtocolVersion >= Protocol18Handler.MC_1_21_9_Version;
RegisterComponent<CustomDataComponent>(0, "minecraft:custom_data");
RegisterComponent<MaxStackSizeComponent>(1, "minecraft:max_stack_size");
@ -31,7 +33,7 @@ public class StructuredComponentsRegistry1215 : StructuredComponentRegistry
RegisterComponent<EnchantmentsComponent1215>(10, "minecraft:enchantments");
RegisterComponent<CanPlaceOnComponent1215>(11, "minecraft:can_place_on");
RegisterComponent<CanBreakComponent1215>(12, "minecraft:can_break");
if (uses1218AttributeAndEquippableFormats)
if (uses1216AttributeAndEquippableFormats)
RegisterComponent<AttributeModifiersComponent1218>(13, "minecraft:attribute_modifiers");
else
RegisterComponent<AttributeModifiersComponent1215>(13, "minecraft:attribute_modifiers");
@ -50,7 +52,7 @@ public class StructuredComponentsRegistry1215 : StructuredComponentRegistry
RegisterComponent<ToolComponent1215>(25, "minecraft:tool");
RegisterComponent<WeaponComponent>(26, "minecraft:weapon"); // NEW
RegisterComponent<EnchantableComponent>(27, "minecraft:enchantable");
if (uses1218AttributeAndEquippableFormats)
if (uses1216AttributeAndEquippableFormats)
RegisterComponent<EquippableComponent1218>(28, "minecraft:equippable");
else
RegisterComponent<EquippableComponent1215>(28, "minecraft:equippable");
@ -70,16 +72,22 @@ public class StructuredComponentsRegistry1215 : StructuredComponentRegistry
RegisterComponent<PotionContentsComponent1212>(42, "minecraft:potion_contents");
RegisterComponent<PotionDurationScaleComponent>(43, "minecraft:potion_duration_scale"); // NEW
RegisterComponent<SuspiciousStewEffectsComponent>(44, "minecraft:suspicious_stew_effects");
RegisterComponent<WritableBlookContentComponent>(45, "minecraft:writable_book_content");
RegisterComponent<WrittenBlookContentComponent>(46, "minecraft:written_book_content");
RegisterComponent<WritableBookContentComponent>(45, "minecraft:writable_book_content");
RegisterComponent<WrittenBookContentComponent>(46, "minecraft:written_book_content");
RegisterComponent<TrimComponent1215>(47, "minecraft:trim");
RegisterComponent<DebugStickStateComponent>(48, "minecraft:debug_stick_state");
RegisterComponent<EntityDataComponent>(49, "minecraft:entity_data");
if (usesTypedEntityDataFormat)
RegisterComponent<TypedEntityDataComponent>(49, "minecraft:entity_data");
else
RegisterComponent<EntityDataComponent>(49, "minecraft:entity_data");
RegisterComponent<BucketEntityDataComponent>(50, "minecraft:bucket_entity_data");
RegisterComponent<BlockEntityDataComponent>(51, "minecraft:block_entity_data");
if (usesTypedEntityDataFormat)
RegisterComponent<TypedBlockEntityDataComponent>(51, "minecraft:block_entity_data");
else
RegisterComponent<BlockEntityDataComponent>(51, "minecraft:block_entity_data");
RegisterComponent<InstrumentComponent1215>(52, "minecraft:instrument"); // Changed to EitherHolder<Instrument> in 1.21.5
RegisterComponent<ProvidesTrimMaterialComponent>(53, "minecraft:provides_trim_material"); // NEW
RegisterComponent<OmniousBottleAmplifierComponent>(54, "minecraft:ominous_bottle_amplifier");
RegisterComponent<OminousBottleAmplifierComponent>(54, "minecraft:ominous_bottle_amplifier");
RegisterComponent<JukeBoxPlayableComponent1215>(55, "minecraft:jukebox_playable");
RegisterComponent<ProvidesBannerPatternsComponent>(56, "minecraft:provides_banner_patterns"); // NEW
RegisterComponent<RecipesComponent>(57, "minecraft:recipes");
@ -116,7 +124,7 @@ public class StructuredComponentsRegistry1215 : StructuredComponentRegistry
RegisterComponent<VarIntComponent>(83, "minecraft:rabbit/variant");
RegisterComponent<VarIntComponent>(84, "minecraft:pig/variant");
RegisterComponent<VarIntComponent>(85, "minecraft:cow/variant");
RegisterComponent<EitherHolderComponent>(86, "minecraft:chicken/variant"); // EitherHolder<ChickenVariant>
RegisterComponent<RegistryEitherHolderComponent>(86, "minecraft:chicken/variant"); // EitherHolder<ChickenVariant>
RegisterComponent<VarIntComponent>(87, "minecraft:frog/variant");
RegisterComponent<VarIntComponent>(88, "minecraft:horse/variant");
RegisterComponent<PaintingVariantHolderComponent>(89, "minecraft:painting/variant"); // Holder<PaintingVariant>

View file

@ -71,16 +71,16 @@ public class StructuredComponentsRegistry261 : StructuredComponentRegistry
RegisterComponent<PotionContentsComponent1212>(51, "minecraft:potion_contents");
RegisterComponent<PotionDurationScaleComponent>(52, "minecraft:potion_duration_scale");
RegisterComponent<SuspiciousStewEffectsComponent>(53, "minecraft:suspicious_stew_effects");
RegisterComponent<WritableBlookContentComponent>(54, "minecraft:writable_book_content");
RegisterComponent<WrittenBlookContentComponent>(55, "minecraft:written_book_content");
RegisterComponent<WritableBookContentComponent>(54, "minecraft:writable_book_content");
RegisterComponent<WrittenBookContentComponent>(55, "minecraft:written_book_content");
RegisterComponent<TrimComponent1215>(56, "minecraft:trim");
RegisterComponent<DebugStickStateComponent>(57, "minecraft:debug_stick_state");
RegisterComponent<TypedEntityDataComponent261>(58, "minecraft:entity_data");
RegisterComponent<TypedEntityDataComponent>(58, "minecraft:entity_data");
RegisterComponent<BucketEntityDataComponent>(59, "minecraft:bucket_entity_data");
RegisterComponent<BlockEntityDataComponent261>(60, "minecraft:block_entity_data");
RegisterComponent<TypedBlockEntityDataComponent>(60, "minecraft:block_entity_data");
RegisterComponent<InstrumentComponent261>(61, "minecraft:instrument");
RegisterComponent<ProvidesTrimMaterialComponent261>(62, "minecraft:provides_trim_material");
RegisterComponent<OmniousBottleAmplifierComponent>(63, "minecraft:ominous_bottle_amplifier");
RegisterComponent<OminousBottleAmplifierComponent>(63, "minecraft:ominous_bottle_amplifier");
RegisterComponent<JukeBoxPlayableComponent1215>(64, "minecraft:jukebox_playable");
RegisterComponent<HolderSetComponent261>(65, "minecraft:provides_banner_patterns");
RegisterComponent<NbtTagComponent261>(66, "minecraft:recipes");