diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/26_1/HolderSetComponent261.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/26_1/HolderSetComponent261.cs new file mode 100644 index 00000000..516117ab --- /dev/null +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/26_1/HolderSetComponent261.cs @@ -0,0 +1,42 @@ +using System.Collections.Generic; +using MinecraftClient.Inventory.ItemPalettes; +using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; + +namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._26_1; + +public class HolderSetComponent261(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) + : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) +{ + public string? TagKey { get; set; } + public List HolderIds { get; } = []; + + public override void Parse(Queue data) + { + var count = DataTypes.ReadNextVarInt(data) - 1; + if (count == -1) + { + TagKey = DataTypes.ReadNextString(data); + return; + } + + for (var i = 0; i < count; i++) + HolderIds.Add(DataTypes.ReadNextVarInt(data)); + } + + public override Queue Serialize() + { + var bytes = new List(); + if (TagKey is not null) + { + bytes.AddRange(DataTypes.GetVarInt(0)); + bytes.AddRange(DataTypes.GetString(TagKey)); + return new Queue(bytes); + } + + bytes.AddRange(DataTypes.GetVarInt(HolderIds.Count + 1)); + foreach (var holderId in HolderIds) + bytes.AddRange(DataTypes.GetVarInt(holderId)); + + return new Queue(bytes); + } +} diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/26_1/InstrumentComponent261.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/26_1/InstrumentComponent261.cs new file mode 100644 index 00000000..0f91f0b3 --- /dev/null +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/26_1/InstrumentComponent261.cs @@ -0,0 +1,38 @@ +using System.Collections.Generic; +using MinecraftClient.Inventory.ItemPalettes; +using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; + +namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._26_1; + +public class InstrumentComponent261(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) + : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) +{ + public int HolderId { get; set; } + + public override void Parse(Queue data) + { + HolderId = DataTypes.ReadNextVarInt(data); + if (HolderId != 0) + return; + + var soundHolderId = DataTypes.ReadNextVarInt(data); + if (soundHolderId == 0) + { + DataTypes.ReadNextString(data); // ResourceLocation + var hasFixedRange = DataTypes.ReadNextBool(data); + if (hasFixedRange) + DataTypes.ReadNextFloat(data); + } + + DataTypes.ReadNextFloat(data); // useDuration + DataTypes.ReadNextFloat(data); // range + DataTypes.ReadNextNbt(data); // ComponentSerialization.STREAM_CODEC + } + + public override Queue Serialize() + { + var bytes = new List(); + bytes.AddRange(DataTypes.GetVarInt(HolderId)); + return new Queue(bytes); + } +} diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/26_1/ProvidesTrimMaterialComponent261.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/26_1/ProvidesTrimMaterialComponent261.cs new file mode 100644 index 00000000..7c76b44a --- /dev/null +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/26_1/ProvidesTrimMaterialComponent261.cs @@ -0,0 +1,36 @@ +using System.Collections.Generic; +using MinecraftClient.Inventory.ItemPalettes; +using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; + +namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._26_1; + +public class ProvidesTrimMaterialComponent261(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) + : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) +{ + public int HolderId { get; set; } + + public override void Parse(Queue data) + { + HolderId = DataTypes.ReadNextVarInt(data); + if (HolderId != 0) + return; + + DataTypes.ReadNextString(data); // base asset suffix + + var overrideCount = DataTypes.ReadNextVarInt(data); + for (var i = 0; i < overrideCount; i++) + { + DataTypes.ReadNextString(data); // ResourceKey + DataTypes.ReadNextString(data); // override suffix + } + + DataTypes.ReadNextNbt(data); // ComponentSerialization.STREAM_CODEC + } + + public override Queue Serialize() + { + var bytes = new List(); + bytes.AddRange(DataTypes.GetVarInt(HolderId)); + return new Queue(bytes); + } +} diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Registries/StructuredComponentsRegistry261.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Registries/StructuredComponentsRegistry261.cs index eff20fe7..d3a3cd12 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Registries/StructuredComponentsRegistry261.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Registries/StructuredComponentsRegistry261.cs @@ -5,6 +5,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_21; 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_11; +using MinecraftClient.Protocol.Handlers.StructuredComponents.Components._26_1; using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Registries; @@ -22,7 +23,7 @@ public class StructuredComponentsRegistry261 : StructuredComponentRegistry RegisterComponent(5, "minecraft:use_effects"); RegisterComponent(6, "minecraft:custom_name"); RegisterComponent(7, "minecraft:minimum_attack_charge"); - RegisterComponent(8, "minecraft:damage_type"); + RegisterComponent(8, "minecraft:damage_type"); RegisterComponent(9, "minecraft:item_name"); RegisterComponent(10, "minecraft:item_model"); RegisterComponent(11, "minecraft:lore"); @@ -41,7 +42,7 @@ public class StructuredComponentsRegistry261 : StructuredComponentRegistry RegisterComponent(24, "minecraft:consumable"); RegisterComponent(25, "minecraft:use_remainder"); RegisterComponent(26, "minecraft:use_cooldown"); - RegisterComponent(27, "minecraft:damage_resistant"); + RegisterComponent(27, "minecraft:damage_resistant"); RegisterComponent(28, "minecraft:tool"); RegisterComponent(29, "minecraft:weapon"); RegisterComponent(30, "minecraft:attack_range"); @@ -75,11 +76,11 @@ public class StructuredComponentsRegistry261 : StructuredComponentRegistry RegisterComponent(58, "minecraft:entity_data"); RegisterComponent(59, "minecraft:bucket_entity_data"); RegisterComponent(60, "minecraft:block_entity_data"); - RegisterComponent(61, "minecraft:instrument"); - RegisterComponent(62, "minecraft:provides_trim_material"); + RegisterComponent(61, "minecraft:instrument"); + RegisterComponent(62, "minecraft:provides_trim_material"); RegisterComponent(63, "minecraft:ominous_bottle_amplifier"); RegisterComponent(64, "minecraft:jukebox_playable"); - RegisterComponent(65, "minecraft:provides_banner_patterns"); + RegisterComponent(65, "minecraft:provides_banner_patterns"); RegisterComponent(66, "minecraft:recipes"); RegisterComponent(67, "minecraft:lodestone_tracker"); RegisterComponent(68, "minecraft:firework_explosion"); @@ -112,9 +113,9 @@ public class StructuredComponentsRegistry261 : StructuredComponentRegistry RegisterComponent(94, "minecraft:pig/sound_variant"); // New in 26.1 RegisterComponent(95, "minecraft:cow/variant"); RegisterComponent(96, "minecraft:cow/sound_variant"); // New in 26.1 - RegisterComponent(97, "minecraft:chicken/variant"); + RegisterComponent(97, "minecraft:chicken/variant"); RegisterComponent(98, "minecraft:chicken/sound_variant"); // New in 26.1 - RegisterComponent(99, "minecraft:zombie_nautilus/variant"); + RegisterComponent(99, "minecraft:zombie_nautilus/variant"); RegisterComponent(100, "minecraft:frog/variant"); RegisterComponent(101, "minecraft:horse/variant"); RegisterComponent(102, "minecraft:painting/variant");