diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/BlockPredicateSubcomponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/BlockPredicateSubcomponent.cs index 9a562840..c8bf2369 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/BlockPredicateSubcomponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/BlockPredicateSubcomponent.cs @@ -50,18 +50,20 @@ public class BlockPredicateSubcomponent(DataTypes dataTypes, SubComponentRegistr data.AddRange(BlockSet.Serialize()); } - // Properites + // Properties data.AddRange(DataTypes.GetBool(HasProperities)); if (HasProperities) { if(Properties == null || Properties.Count == 0) throw new ArgumentNullException($"Can not serialize a BlockPredicate when the Properties is empty but HasProperties is true!"); + data.AddRange(DataTypes.GetVarInt(Properties.Count)); foreach (var property in Properties) data.AddRange(property.Serialize()); } // NBT + data.AddRange(DataTypes.GetBool(HasNbt)); if (HasNbt) { if(Nbt == null) diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/PropertySubComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/PropertySubComponent.cs index 0b8e41eb..6170dffa 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/PropertySubComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/PropertySubComponent.cs @@ -18,11 +18,13 @@ public class PropertySubComponent(DataTypes dataTypes, SubComponentRegistry subC IsExactMatch = dataTypes.ReadNextBool(data); if (IsExactMatch) - ExactValue = dataTypes.ReadNextString(data); - else // Ranged Match { - MinValue = dataTypes.ReadNextString(data); - MaxValue = dataTypes.ReadNextString(data); + ExactValue = dataTypes.ReadNextString(data); + } + else + { + MinValue = dataTypes.ReadNextBool(data) ? dataTypes.ReadNextString(data) : null; + MaxValue = dataTypes.ReadNextBool(data) ? dataTypes.ReadNextString(data) : null; } } @@ -45,11 +47,13 @@ public class PropertySubComponent(DataTypes dataTypes, SubComponentRegistry subC } else { - if (string.IsNullOrEmpty(MinValue?.Trim()) || string.IsNullOrEmpty(MaxValue?.Trim())) - throw new ArgumentNullException($"Can not serialize a Property sub-component if the MinValue or MaxValue is null or empty when the type is not Exact Match!"); + data.AddRange(DataTypes.GetBool(MinValue != null)); + if (MinValue != null) + data.AddRange(DataTypes.GetString(MinValue)); - data.AddRange(DataTypes.GetString(MinValue)); - data.AddRange(DataTypes.GetString(MaxValue)); + data.AddRange(DataTypes.GetBool(MaxValue != null)); + if (MaxValue != null) + data.AddRange(DataTypes.GetString(MaxValue)); } return new Queue(data);