fix: StructuredComponents batch 3 audit — EnchantmentGlintOverrideComponent type correction

Audited all 14 simple binary components (batch 3): max_stack_size,
max_damage, damage, unbreakable, rarity, custom_model_data, repair_cost,
enchantment_glint_override, ominous_bottle_amplifier, dyed_color,
map_color, map_id, map_post_processing, base_color.

Found and fixed 1 bug:
- EnchantmentGlintOverrideComponent: was reading/writing VarInt but the
  official STREAM_CODEC uses ByteBufCodecs.BOOL (single byte boolean).
  Changed property type from int to bool, Parse from ReadNextVarInt to
  ReadNextBool, and Serialize from GetVarInt to GetBool.

All other 13 components matched the official 1.20.6 STREAM_CODEC
definitions exactly.

Verified in-game: connected to 1.20.6 vanilla server, received items
with enchantment_glint_override=true/false, dyed_color, map_color,
map_id, base_color, unbreakable, rarity, custom_model_data, repair_cost,
damage, max_damage. All parsed and serialized correctly with no errors.

Made-with: Cursor
This commit is contained in:
BruceChen 2026-03-20 00:25:28 +08:00
parent 4944497f5a
commit c689343371

View file

@ -7,17 +7,17 @@ namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_2
public class EnchantmentGlintOverrideComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public int HasGlint { get; set; }
public bool HasGlint { get; set; }
public override void Parse(Queue<byte> data)
{
HasGlint = dataTypes.ReadNextVarInt(data);
HasGlint = dataTypes.ReadNextBool(data);
}
public override Queue<byte> Serialize()
{
var data = new List<byte>();
data.AddRange(DataTypes.GetVarInt(HasGlint));
data.AddRange(DataTypes.GetBool(HasGlint));
return new Queue<byte>(data);
}
}