From 0da4a718cb03fa40aeb0e61026c012b3d6a1137c Mon Sep 17 00:00:00 2001 From: Anon Date: Sat, 5 Oct 2024 13:37:52 +0200 Subject: [PATCH] Implemented all structured components, renamed them all to a better format --- .../Inventory/TrimAssetOverride.cs | 3 + ...1206.cs => AttributeModifiersComponent.cs} | 6 +- .../1_20_6/BannerPatternsComponent.cs | 68 +++++++++++ .../Components/1_20_6/BaseColorComponent.cs | 23 ++++ .../Components/1_20_6/BeesComponent.cs | 46 ++++++++ .../Components/1_20_6/BlockStateComponent.cs | 32 ++++++ ...nent1206.cs => BundleContentsComponent.cs} | 2 +- ...kComponent1206.cs => CanBreakComponent.cs} | 6 +- ...omponent1206.cs => CanPlaceOnComponent.cs} | 6 +- ...1206.cs => ChargedProjectilesComponent.cs} | 2 +- .../Components/1_20_6/ContainerComponent.cs | 37 ++++++ .../1_20_6/ContainerLootComponent.cs | 23 ++++ ...nt1206.cs => CreativeSlotLockComponent.cs} | 2 +- ...omponent1206.cs => CustomDataComponent.cs} | 2 +- ...ent1206.cs => CustomModelDataComponent.cs} | 2 +- ...omponent1206.cs => CustomNameComponent.cs} | 2 +- ...ageComponent1206.cs => DamageComponent.cs} | 2 +- .../1_20_6/DebugStickStateComponent.cs | 23 ++++ ...rComponent1206.cs => DyeColorComponent.cs} | 2 +- ...s => EnchantmentGlintOverrideComponent.cs} | 2 +- ...ponent1206.cs => EnchantmentsComponent.cs} | 2 +- .../Components/1_20_6/EntityDataComponent.cs | 29 +++++ ...onent1206.cs => FireResistantComponent.cs} | 2 +- .../1_20_6/FireworkExplosionComponent.cs | 25 ++++ .../Components/1_20_6/FireworksComponent.cs | 49 ++++++++ ...onent1206.cs => FoodComponentComponent.cs} | 6 +- ...6.cs => HideAdditionalTooltipComponent.cs} | 2 +- ...mponent1206.cs => HideTooltipComponent.cs} | 2 +- .../Components/1_20_6/InstrumentComponent.cs | 67 +++++++++++ ...06.cs => IntangibleProjectileComponent.cs} | 2 +- ...eComponent1206.cs => ItemNameComponent.cs} | 2 +- .../Components/1_20_6/LockComponent.cs | 23 ++++ .../1_20_6/LodestoneTrackerComponent.cs | 43 +++++++ ...{LoreComponent1206.cs => LoreComponent.cs} | 0 ...rComponent1206.cs => MapColorComponent.cs} | 2 +- ...nent1206.cs => MapDecorationsComponent.cs} | 2 +- ...apIdComponent1206.cs => MapIdComponent.cs} | 2 +- ...t1206.cs => MapPostProcessingComponent.cs} | 2 +- ...Component1206.cs => MaxDamageComponent.cs} | 2 +- ...ponent1206.cs => MaxStackSizeComponent.cs} | 2 +- .../1_20_6/NoteBlockSoundComponent.cs | 23 ++++ .../1_20_6/OmniousBottleAmplifierComponent.cs | 23 ++++ .../1_20_6/PotDecorationsComponent.cs | 28 +++++ ...nent1206.cs => PotionContentsComponent.cs} | 6 +- .../Components/1_20_6/ProfileComponent.cs | 81 +++++++++++++ ...ityComponent1206.cs => RarityComponent.cs} | 2 +- .../Components/1_20_6/RecipesComponent.cs | 23 ++++ ...omponent1206.cs => RepairCostComponent.cs} | 2 +- ...1206.cs => StoredEnchantmentsComponent.cs} | 4 +- ...6.cs => SuspiciousStewEffectsComponent.cs} | 2 +- ...{ToolComponent1206.cs => ToolComponent.cs} | 6 +- .../Components/1_20_6/TrimComponent.cs | 107 ++++++++++++++++++ ...mponent1206.cs => UnbreakableComponent.cs} | 0 ...06.cs => WritableBlookContentComponent.cs} | 2 +- ...206.cs => WrittenBlookContentComponent.cs} | 2 +- ...ponent1206.cs => AttributeSubComponent.cs} | 2 +- ...t1206.cs => BlockPredicateSubcomponent.cs} | 10 +- ...mponent1206.cs => BlockSetSubcomponent.cs} | 2 +- ...omponent1206.cs => DetailsSubComponent.cs} | 6 +- ...Component1206.cs => EffectSubComponent.cs} | 6 +- .../1_20_6/FireworkExplosionSubComponent.cs | 63 +++++++++++ ...ent1206.cs => PotionEffectSubComponent.cs} | 6 +- ...mponent1206.cs => PropertySubComponent.cs} | 2 +- ...ubComponent1206.cs => RuleSubComponent.cs} | 6 +- .../Components/Subcomponents/SubComponents.cs | 3 +- .../StructuredComponentsRegistry1206.cs | 87 ++++++++------ .../Subcomponents/SubComponentRegistry1206.cs | 18 +-- 67 files changed, 971 insertions(+), 108 deletions(-) create mode 100644 MinecraftClient/Inventory/TrimAssetOverride.cs rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{AttributeModifiersComponent1206.cs => AttributeModifiersComponent.cs} (80%) create mode 100644 MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BannerPatternsComponent.cs create mode 100644 MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BaseColorComponent.cs create mode 100644 MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BeesComponent.cs create mode 100644 MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BlockStateComponent.cs rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{BundleContentsComponent1206.cs => BundleContentsComponent.cs} (90%) rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{CanBreakComponent1206.cs => CanBreakComponent.cs} (80%) rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{CanPlaceOnComponent1206.cs => CanPlaceOnComponent.cs} (80%) rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{ChargedProjectilesComponent1206.cs => ChargedProjectilesComponent.cs} (89%) create mode 100644 MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ContainerComponent.cs create mode 100644 MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ContainerLootComponent.cs rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{CreativeSlotLockComponent1206.cs => CreativeSlotLockComponent.cs} (69%) rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{MapDecorationsComponent1206.cs => CustomDataComponent.cs} (83%) rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{CustomModelDataComponent1206.cs => CustomModelDataComponent.cs} (74%) rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{CustomNameComponent1206.cs => CustomNameComponent.cs} (85%) rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{DamageComponent1206.cs => DamageComponent.cs} (83%) create mode 100644 MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/DebugStickStateComponent.cs rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{DyeColorComponent1206.cs => DyeColorComponent.cs} (86%) rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{EnchantmentGlintOverrideComponent1206.cs => EnchantmentGlintOverrideComponent.cs} (82%) rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{EnchantmentsComponent1206.cs => EnchantmentsComponent.cs} (91%) create mode 100644 MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/EntityDataComponent.cs rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{HideTooltipComponent1206.cs => FireResistantComponent.cs} (67%) create mode 100644 MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FireworkExplosionComponent.cs create mode 100644 MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FireworksComponent.cs rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{FoodComponentComponent1206.cs => FoodComponentComponent.cs} (85%) rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{HideAdditionalTooltipComponent1206.cs => HideAdditionalTooltipComponent.cs} (65%) rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{FireResistantComponent1206.cs => HideTooltipComponent.cs} (67%) create mode 100644 MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/InstrumentComponent.cs rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{IntangibleProjectileComponent1206.cs => IntangibleProjectileComponent.cs} (82%) rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{ItemNameComponent1206.cs => ItemNameComponent.cs} (85%) create mode 100644 MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/LockComponent.cs create mode 100644 MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/LodestoneTrackerComponent.cs rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{LoreComponent1206.cs => LoreComponent.cs} (100%) rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{MapColorComponent1206.cs => MapColorComponent.cs} (83%) rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{CustomDataComponent1206.cs => MapDecorationsComponent.cs} (91%) rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{MapIdComponent1206.cs => MapIdComponent.cs} (83%) rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{MapPostProcessingComponent1206.cs => MapPostProcessingComponent.cs} (82%) rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{MaxDamageComponent1206.cs => MaxDamageComponent.cs} (83%) rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{MaxStackSizeComponent1206.cs => MaxStackSizeComponent.cs} (83%) create mode 100644 MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/NoteBlockSoundComponent.cs create mode 100644 MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/OmniousBottleAmplifierComponent.cs create mode 100644 MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/PotDecorationsComponent.cs rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{PotionContentsComponent1206.cs => PotionContentsComponent.cs} (83%) create mode 100644 MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ProfileComponent.cs rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{RarityComponent1206.cs => RarityComponent.cs} (85%) create mode 100644 MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/RecipesComponent.cs rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{RepairCostComponent1206.cs => RepairCostComponent.cs} (83%) rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{StoredEnchantmentsComponent1206.cs => StoredEnchantmentsComponent.cs} (55%) rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{SuspiciousStewEffectsComponent1206.cs => SuspiciousStewEffectsComponent.cs} (90%) rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{ToolComponent1206.cs => ToolComponent.cs} (83%) create mode 100644 MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/TrimComponent.cs rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{UnbreakableComponent1206.cs => UnbreakableComponent.cs} (100%) rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{WritableBlookContentComponent1206.cs => WritableBlookContentComponent.cs} (90%) rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/{WrittenBlookContentComponent1206.cs => WrittenBlookContentComponent.cs} (94%) rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/{AttributeSubComponent1206.cs => AttributeSubComponent.cs} (90%) rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/{BlockPredicateSubcomponent1206.cs => BlockPredicateSubcomponent.cs} (80%) rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/{BlockSetSubcomponent1206.cs => BlockSetSubcomponent.cs} (91%) rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/{DetailsSubComponent1206.cs => DetailsSubComponent.cs} (83%) rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/{EffectSubComponent1206.cs => EffectSubComponent.cs} (65%) create mode 100644 MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/FireworkExplosionSubComponent.cs rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/{PotionEffectSubComponent1206.cs => PotionEffectSubComponent.cs} (65%) rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/{PropertySubComponent1206.cs => PropertySubComponent.cs} (93%) rename MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/{RuleSubComponent1206.cs => RuleSubComponent.cs} (80%) diff --git a/MinecraftClient/Inventory/TrimAssetOverride.cs b/MinecraftClient/Inventory/TrimAssetOverride.cs new file mode 100644 index 00000000..7047bde2 --- /dev/null +++ b/MinecraftClient/Inventory/TrimAssetOverride.cs @@ -0,0 +1,3 @@ +namespace MinecraftClient.Inventory; + +public record TrimAssetOverride(int ArmorMaterialType, string AssetName); \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/AttributeModifiersComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/AttributeModifiersComponent.cs similarity index 80% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/AttributeModifiersComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/AttributeModifiersComponent.cs index 08e0e5f2..d969d1b4 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/AttributeModifiersComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/AttributeModifiersComponent.cs @@ -7,11 +7,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class AttributeModifiersComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class AttributeModifiersComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int NumberOfAttributes { get; set; } - public List Attributes { get; set; } = new(); + public List Attributes { get; set; } = new(); public bool ShowInTooltip { get; set; } public override void Parse(Queue data) @@ -19,7 +19,7 @@ public class AttributeModifiersComponent1206(DataTypes dataTypes, ItemPalette it NumberOfAttributes = dataTypes.ReadNextVarInt(data); for (var i = 0; i < NumberOfAttributes; i++) - Attributes.Add((AttributeSubComponent1206)subComponentRegistry.ParseSubComponent(SubComponents.Attribute, data)); + Attributes.Add((AttributeSubComponent)subComponentRegistry.ParseSubComponent(SubComponents.Attribute, data)); ShowInTooltip = dataTypes.ReadNextBool(data); } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BannerPatternsComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BannerPatternsComponent.cs new file mode 100644 index 00000000..82df01c9 --- /dev/null +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BannerPatternsComponent.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using MinecraftClient.Inventory.ItemPalettes; +using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; + +namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; + +public class BannerPatternsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) + : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) +{ + public int NumberOfLayers { get; set; } + public List Layers { get; set; } = []; + + public override void Parse(Queue data) + { + NumberOfLayers = dataTypes.ReadNextVarInt(data); + + for (var i = 0; i < NumberOfLayers; i++) + { + var patternType = dataTypes.ReadNextVarInt(data); + Layers.Add(new BannerLayer + { + PatternType = patternType, + AssetId = patternType == 0 ? dataTypes.ReadNextString(data) : null, + TranslationKey = patternType == 0 ? dataTypes.ReadNextString(data) : null, + DyeColor = dataTypes.ReadNextVarInt(data) + }); + } + } + + public override Queue Serialize() + { + var data = new List(); + data.AddRange(DataTypes.GetVarInt(NumberOfLayers)); + + if (NumberOfLayers > 0) + { + if (NumberOfLayers != Layers.Count) + throw new Exception("Can't serialize BannerPatternsComponent because NumberOfLayers and Layers.Count differ!"); + + foreach (var bannerLayer in Layers) + { + data.AddRange(DataTypes.GetVarInt(bannerLayer.PatternType)); + + if (bannerLayer.PatternType == 0) + { + if(string.IsNullOrEmpty(bannerLayer.AssetId) || string.IsNullOrEmpty(bannerLayer.TranslationKey)) + throw new Exception("Can't serialize BannerPatternsComponent because AssetId or TranslationKey is null/empty!"); + + data.AddRange(DataTypes.GetString(bannerLayer.AssetId)); + data.AddRange(DataTypes.GetString(bannerLayer.TranslationKey)); + } + + data.AddRange(DataTypes.GetVarInt(bannerLayer.DyeColor)); + } + } + + return new Queue(data); + } +} + +public class BannerLayer +{ + public int PatternType { get; set; } + public string? AssetId { get; set; } = null!; + public string? TranslationKey { get; set; } = null!; + public int DyeColor { get; set; } +} \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BaseColorComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BaseColorComponent.cs new file mode 100644 index 00000000..0f2d9620 --- /dev/null +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BaseColorComponent.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using MinecraftClient.Inventory.ItemPalettes; +using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; + +namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; + +public class BaseColorComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) + : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) +{ + public int DyeColor { get; set; } + + public override void Parse(Queue data) + { + DyeColor = dataTypes.ReadNextVarInt(data); + } + + public override Queue Serialize() + { + var data = new List(); + data.AddRange(DataTypes.GetVarInt(DyeColor)); + return new Queue(data); + } +} \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BeesComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BeesComponent.cs new file mode 100644 index 00000000..f0630fe1 --- /dev/null +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BeesComponent.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using MinecraftClient.Inventory; +using MinecraftClient.Inventory.ItemPalettes; +using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; + +namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; + +public class BeesComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) + : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) +{ + public int NumberOfBees { get; set; } + public List Bees { get; set; } = []; + + public override void Parse(Queue data) + { + NumberOfBees = dataTypes.ReadNextVarInt(data); + for (var i = 0; i < NumberOfBees; i++) + { + Bees.Add(new Bee(dataTypes.ReadNextNbt(data), dataTypes.ReadNextVarInt(data), dataTypes.ReadNextVarInt(data))); + } + } + + public override Queue Serialize() + { + var data = new List(); + data.AddRange(DataTypes.GetVarInt(NumberOfBees)); + + if (NumberOfBees > 0) + { + if (NumberOfBees != Bees.Count) + throw new Exception("Can't serialize the BeeComponent because NumberOfBees and Bees.Count differ!"); + + foreach (var bee in Bees) + { + data.AddRange(DataTypes.GetNbt(bee.EntityDataNbt)); + data.AddRange(DataTypes.GetVarInt(bee.TicksInHive)); + data.AddRange(DataTypes.GetVarInt(bee.MinTicksInHive)); + } + } + + return new Queue(data); + } +} + +public record Bee(Dictionary? EntityDataNbt, int TicksInHive, int MinTicksInHive); \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BlockStateComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BlockStateComponent.cs new file mode 100644 index 00000000..be3950fe --- /dev/null +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BlockStateComponent.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; +using MinecraftClient.Inventory.ItemPalettes; +using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; + +namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; + +public class BlockStateComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) + : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) +{ + public int NumberOfProperties { get; set; } + public List<(string, string)> Properties { get; set; } = []; + + public override void Parse(Queue data) + { + NumberOfProperties = dataTypes.ReadNextVarInt(data); + for(var i = 0; i < NumberOfProperties; i++) + Properties.Add((dataTypes.ReadNextString(data), dataTypes.ReadNextString(data))); + } + + public override Queue Serialize() + { + var data = new List(); + data.AddRange(DataTypes.GetVarInt(NumberOfProperties)); + for (var i = 0; i < NumberOfProperties; i++) + { + data.AddRange(DataTypes.GetString(Properties[i].Item1)); + data.AddRange(DataTypes.GetString(Properties[i].Item2)); + } + + return new Queue(data); + } +} \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BundleContentsComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BundleContentsComponent.cs similarity index 90% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BundleContentsComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BundleContentsComponent.cs index 075c7a7b..063d1d20 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BundleContentsComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BundleContentsComponent.cs @@ -7,7 +7,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class BundleContentsComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class BundleContentsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int NumberOfItems { get; set; } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CanBreakComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CanBreakComponent.cs similarity index 80% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CanBreakComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CanBreakComponent.cs index cf0433d8..06ca3a7b 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CanBreakComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CanBreakComponent.cs @@ -7,11 +7,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class CanBreakComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class CanBreakComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int NumberOfPredicates { get; set; } - public List BlockPredicates { get; set; } = new(); + public List BlockPredicates { get; set; } = new(); public bool ShowInTooltip { get; set; } public override void Parse(Queue data) @@ -19,7 +19,7 @@ public class CanBreakComponent1206(DataTypes dataTypes, ItemPalette itemPalette, NumberOfPredicates = dataTypes.ReadNextVarInt(data); for (var i = 0; i < NumberOfPredicates; i++) - BlockPredicates.Add((BlockPredicateSubcomponent1206)subComponentRegistry.ParseSubComponent(SubComponents.BlockPredicate, data)); + BlockPredicates.Add((BlockPredicateSubcomponent)subComponentRegistry.ParseSubComponent(SubComponents.BlockPredicate, data)); ShowInTooltip = dataTypes.ReadNextBool(data); } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CanPlaceOnComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CanPlaceOnComponent.cs similarity index 80% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CanPlaceOnComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CanPlaceOnComponent.cs index ef2057c9..581c089f 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CanPlaceOnComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CanPlaceOnComponent.cs @@ -7,11 +7,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class CanPlaceOnComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class CanPlaceOnComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int NumberOfPredicates { get; set; } - public List BlockPredicates { get; set; } = new(); + public List BlockPredicates { get; set; } = new(); public bool ShowInTooltip { get; set; } public override void Parse(Queue data) @@ -19,7 +19,7 @@ public class CanPlaceOnComponent1206(DataTypes dataTypes, ItemPalette itemPalett NumberOfPredicates = dataTypes.ReadNextVarInt(data); for (var i = 0; i < NumberOfPredicates; i++) - BlockPredicates.Add((BlockPredicateSubcomponent1206)subComponentRegistry.ParseSubComponent(SubComponents.BlockPredicate, data)); + BlockPredicates.Add((BlockPredicateSubcomponent)subComponentRegistry.ParseSubComponent(SubComponents.BlockPredicate, data)); ShowInTooltip = dataTypes.ReadNextBool(data); } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ChargedProjectilesComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ChargedProjectilesComponent.cs similarity index 89% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ChargedProjectilesComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ChargedProjectilesComponent.cs index 842af032..ef0875ef 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ChargedProjectilesComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ChargedProjectilesComponent.cs @@ -7,7 +7,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class ChargedProjectilesComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class ChargedProjectilesComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int NumberOfItems { get; set; } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ContainerComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ContainerComponent.cs new file mode 100644 index 00000000..2b050aff --- /dev/null +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ContainerComponent.cs @@ -0,0 +1,37 @@ +using System.Collections.Generic; +using MinecraftClient.Inventory; +using MinecraftClient.Inventory.ItemPalettes; +using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; + +namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; + +public class ContainerComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) + : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) +{ + public int NumberOfItems { get; set; } + public List Items { get; set; } = []; + + public override void Parse(Queue data) + { + NumberOfItems = dataTypes.ReadNextVarInt(data); + for (var i = 0; i < NumberOfItems; i++) + { + var item = dataTypes.ReadNextItemSlot(data, ItemPalette); + + if (item is null) + continue; + + Items.Add(item); + } + } + + public override Queue Serialize() + { + var data = new List(); + data.AddRange(DataTypes.GetVarInt(NumberOfItems)); + for (var i = 0; i < NumberOfItems; i++) + data.AddRange(DataTypes.GetItemSlot(Items[i], itemPalette)); + + return new Queue(data); + } +} \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ContainerLootComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ContainerLootComponent.cs new file mode 100644 index 00000000..d0f951ae --- /dev/null +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ContainerLootComponent.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using MinecraftClient.Inventory.ItemPalettes; +using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; + +namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; + +public class ContainerLootComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) + : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) +{ + public Dictionary? Nbt { get; set; } + + public override void Parse(Queue data) + { + Nbt = dataTypes.ReadNextNbt(data); + } + + public override Queue Serialize() + { + var data = new List(); + data.AddRange(DataTypes.GetNbt(Nbt)); + return new Queue(data); + } +} \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CreativeSlotLockComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CreativeSlotLockComponent.cs similarity index 69% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CreativeSlotLockComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CreativeSlotLockComponent.cs index 5d78ac1f..06989ec9 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CreativeSlotLockComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CreativeSlotLockComponent.cs @@ -4,5 +4,5 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class CreativeSlotLockComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class CreativeSlotLockComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : EmptyComponent(dataTypes, itemPalette, subComponentRegistry); \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapDecorationsComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CustomDataComponent.cs similarity index 83% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapDecorationsComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CustomDataComponent.cs index 9111f5b6..22b22b70 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapDecorationsComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CustomDataComponent.cs @@ -4,7 +4,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class MapDecorationsComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class CustomDataComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public Dictionary? Nbt { get; set; } = new(); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CustomModelDataComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CustomModelDataComponent.cs similarity index 74% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CustomModelDataComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CustomModelDataComponent.cs index a734faac..e8c05528 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CustomModelDataComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CustomModelDataComponent.cs @@ -4,7 +4,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class CustomModelDataComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) +public class CustomModelDataComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int Value { get; set; } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CustomNameComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CustomNameComponent.cs similarity index 85% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CustomNameComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CustomNameComponent.cs index 59483d4a..024b7a43 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CustomNameComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CustomNameComponent.cs @@ -5,7 +5,7 @@ using MinecraftClient.Protocol.Message; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class CustomNameComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class CustomNameComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public string CustomName { get; set; } = string.Empty; diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/DamageComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/DamageComponent.cs similarity index 83% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/DamageComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/DamageComponent.cs index 6d135ec1..9ac84800 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/DamageComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/DamageComponent.cs @@ -4,7 +4,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class DamageComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class DamageComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int Damage { get; set; } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/DebugStickStateComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/DebugStickStateComponent.cs new file mode 100644 index 00000000..7cfc68e4 --- /dev/null +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/DebugStickStateComponent.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using MinecraftClient.Inventory.ItemPalettes; +using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; + +namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; + +public class DebugStickStateComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) + : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) +{ + public Dictionary? Nbt { get; set; } + + public override void Parse(Queue data) + { + Nbt = dataTypes.ReadNextNbt(data); + } + + public override Queue Serialize() + { + var data = new List(); + data.AddRange(DataTypes.GetNbt(Nbt)); + return new Queue(data); + } +} \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/DyeColorComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/DyeColorComponent.cs similarity index 86% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/DyeColorComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/DyeColorComponent.cs index 3667cdc5..fc6de3d0 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/DyeColorComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/DyeColorComponent.cs @@ -4,7 +4,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class DyeColorComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class DyeColorComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int Color { get; set; } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/EnchantmentGlintOverrideComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/EnchantmentGlintOverrideComponent.cs similarity index 82% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/EnchantmentGlintOverrideComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/EnchantmentGlintOverrideComponent.cs index a5ac05e1..bdeb1d24 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/EnchantmentGlintOverrideComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/EnchantmentGlintOverrideComponent.cs @@ -4,7 +4,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class EnchantmentGlintOverrideComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class EnchantmentGlintOverrideComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int HasGlint { get; set; } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/EnchantmentsComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/EnchantmentsComponent.cs similarity index 91% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/EnchantmentsComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/EnchantmentsComponent.cs index 3e849220..e38b41fd 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/EnchantmentsComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/EnchantmentsComponent.cs @@ -5,7 +5,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class EnchantmentsComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class EnchantmentsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int NumberOfEnchantments { get; set; } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/EntityDataComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/EntityDataComponent.cs new file mode 100644 index 00000000..a4e6ef98 --- /dev/null +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/EntityDataComponent.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using MinecraftClient.Inventory.ItemPalettes; +using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; + +namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; + +public class EntityDataComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) + : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) +{ + public Dictionary? Nbt { get; set; } + + public override void Parse(Queue data) + { + Nbt = dataTypes.ReadNextNbt(data); + } + + public override Queue Serialize() + { + var data = new List(); + data.AddRange(DataTypes.GetNbt(Nbt)); + return new Queue(data); + } +} + +public class BucketEntityDataComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) + : EntityDataComponent(dataTypes, itemPalette, subComponentRegistry) {} + +public class BlockEntityDataComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) + : EntityDataComponent(dataTypes, itemPalette, subComponentRegistry) {} \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/HideTooltipComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FireResistantComponent.cs similarity index 67% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/HideTooltipComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FireResistantComponent.cs index a7b23fb8..e0eed96c 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/HideTooltipComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FireResistantComponent.cs @@ -3,5 +3,5 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class HideTooltipComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class FireResistantComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : EmptyComponent(dataTypes, itemPalette, subComponentRegistry); \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FireworkExplosionComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FireworkExplosionComponent.cs new file mode 100644 index 00000000..eeb4e876 --- /dev/null +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FireworkExplosionComponent.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using MinecraftClient.Inventory.ItemPalettes; +using MinecraftClient.Mapping; +using MinecraftClient.Protocol.Handlers.StructuredComponents.Components.Subcomponents; +using MinecraftClient.Protocol.Handlers.StructuredComponents.Components.Subcomponents._1_20_6; +using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; + +namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; + +public class FireworkExplosionComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) + : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) +{ + public FireworkExplosionSubComponent? FireworkExplosionSubComponent { get; set; } + + public override void Parse(Queue data) + { + FireworkExplosionSubComponent = (FireworkExplosionSubComponent)subComponentRegistry.ParseSubComponent(SubComponents.FireworkExplosion, data); + } + + public override Queue Serialize() + { + return FireworkExplosionSubComponent!.Serialize(); + } +} \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FireworksComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FireworksComponent.cs new file mode 100644 index 00000000..c670e95d --- /dev/null +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FireworksComponent.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using MinecraftClient.Inventory.ItemPalettes; +using MinecraftClient.Mapping; +using MinecraftClient.Protocol.Handlers.StructuredComponents.Components.Subcomponents; +using MinecraftClient.Protocol.Handlers.StructuredComponents.Components.Subcomponents._1_20_6; +using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; + +namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; + +public class FireworksComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) + : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) +{ + public int FlightDuration { get; set; } + public int NumberOfExplosions { get; set; } + + public List Explosions { get; set; } = []; + + public override void Parse(Queue data) + { + FlightDuration = dataTypes.ReadNextVarInt(data); + NumberOfExplosions = dataTypes.ReadNextVarInt(data); + + if (NumberOfExplosions > 0) + { + for(var i = 0; i < NumberOfExplosions; i++) + Explosions.Add( + (FireworkExplosionSubComponent)subComponentRegistry.ParseSubComponent(SubComponents.FireworkExplosion, + data)); + } + } + + public override Queue Serialize() + { + var data = new List(); + data.AddRange(DataTypes.GetVarInt(FlightDuration)); + data.AddRange(DataTypes.GetVarInt(NumberOfExplosions)); + if (NumberOfExplosions > 0) + { + if (NumberOfExplosions != Explosions.Count) + throw new Exception("Can't serialize FireworksComponent because NumberOfExplosions and the lenght of Explosions differ!"); + + foreach(var explosion in Explosions) + data.AddRange(explosion.Serialize().ToList()); + } + return new Queue(data); + } +} \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FoodComponentComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FoodComponentComponent.cs similarity index 85% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FoodComponentComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FoodComponentComponent.cs index ad9b6fd9..f848750d 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FoodComponentComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FoodComponentComponent.cs @@ -7,7 +7,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class FoodComponentComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class FoodComponentComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int Nutrition { get; set; } @@ -15,7 +15,7 @@ public class FoodComponentComponent1206(DataTypes dataTypes, ItemPalette itemPal public bool CanAlwaysEat { get; set; } public float SecondsToEat { get; set; } public int NumberOfEffects { get; set; } - public List Effects { get; set; } = new(); + public List Effects { get; set; } = new(); public override void Parse(Queue data) { @@ -26,7 +26,7 @@ public class FoodComponentComponent1206(DataTypes dataTypes, ItemPalette itemPal NumberOfEffects = dataTypes.ReadNextVarInt(data); for(var i = 0; i < NumberOfEffects; i++) - Effects.Add((EffectSubComponent1206)subComponentRegistry.ParseSubComponent(SubComponents.Effect, data)); + Effects.Add((EffectSubComponent)subComponentRegistry.ParseSubComponent(SubComponents.Effect, data)); } public override Queue Serialize() diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/HideAdditionalTooltipComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/HideAdditionalTooltipComponent.cs similarity index 65% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/HideAdditionalTooltipComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/HideAdditionalTooltipComponent.cs index d3b9df83..13a7197a 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/HideAdditionalTooltipComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/HideAdditionalTooltipComponent.cs @@ -3,5 +3,5 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class HideAdditionalTooltipComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class HideAdditionalTooltipComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : EmptyComponent(dataTypes, itemPalette, subComponentRegistry); \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FireResistantComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/HideTooltipComponent.cs similarity index 67% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FireResistantComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/HideTooltipComponent.cs index 89d4a6af..b1d0783e 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FireResistantComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/HideTooltipComponent.cs @@ -3,5 +3,5 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class FireResistantComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class HideTooltipComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : EmptyComponent(dataTypes, itemPalette, subComponentRegistry); \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/InstrumentComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/InstrumentComponent.cs new file mode 100644 index 00000000..87bb17be --- /dev/null +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/InstrumentComponent.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using MinecraftClient.Inventory.ItemPalettes; +using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; + +namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; + +public class InstrumentComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) + : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) +{ + public int InstrumentType { get; set; } + public int SoundEventType { get; set; } + public string? SoundName { get; set; } = null!; + public bool HasFixedRange { get; set; } + public float FixedRange { get; set; } + public float UseDuration { get; set; } + public float Range { get; set; } + + public override void Parse(Queue data) + { + InstrumentType = dataTypes.ReadNextVarInt(data); + + if (InstrumentType == 0) + { + SoundEventType = dataTypes.ReadNextVarInt(data); + SoundName = dataTypes.ReadNextString(data); + + if (SoundEventType == 0) + { + HasFixedRange = dataTypes.ReadNextBool(data); + FixedRange = dataTypes.ReadNextFloat(data); + } + + UseDuration = dataTypes.ReadNextFloat(data); + Range = dataTypes.ReadNextFloat(data); + } + + // TODO: Check, if we need to load in defaults from a registry + } + + public override Queue Serialize() + { + var data = new List(); + data.AddRange(DataTypes.GetVarInt(InstrumentType)); + + if (InstrumentType == 0) + { + data.AddRange(DataTypes.GetVarInt(SoundEventType)); + + if (string.IsNullOrEmpty(SoundName)) + throw new NullReferenceException("Can't serialize InstrumentComponent because SoundName is empty!"); + + data.AddRange(DataTypes.GetString(SoundName)); + if (SoundEventType == 0) + { + data.AddRange(DataTypes.GetBool(HasFixedRange)); + data.AddRange(DataTypes.GetFloat(FixedRange)); + } + + data.AddRange(DataTypes.GetFloat(UseDuration)); + data.AddRange(DataTypes.GetFloat(Range)); + } + + // TODO: Check, if we need to load in defaults from a registry if InstrumentType != 0 and send them + return new Queue(data); + } +} \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/IntangibleProjectileComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/IntangibleProjectileComponent.cs similarity index 82% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/IntangibleProjectileComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/IntangibleProjectileComponent.cs index e9f94396..cba25e6e 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/IntangibleProjectileComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/IntangibleProjectileComponent.cs @@ -4,7 +4,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class IntangibleProjectileComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class IntangibleProjectileComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public Dictionary? Nbt { get; set; } = new(); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ItemNameComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ItemNameComponent.cs similarity index 85% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ItemNameComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ItemNameComponent.cs index 3cb8af44..a7c8bda3 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ItemNameComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ItemNameComponent.cs @@ -5,7 +5,7 @@ using MinecraftClient.Protocol.Message; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class ItemNameComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class ItemNameComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public string ItemName { get; set; } = string.Empty; diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/LockComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/LockComponent.cs new file mode 100644 index 00000000..c9ebe0b0 --- /dev/null +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/LockComponent.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using MinecraftClient.Inventory.ItemPalettes; +using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; + +namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; + +public class LockComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) + : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) +{ + public Dictionary? Nbt { get; set; } + + public override void Parse(Queue data) + { + Nbt = dataTypes.ReadNextNbt(data); + } + + public override Queue Serialize() + { + var data = new List(); + data.AddRange(DataTypes.GetNbt(Nbt)); + return new Queue(data); + } +} \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/LodestoneTrackerComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/LodestoneTrackerComponent.cs new file mode 100644 index 00000000..702b8763 --- /dev/null +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/LodestoneTrackerComponent.cs @@ -0,0 +1,43 @@ +using System.Collections.Generic; +using MinecraftClient.Inventory.ItemPalettes; +using MinecraftClient.Mapping; +using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; + +namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; + +public class LodestoneTrackerComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) + : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) +{ + public bool HasGlobalPosition { get; set; } + public string Dimension { get; set; } = null!; + public Location Position { get; set; } + public bool Tracked { get; set; } + + public override void Parse(Queue data) + { + HasGlobalPosition = dataTypes.ReadNextBool(data); + + if (HasGlobalPosition) + { + Dimension = dataTypes.ReadNextString(data); + Position = dataTypes.ReadNextLocation(data); + } + + Tracked = dataTypes.ReadNextBool(data); + } + + public override Queue Serialize() + { + var data = new List(); + data.AddRange(DataTypes.GetBool(HasGlobalPosition)); + + if (HasGlobalPosition) + { + data.AddRange(DataTypes.GetString(Dimension)); + data.AddRange(DataTypes.GetLocation(Position)); + } + + data.AddRange(DataTypes.GetBool(Tracked)); + return new Queue(data); + } +} \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/LoreComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/LoreComponent.cs similarity index 100% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/LoreComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/LoreComponent.cs diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapColorComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapColorComponent.cs similarity index 83% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapColorComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapColorComponent.cs index 17f84f6b..7c7e9186 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapColorComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapColorComponent.cs @@ -4,7 +4,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class MapColorComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class MapColorComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int Id { get; set; } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CustomDataComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapDecorationsComponent.cs similarity index 91% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CustomDataComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapDecorationsComponent.cs index a359522b..c6f8f343 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CustomDataComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapDecorationsComponent.cs @@ -4,7 +4,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class CustomDataComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class MapDecorationsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public Dictionary? Nbt { get; set; } = new(); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapIdComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapIdComponent.cs similarity index 83% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapIdComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapIdComponent.cs index 283cf024..2df65305 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapIdComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapIdComponent.cs @@ -4,7 +4,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class MapIdComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class MapIdComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int Id { get; set; } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapPostProcessingComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapPostProcessingComponent.cs similarity index 82% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapPostProcessingComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapPostProcessingComponent.cs index c9abbca1..3d02a8bf 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapPostProcessingComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapPostProcessingComponent.cs @@ -4,7 +4,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class MapPostProcessingComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class MapPostProcessingComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int Type { get; set; } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MaxDamageComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MaxDamageComponent.cs similarity index 83% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MaxDamageComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MaxDamageComponent.cs index abdd483f..8edbd0c2 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MaxDamageComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MaxDamageComponent.cs @@ -4,7 +4,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class MaxDamageComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class MaxDamageComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int MaxDamage { get; set; } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MaxStackSizeComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MaxStackSizeComponent.cs similarity index 83% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MaxStackSizeComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MaxStackSizeComponent.cs index ec598351..11855c6a 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MaxStackSizeComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MaxStackSizeComponent.cs @@ -4,7 +4,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class MaxStackSizeComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class MaxStackSizeComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int MaxStackSize { get; set; } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/NoteBlockSoundComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/NoteBlockSoundComponent.cs new file mode 100644 index 00000000..d4c0a157 --- /dev/null +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/NoteBlockSoundComponent.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using MinecraftClient.Inventory.ItemPalettes; +using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; + +namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; + +public class NoteBlockSoundComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) + : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) +{ + public string Identifier { get; set; } = null!; + + public override void Parse(Queue data) + { + Identifier = dataTypes.ReadNextString(data); + } + + public override Queue Serialize() + { + var data = new List(); + data.AddRange(DataTypes.GetString(Identifier)); + return new Queue(data); + } +} \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/OmniousBottleAmplifierComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/OmniousBottleAmplifierComponent.cs new file mode 100644 index 00000000..f92a23e7 --- /dev/null +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/OmniousBottleAmplifierComponent.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using MinecraftClient.Inventory.ItemPalettes; +using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; + +namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; + +public class OmniousBottleAmplifierComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) + : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) +{ + public int Amplifier { get; set; } + + public override void Parse(Queue data) + { + Amplifier = dataTypes.ReadNextVarInt(data); + } + + public override Queue Serialize() + { + var data = new List(); + data.AddRange(DataTypes.GetVarInt(Amplifier)); + return new Queue(data); + } +} \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/PotDecorationsComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/PotDecorationsComponent.cs new file mode 100644 index 00000000..74607228 --- /dev/null +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/PotDecorationsComponent.cs @@ -0,0 +1,28 @@ +using System.Collections.Generic; +using MinecraftClient.Inventory.ItemPalettes; +using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; + +namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; + +public class PotDecorationsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) + : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) +{ + public int NumberOfItems { get; set; } + public List Items { get; set; } = []; + + public override void Parse(Queue data) + { + NumberOfItems = dataTypes.ReadNextVarInt(data); + for(var i = 0; i < NumberOfItems; i++) + Items.Add(dataTypes.ReadNextVarInt(data)); + } + + public override Queue Serialize() + { + var data = new List(); + data.AddRange(DataTypes.GetVarInt(NumberOfItems)); + for(var i = 0; i < NumberOfItems; i++) + data.AddRange(DataTypes.GetVarInt(Items[i])); + return new Queue(data); + } +} \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/PotionContentsComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/PotionContentsComponent.cs similarity index 83% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/PotionContentsComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/PotionContentsComponent.cs index cf86da9b..be00c31f 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/PotionContentsComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/PotionContentsComponent.cs @@ -7,14 +7,14 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class PotionContentsComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class PotionContentsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int PotiononId { get; set; } public bool HasCustomColor { get; set; } public int CustomColor { get; set; } public int NumberOfCustomEffects { get; set; } - public List Effects { get; set; } = new(); + public List Effects { get; set; } = new(); public override void Parse(Queue data) { @@ -24,7 +24,7 @@ public class PotionContentsComponent1206(DataTypes dataTypes, ItemPalette itemPa NumberOfCustomEffects = dataTypes.ReadNextVarInt(data); for(var i = 0; i < NumberOfCustomEffects; i++) - Effects.Add((PotionEffectSubComponent1206)subComponentRegistry.ParseSubComponent(SubComponents.PotionEffect, data)); + Effects.Add((PotionEffectSubComponent)subComponentRegistry.ParseSubComponent(SubComponents.PotionEffect, data)); } public override Queue Serialize() diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ProfileComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ProfileComponent.cs new file mode 100644 index 00000000..fc8dc441 --- /dev/null +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ProfileComponent.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using MinecraftClient.Inventory.ItemPalettes; +using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; + +namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; + +public class ProfileComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) +{ + public bool HasName { get; set; } + public string? Name { get; set; } = null!; + public bool HasUniqueId { get; set; } + public Guid Uuid { get; set; } + public int NumberOfProperties { get; set; } + public List ProfileProperties { get; set; } = []; + + public override void Parse(Queue data) + { + HasName = dataTypes.ReadNextBool(data); + + if(HasName) + Name = dataTypes.ReadNextString(data); + + HasUniqueId = dataTypes.ReadNextBool(data); + + if (HasUniqueId) + Uuid = dataTypes.ReadNextUUID(data); + + NumberOfProperties = dataTypes.ReadNextVarInt(data); + for (var i = 0; i < NumberOfProperties; i++) + { + var propertyName = dataTypes.ReadNextString(data); + var propertyValue = dataTypes.ReadNextString(data); + var hasSignature = dataTypes.ReadNextBool(data); + var signature = hasSignature ? dataTypes.ReadNextString(data) : null; + + ProfileProperties.Add(new ProfileProperty(propertyName, propertyValue, hasSignature, signature)); + } + } + + public override Queue Serialize() + { + var data = new List(); + + data.AddRange(DataTypes.GetBool(HasName)); + if (HasName) + { + if (string.IsNullOrEmpty(Name)) + throw new NullReferenceException("Can't serialize the ProfileComponent because the Name is null/empty!"); + + data.AddRange(DataTypes.GetString(Name)); + } + + if (HasUniqueId) + data.AddRange(DataTypes.GetUUID(Uuid)); + + if (NumberOfProperties > 0) + { + if(NumberOfProperties != ProfileProperties.Count) + throw new Exception("Can't serialize the ProfileComponent because the NumberOfProperties and ProfileProperties.Count differ!"); + + foreach (var profileProperty in ProfileProperties) + { + data.AddRange(DataTypes.GetString(profileProperty.Name)); + data.AddRange(DataTypes.GetString(profileProperty.Value)); + data.AddRange(DataTypes.GetBool(profileProperty.HasSignature)); + if (profileProperty.HasSignature) + { + if(string.IsNullOrEmpty(profileProperty.Signature)) + throw new NullReferenceException("Can't serialize the ProfileComponent because HasSignature is true, but the Signature is null/empty!"); + + data.AddRange(DataTypes.GetString(profileProperty.Signature)); + } + } + } + + return new Queue(data); + } +} + +public record ProfileProperty(string Name, string Value, bool HasSignature, string? Signature); \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/RarityComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/RarityComponent.cs similarity index 85% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/RarityComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/RarityComponent.cs index 100072c9..4da4cb00 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/RarityComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/RarityComponent.cs @@ -5,7 +5,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class RarityComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class RarityComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public ItemRarity Rarity { get; set; } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/RecipesComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/RecipesComponent.cs new file mode 100644 index 00000000..a1101eca --- /dev/null +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/RecipesComponent.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using MinecraftClient.Inventory.ItemPalettes; +using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; + +namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; + +public class RecipesComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) + : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) +{ + public Dictionary? Nbt { get; set; } + + public override void Parse(Queue data) + { + Nbt = dataTypes.ReadNextNbt(data); + } + + public override Queue Serialize() + { + var data = new List(); + data.AddRange(DataTypes.GetNbt(Nbt)); + return new Queue(data); + } +} \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/RepairCostComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/RepairCostComponent.cs similarity index 83% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/RepairCostComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/RepairCostComponent.cs index e4153617..ccd1e2b5 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/RepairCostComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/RepairCostComponent.cs @@ -4,7 +4,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class RepairCostComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class RepairCostComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int Cost { get; set; } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/StoredEnchantmentsComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/StoredEnchantmentsComponent.cs similarity index 55% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/StoredEnchantmentsComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/StoredEnchantmentsComponent.cs index 05f5e2d8..0ddbc431 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/StoredEnchantmentsComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/StoredEnchantmentsComponent.cs @@ -5,5 +5,5 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class StoredEnchantmentsComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) - : EnchantmentsComponent1206(dataTypes, itemPalette, subComponentRegistry); \ No newline at end of file +public class StoredEnchantmentsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) + : EnchantmentsComponent(dataTypes, itemPalette, subComponentRegistry); \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/SuspiciousStewEffectsComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/SuspiciousStewEffectsComponent.cs similarity index 90% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/SuspiciousStewEffectsComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/SuspiciousStewEffectsComponent.cs index 00e74b80..a6d81d9a 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/SuspiciousStewEffectsComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/SuspiciousStewEffectsComponent.cs @@ -7,7 +7,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class SuspiciousStewEffectsComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class SuspiciousStewEffectsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int NumberOfEffects { get; set; } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ToolComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ToolComponent.cs similarity index 83% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ToolComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ToolComponent.cs index 6a04585b..3c09e43e 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ToolComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ToolComponent.cs @@ -7,11 +7,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class ToolComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class ToolComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int NumberOfRules { get; set; } - public List Rules { get; set; } = new(); + public List Rules { get; set; } = new(); public float DefaultMiningSpeed { get; set; } public int DamagePerBlock { get; set; } @@ -20,7 +20,7 @@ public class ToolComponent1206(DataTypes dataTypes, ItemPalette itemPalette, Sub NumberOfRules = dataTypes.ReadNextVarInt(data); for (var i = 0; i < NumberOfRules; i++) - Rules.Add((RuleSubComponent1206)subComponentRegistry.ParseSubComponent(SubComponents.Rule, data)); + Rules.Add((RuleSubComponent)subComponentRegistry.ParseSubComponent(SubComponents.Rule, data)); DefaultMiningSpeed = dataTypes.ReadNextFloat(data); DamagePerBlock = dataTypes.ReadNextVarInt(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/TrimComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/TrimComponent.cs new file mode 100644 index 00000000..25d30c4a --- /dev/null +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/TrimComponent.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; +using MinecraftClient.Inventory; +using MinecraftClient.Inventory.ItemPalettes; +using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; +using MinecraftClient.Protocol.Message; + +namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; + +public class TrimComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) +{ + public int TrimMaterialType { get; set; } + public string AssetName { get; set; } = null!; + public int Ingredient { get; set; } + public float ItemModelIndex { get; set; } + public int NumberOfOverrides { get; set; } + public List? Overrides { get; set; } + public string Description { get; set; } = null!; + public int TrimPatternType { get; set; } + public string TrimPatternTypeAssetName { get; set; } = null!; + public int TemplateItem { get; set; } + public string TrimPatternTypeDescription { get; set; } = null!; + public bool Decal { get; set; } + public bool ShowInTooltip { get; set; } + + public override void Parse(Queue data) + { + TrimMaterialType = dataTypes.ReadNextVarInt(data); + + if (TrimMaterialType == 0) + { + AssetName = dataTypes.ReadNextString(data); + Ingredient = dataTypes.ReadNextVarInt(data); + ItemModelIndex = dataTypes.ReadNextFloat(data); + NumberOfOverrides = dataTypes.ReadNextVarInt(data); + + if (NumberOfOverrides > 0) + { + Overrides = []; + + for (var i = 0; i < NumberOfOverrides; i++) + Overrides.Add(new TrimAssetOverride(dataTypes.ReadNextVarInt(data), + dataTypes.ReadNextString(data))); + } + + Description = ChatParser.ParseText(dataTypes.ReadNextString(data)); + } + + TrimPatternType = dataTypes.ReadNextVarInt(data); + + if (TrimPatternType == 0) + { + TrimPatternTypeAssetName = dataTypes.ReadNextString(data); + TemplateItem = dataTypes.ReadNextVarInt(data); + TrimPatternTypeDescription = dataTypes.ReadNextString(data); + Decal = dataTypes.ReadNextBool(data); + } + + ShowInTooltip = dataTypes.ReadNextBool(data); + } + + public override Queue Serialize() + { + var data = new List(); + + data.AddRange(DataTypes.GetVarInt(TrimMaterialType)); + + if (TrimMaterialType == 0) + { + if (string.IsNullOrEmpty(AssetName) || string.IsNullOrEmpty(Description)) + throw new NullReferenceException("Can't serialize the TrimComponent because the Asset Name or Description are null!"); + + data.AddRange(DataTypes.GetString(AssetName)); + data.AddRange(DataTypes.GetVarInt(Ingredient)); + data.AddRange(DataTypes.GetFloat(ItemModelIndex)); + data.AddRange(DataTypes.GetVarInt(NumberOfOverrides)); + if (NumberOfOverrides > 0) + { + if(NumberOfOverrides != Overrides?.Count) + throw new NullReferenceException("Can't serialize the TrimComponent because value of NumberOfOverrides and the size of Overrides don't match!"); + + foreach (var (armorMaterialType, assetName) in Overrides) + { + data.AddRange(DataTypes.GetVarInt(armorMaterialType)); + data.AddRange(DataTypes.GetString(assetName)); + } + } + data.AddRange(DataTypes.GetString(Description)); + + data.AddRange(DataTypes.GetVarInt(TrimPatternType)); + if (TrimPatternType == 0) + { + if (string.IsNullOrEmpty(TrimPatternTypeAssetName) || string.IsNullOrEmpty(TrimPatternTypeDescription)) + throw new NullReferenceException("Can't serialize the TrimComponent because the TrimPatternTypeAssetName or TrimPatternTypeDescription are null!"); + + data.AddRange(DataTypes.GetString(TrimPatternTypeAssetName)); + data.AddRange(DataTypes.GetVarInt(TemplateItem)); + data.AddRange(DataTypes.GetString(TrimPatternTypeDescription)); + data.AddRange(DataTypes.GetBool(Decal)); + } + + data.AddRange(DataTypes.GetBool(ShowInTooltip)); + } + + return new Queue(data); + } +} \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/UnbreakableComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/UnbreakableComponent.cs similarity index 100% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/UnbreakableComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/UnbreakableComponent.cs diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/WritableBlookContentComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/WritableBlookContentComponent.cs similarity index 90% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/WritableBlookContentComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/WritableBlookContentComponent.cs index 4e32ef37..9c782d55 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/WritableBlookContentComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/WritableBlookContentComponent.cs @@ -6,7 +6,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class WritableBlookContentComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) +public class WritableBlookContentComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int NumberOfPages { get; set; } public List Pages { get; set; } = []; diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/WrittenBlookContentComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/WrittenBlookContentComponent.cs similarity index 94% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/WrittenBlookContentComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/WrittenBlookContentComponent.cs index 8bc2f060..bf315b3d 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/WrittenBlookContentComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/WrittenBlookContentComponent.cs @@ -7,7 +7,7 @@ using MinecraftClient.Protocol.Message; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class WrittenBlookContentComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) +public class WrittenBlookContentComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public string RawTitle { get; set; } = null!; public bool HasFilteredTitle { get; set; } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/AttributeSubComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/AttributeSubComponent.cs similarity index 90% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/AttributeSubComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/AttributeSubComponent.cs index c7d63dd3..a29374e1 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/AttributeSubComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/AttributeSubComponent.cs @@ -4,7 +4,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components.Subcomponents._1_20_6; -public class AttributeSubComponent1206(DataTypes dataTypes, SubComponentRegistry subComponentRegistry) : SubComponent(dataTypes, subComponentRegistry) +public class AttributeSubComponent(DataTypes dataTypes, SubComponentRegistry subComponentRegistry) : SubComponent(dataTypes, subComponentRegistry) { public int TypeId { get; set; } public Guid Uuid { get; set; } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/BlockPredicateSubcomponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/BlockPredicateSubcomponent.cs similarity index 80% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/BlockPredicateSubcomponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/BlockPredicateSubcomponent.cs index fae29a94..9a562840 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/BlockPredicateSubcomponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/BlockPredicateSubcomponent.cs @@ -4,12 +4,12 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components.Subcomponents._1_20_6; -public class BlockPredicateSubcomponent1206(DataTypes dataTypes, SubComponentRegistry subComponentRegistry) : SubComponent(dataTypes, subComponentRegistry) +public class BlockPredicateSubcomponent(DataTypes dataTypes, SubComponentRegistry subComponentRegistry) : SubComponent(dataTypes, subComponentRegistry) { public bool HasBlocks { get; set; } - public BlockSetSubcomponent1206? BlockSet { get; set; } + public BlockSetSubcomponent? BlockSet { get; set; } public bool HasProperities { get; set; } - public List? Properties { get; set; } + public List? Properties { get; set; } public bool HasNbt { get; set; } public Dictionary? Nbt { get; set; } @@ -18,7 +18,7 @@ public class BlockPredicateSubcomponent1206(DataTypes dataTypes, SubComponentReg HasBlocks = dataTypes.ReadNextBool(data); if (HasBlocks) - BlockSet = (BlockSetSubcomponent1206)subComponentRegistry.ParseSubComponent(SubComponents.BlockSet, data); + BlockSet = (BlockSetSubcomponent)subComponentRegistry.ParseSubComponent(SubComponents.BlockSet, data); HasProperities = dataTypes.ReadNextBool(data); @@ -27,7 +27,7 @@ public class BlockPredicateSubcomponent1206(DataTypes dataTypes, SubComponentReg Properties = new(); var numberOfProperties = dataTypes.ReadNextVarInt(data); for (var i = 0; i < numberOfProperties; i++) - Properties.Add((PropertySubComponent1206)subComponentRegistry.ParseSubComponent(SubComponents.Property, data)); + Properties.Add((PropertySubComponent)subComponentRegistry.ParseSubComponent(SubComponents.Property, data)); } HasNbt = dataTypes.ReadNextBool(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/BlockSetSubcomponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/BlockSetSubcomponent.cs similarity index 91% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/BlockSetSubcomponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/BlockSetSubcomponent.cs index a35eeec1..dbc7c40a 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/BlockSetSubcomponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/BlockSetSubcomponent.cs @@ -4,7 +4,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components.Subcomponents._1_20_6; -public class BlockSetSubcomponent1206(DataTypes dataTypes, SubComponentRegistry subComponentRegistry) : SubComponent(dataTypes, subComponentRegistry) +public class BlockSetSubcomponent(DataTypes dataTypes, SubComponentRegistry subComponentRegistry) : SubComponent(dataTypes, subComponentRegistry) { public int Type { get; set; } public string? TagName { get; set; } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/DetailsSubComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/DetailsSubComponent.cs similarity index 83% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/DetailsSubComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/DetailsSubComponent.cs index 289d432c..7394e13d 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/DetailsSubComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/DetailsSubComponent.cs @@ -4,7 +4,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components.Subcomponents._1_20_6; -public class DetailsSubComponent1206(DataTypes dataTypes, SubComponentRegistry subComponentRegistry) : SubComponent(dataTypes, subComponentRegistry) +public class DetailsSubComponent(DataTypes dataTypes, SubComponentRegistry subComponentRegistry) : SubComponent(dataTypes, subComponentRegistry) { public int Amplifier { get; set; } public int Duration { get; set; } @@ -12,7 +12,7 @@ public class DetailsSubComponent1206(DataTypes dataTypes, SubComponentRegistry s public bool ShowParticles { get; set; } public bool ShowIcon { get; set; } public bool HasHiddenEffects { get; set; } - public DetailsSubComponent1206? Detail { get; set; } + public DetailsSubComponent? Detail { get; set; } protected override void Parse(Queue data) { @@ -24,7 +24,7 @@ public class DetailsSubComponent1206(DataTypes dataTypes, SubComponentRegistry s HasHiddenEffects = dataTypes.ReadNextBool(data); if(HasHiddenEffects) - Detail = (DetailsSubComponent1206)subComponentRegistry.ParseSubComponent(SubComponents.Details, data); + Detail = (DetailsSubComponent)subComponentRegistry.ParseSubComponent(SubComponents.Details, data); } public override Queue Serialize() diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/EffectSubComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/EffectSubComponent.cs similarity index 65% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/EffectSubComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/EffectSubComponent.cs index b7cd1117..a676cfca 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/EffectSubComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/EffectSubComponent.cs @@ -4,14 +4,14 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components.Subcomponents._1_20_6; -public class EffectSubComponent1206(DataTypes dataTypes, SubComponentRegistry subComponentRegistry) : SubComponent(dataTypes, subComponentRegistry) +public class EffectSubComponent(DataTypes dataTypes, SubComponentRegistry subComponentRegistry) : SubComponent(dataTypes, subComponentRegistry) { - public PotionEffectSubComponent1206 TypeId { get; set; } + public PotionEffectSubComponent TypeId { get; set; } public float Probability { get; set; } protected override void Parse(Queue data) { - TypeId = (PotionEffectSubComponent1206)subComponentRegistry.ParseSubComponent(SubComponents.PotionEffect, data); + TypeId = (PotionEffectSubComponent)subComponentRegistry.ParseSubComponent(SubComponents.PotionEffect, data); Probability = dataTypes.ReadNextFloat(data); } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/FireworkExplosionSubComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/FireworkExplosionSubComponent.cs new file mode 100644 index 00000000..e4c67cc7 --- /dev/null +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/FireworkExplosionSubComponent.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; + +namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components.Subcomponents._1_20_6; + +public class FireworkExplosionSubComponent(DataTypes dataTypes, SubComponentRegistry subComponentRegistry) : SubComponent(dataTypes, subComponentRegistry) +{ + public int Shape { get; set; } + public int NumberOfColors { get; set; } + public List Colors { get; set; } = []; + public int NumberOfFadeColors { get; set; } + public List FadeColors { get; set; } = []; + public bool HasTrail { get; set; } + public bool HasTwinkle { get; set; } + + protected override void Parse(Queue data) + { + Shape = dataTypes.ReadNextVarInt(data); + NumberOfColors = dataTypes.ReadNextVarInt(data); + + for (var i = 0; i < NumberOfColors; i++) + Colors.Add(dataTypes.ReadNextInt(data)); + + NumberOfFadeColors = dataTypes.ReadNextVarInt(data); + + for (var i = 0; i < NumberOfFadeColors; i++) + FadeColors.Add(dataTypes.ReadNextInt(data)); + + HasTrail = dataTypes.ReadNextBool(data); + HasTwinkle = dataTypes.ReadNextBool(data); + } + + public override Queue Serialize() + { + var data = new List(); + data.AddRange(DataTypes.GetVarInt(Shape)); + + data.AddRange(DataTypes.GetVarInt(NumberOfColors)); + if (NumberOfColors > 0) + { + if (NumberOfColors != Colors.Count) + throw new Exception("Can't serialize FireworkExplosionComponent because NumberOfColors and the length of Colors list differ!"); + + foreach (var color in Colors) + data.AddRange(DataTypes.GetInt(color)); + } + + data.AddRange(DataTypes.GetVarInt(NumberOfFadeColors)); + if (NumberOfFadeColors > 0) + { + if (NumberOfFadeColors != FadeColors.Count) + throw new Exception("Can't serialize FireworkExplosionComponent because NumberOfFadeColors and the length of FadeColors list differ!"); + + foreach (var fadeColor in FadeColors) + data.AddRange(DataTypes.GetInt(fadeColor)); + } + + data.AddRange(DataTypes.GetBool(HasTrail)); + data.AddRange(DataTypes.GetBool(HasTwinkle)); + return new Queue(data); + } +} \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/PotionEffectSubComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/PotionEffectSubComponent.cs similarity index 65% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/PotionEffectSubComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/PotionEffectSubComponent.cs index c325e313..13cc55f9 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/PotionEffectSubComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/PotionEffectSubComponent.cs @@ -4,15 +4,15 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components.Subcomponents._1_20_6; -public class PotionEffectSubComponent1206(DataTypes dataTypes, SubComponentRegistry subComponentRegistry) : SubComponent(dataTypes, subComponentRegistry) +public class PotionEffectSubComponent(DataTypes dataTypes, SubComponentRegistry subComponentRegistry) : SubComponent(dataTypes, subComponentRegistry) { public int TypeId { get; set; } - public DetailsSubComponent1206 Details { get; set; } + public DetailsSubComponent Details { get; set; } protected override void Parse(Queue data) { TypeId = dataTypes.ReadNextVarInt(data); - Details = (DetailsSubComponent1206)subComponentRegistry.ParseSubComponent(SubComponents.Details, data); + Details = (DetailsSubComponent)subComponentRegistry.ParseSubComponent(SubComponents.Details, data); } public override Queue Serialize() diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/PropertySubComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/PropertySubComponent.cs similarity index 93% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/PropertySubComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/PropertySubComponent.cs index 64742c5f..0b8e41eb 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/PropertySubComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/PropertySubComponent.cs @@ -4,7 +4,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components.Subcomponents._1_20_6; -public class PropertySubComponent1206(DataTypes dataTypes, SubComponentRegistry subComponentRegistry) : SubComponent(dataTypes, subComponentRegistry) +public class PropertySubComponent(DataTypes dataTypes, SubComponentRegistry subComponentRegistry) : SubComponent(dataTypes, subComponentRegistry) { public string? Name { get; set; } public bool IsExactMatch { get; set; } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/RuleSubComponent1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/RuleSubComponent.cs similarity index 80% rename from MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/RuleSubComponent1206.cs rename to MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/RuleSubComponent.cs index e5830f4d..ca8807b5 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/RuleSubComponent1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/RuleSubComponent.cs @@ -4,9 +4,9 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components.Subcomponents._1_20_6; -public class RuleSubComponent1206(DataTypes dataTypes, SubComponentRegistry subComponentRegistry) : SubComponent(dataTypes, subComponentRegistry) +public class RuleSubComponent(DataTypes dataTypes, SubComponentRegistry subComponentRegistry) : SubComponent(dataTypes, subComponentRegistry) { - public BlockSetSubcomponent1206 Blocks { get; set; } + public BlockSetSubcomponent Blocks { get; set; } public bool HasSpeed { get; set; } public float Speed { get; set; } public bool HasCorrectDropForBlocks { get; set; } @@ -14,7 +14,7 @@ public class RuleSubComponent1206(DataTypes dataTypes, SubComponentRegistry subC protected override void Parse(Queue data) { - Blocks = (BlockSetSubcomponent1206)subComponentRegistry.ParseSubComponent(SubComponents.BlockSet, data); + Blocks = (BlockSetSubcomponent)subComponentRegistry.ParseSubComponent(SubComponents.BlockSet, data); HasSpeed = dataTypes.ReadNextBool(data); if(HasSpeed) diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/SubComponents.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/SubComponents.cs index 1c4e8d8d..5152c9cd 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/SubComponents.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/SubComponents.cs @@ -1,6 +1,6 @@ namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components.Subcomponents; -public class SubComponents +public abstract class SubComponents { public const string BlockPredicate = "BlockPredicate"; public const string BlockSet = "BlockSet"; @@ -10,4 +10,5 @@ public class SubComponents public const string PotionEffect = "PotionEffect"; public const string Details = "Details"; public const string Rule = "Rule"; + public const string FireworkExplosion = "FireworkExplosion"; } \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Registries/StructuredComponentsRegistry1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Registries/StructuredComponentsRegistry1206.cs index 12c61695..ebf75e41 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Registries/StructuredComponentsRegistry1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Registries/StructuredComponentsRegistry1206.cs @@ -9,40 +9,61 @@ public class StructuredComponentsRegistry1206 : StructuredComponentRegistry public StructuredComponentsRegistry1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : base(dataTypes, itemPalette, subComponentRegistry) { - RegisterComponent(0, "minecraft:custom_data"); - RegisterComponent(1, "minecraft:max_stack_size"); - RegisterComponent(2, "minecraft:max_damage"); - RegisterComponent(3, "minecraft:damage"); + RegisterComponent(0, "minecraft:custom_data"); + RegisterComponent(1, "minecraft:max_stack_size"); + RegisterComponent(2, "minecraft:max_damage"); + RegisterComponent(3, "minecraft:damage"); RegisterComponent(4, "minecraft:unbreakable"); - RegisterComponent(5, "minecraft:custom_name"); - RegisterComponent(6, "minecraft:item_name"); + RegisterComponent(5, "minecraft:custom_name"); + RegisterComponent(6, "minecraft:item_name"); RegisterComponent(7, "minecraft:lore"); - RegisterComponent(8, "minecraft:rarity"); - RegisterComponent(9, "minecraft:enchantments"); - RegisterComponent(10, "minecraft:can_place_on"); - RegisterComponent(11, "minecraft:can_break"); - RegisterComponent(12, "minecraft:attribute_modifiers"); - RegisterComponent(13, "minecraft:custom_model_data"); - RegisterComponent(14, "minecraft:hide_additional_tooltip"); - RegisterComponent(15, "minecraft:hide_tooltip"); - RegisterComponent(16, "minecraft:repair_cost"); - RegisterComponent(17, "minecraft:creative_slot_lock"); - RegisterComponent(18, "minecraft:enchantment_glint_override"); - RegisterComponent(19, "minecraft:intangible_projectile"); - RegisterComponent(20, "minecraft:food"); - RegisterComponent(21, "minecraft:fire_resistant"); - RegisterComponent(22, "minecraft:tool"); - RegisterComponent(23, "minecraft:stored_enchantments"); - RegisterComponent(24, "minecraft:dyed_color"); - RegisterComponent(25, "minecraft:map_color"); - RegisterComponent(26, "minecraft:map_id"); - RegisterComponent(27, "minecraft:map_decorations"); - RegisterComponent(28, "minecraft:map_post_processing"); - RegisterComponent(29, "minecraft:charged_projectiles"); - RegisterComponent(30, "minecraft:bundle_contents"); - RegisterComponent(31, "minecraft:potion_contents"); - RegisterComponent(32, "minecraft:suspicious_stew_effects"); - RegisterComponent(33, "minecraft:writable_book_content"); - RegisterComponent(34, "minecraft:written_book_content"); + RegisterComponent(8, "minecraft:rarity"); + RegisterComponent(9, "minecraft:enchantments"); + RegisterComponent(10, "minecraft:can_place_on"); + RegisterComponent(11, "minecraft:can_break"); + RegisterComponent(12, "minecraft:attribute_modifiers"); + RegisterComponent(13, "minecraft:custom_model_data"); + RegisterComponent(14, "minecraft:hide_additional_tooltip"); + RegisterComponent(15, "minecraft:hide_tooltip"); + RegisterComponent(16, "minecraft:repair_cost"); + RegisterComponent(17, "minecraft:creative_slot_lock"); + RegisterComponent(18, "minecraft:enchantment_glint_override"); + RegisterComponent(19, "minecraft:intangible_projectile"); + RegisterComponent(20, "minecraft:food"); + RegisterComponent(21, "minecraft:fire_resistant"); + RegisterComponent(22, "minecraft:tool"); + RegisterComponent(23, "minecraft:stored_enchantments"); + RegisterComponent(24, "minecraft:dyed_color"); + RegisterComponent(25, "minecraft:map_color"); + RegisterComponent(26, "minecraft:map_id"); + RegisterComponent(27, "minecraft:map_decorations"); + RegisterComponent(28, "minecraft:map_post_processing"); + RegisterComponent(29, "minecraft:charged_projectiles"); + RegisterComponent(30, "minecraft:bundle_contents"); + RegisterComponent(31, "minecraft:potion_contents"); + RegisterComponent(32, "minecraft:suspicious_stew_effects"); + RegisterComponent(33, "minecraft:writable_book_content"); + RegisterComponent(34, "minecraft:written_book_content"); + RegisterComponent(35, "minecraft:trim"); + RegisterComponent(36, "minecraft:debug_stick_state"); + RegisterComponent(37, "minecraft:entity_data"); + RegisterComponent(38, "minecraft:bucket_entity_data"); + RegisterComponent(39, "minecraft:block_entity_data"); + RegisterComponent(40, "minecraft:instrument"); + RegisterComponent(41, "minecraft:ominous_bottle_amplifier"); + RegisterComponent(42, "minecraft:recipes"); + RegisterComponent(43, "minecraft:lodestone_tracker"); + RegisterComponent(44, "minecraft:firework_explosion"); + RegisterComponent(45, "minecraft:fireworks"); + RegisterComponent(46, "minecraft:profile"); + RegisterComponent(47, "minecraft:note_block_sound"); + RegisterComponent(48, "minecraft:banner_patterns"); + RegisterComponent(49, "minecraft:base_color"); + RegisterComponent(50, "minecraft:pot_decorations"); + RegisterComponent(51, "minecraft:container"); + RegisterComponent(52, "minecraft:block_state"); + RegisterComponent(53, "minecraft:bees"); + RegisterComponent(54, "minecraft:lock"); + RegisterComponent(55, "minecraft:container_loot"); } } \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Registries/Subcomponents/SubComponentRegistry1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Registries/Subcomponents/SubComponentRegistry1206.cs index 91fa60ea..2e270842 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Registries/Subcomponents/SubComponentRegistry1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Registries/Subcomponents/SubComponentRegistry1206.cs @@ -1,3 +1,4 @@ +using MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; using MinecraftClient.Protocol.Handlers.StructuredComponents.Components.Subcomponents; using MinecraftClient.Protocol.Handlers.StructuredComponents.Components.Subcomponents._1_20_6; using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; @@ -8,13 +9,14 @@ public class SubComponentRegistry1206 : SubComponentRegistry { public SubComponentRegistry1206(DataTypes dataTypes) : base(dataTypes) { - RegisterSubComponent(SubComponents.BlockPredicate); - RegisterSubComponent(SubComponents.BlockSet); - RegisterSubComponent(SubComponents.Property); - RegisterSubComponent(SubComponents.Attribute); - RegisterSubComponent(SubComponents.Effect); - RegisterSubComponent(SubComponents.PotionEffect); - RegisterSubComponent(SubComponents.Details); - RegisterSubComponent(SubComponents.Rule); + RegisterSubComponent(SubComponents.BlockPredicate); + RegisterSubComponent(SubComponents.BlockSet); + RegisterSubComponent(SubComponents.Property); + RegisterSubComponent(SubComponents.Attribute); + RegisterSubComponent(SubComponents.Effect); + RegisterSubComponent(SubComponents.PotionEffect); + RegisterSubComponent(SubComponents.Details); + RegisterSubComponent(SubComponents.Rule); + RegisterSubComponent(SubComponents.FireworkExplosion); } } \ No newline at end of file