Formatted the code and removed logs from Auto Attack

This commit is contained in:
Anon 2026-06-04 11:42:41 +02:00
parent a4ff7ae438
commit c6ca3dc13d
117 changed files with 602 additions and 585 deletions

View file

@ -6,13 +6,13 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class AttributeModifiersComponent(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<SubComponent> Attributes { get; set; } = new();
public bool ShowInTooltip { get; set; }
public override void Parse(Queue<byte> data)
{
NumberOfAttributes = DataTypes.ReadNextVarInt(data);
@ -27,13 +27,13 @@ public class AttributeModifiersComponent(DataTypes dataTypes, ItemPalette itemPa
{
var data = new List<byte>();
data.AddRange(DataTypes.GetVarInt(NumberOfAttributes));
if(Attributes.Count != NumberOfAttributes)
if (Attributes.Count != NumberOfAttributes)
throw new ArgumentNullException($"Can not serialize a AttributeModifiersComponent when the Attributes count != NumberOfAttributes!");
foreach (var attribute in Attributes)
data.AddRange(attribute.Serialize());
data.AddRange(DataTypes.GetBool(ShowInTooltip));
return new Queue<byte>(data);
}

View file

@ -5,12 +5,12 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class BannerPatternsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class BannerPatternsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public int NumberOfLayers { get; set; }
public List<BannerLayer> Layers { get; set; } = [];
public override void Parse(Queue<byte> data)
{
NumberOfLayers = DataTypes.ReadNextVarInt(data);
@ -44,17 +44,17 @@ public class BannerPatternsComponent(DataTypes dataTypes, ItemPalette itemPalett
if (bannerLayer.PatternType == 0)
{
if(string.IsNullOrEmpty(bannerLayer.AssetId) || string.IsNullOrEmpty(bannerLayer.TranslationKey))
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<byte>(data);
}
}

View file

@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class BaseColorComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class BaseColorComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public int DyeColor { get; set; }
public override void Parse(Queue<byte> data)
{
DyeColor = DataTypes.ReadNextVarInt(data);

View file

@ -6,12 +6,12 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class BeesComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class BeesComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public int NumberOfBees { get; set; }
public List<Bee> Bees { get; set; } = [];
public override void Parse(Queue<byte> data)
{
NumberOfBees = DataTypes.ReadNextVarInt(data);
@ -30,7 +30,7 @@ public class BeesComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComp
{
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));

View file

@ -4,15 +4,15 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class BlockStateComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class BlockStateComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public List<(string, string)> Properties { get; set; } = [];
public override void Parse(Queue<byte> data)
{
var count = DataTypes.ReadNextVarInt(data);
for(var i = 0; i < count; i++)
for (var i = 0; i < count; i++)
Properties.Add((DataTypes.ReadNextString(data), DataTypes.ReadNextString(data)));
}
@ -25,7 +25,7 @@ public class BlockStateComponent(DataTypes dataTypes, ItemPalette itemPalette, S
data.AddRange(DataTypes.GetString(key));
data.AddRange(DataTypes.GetString(value));
}
return new Queue<byte>(data);
}
}

View file

@ -5,7 +5,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class BundleContentsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class BundleContentsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public List<Item> Items { get; set; } = [];

View file

@ -7,13 +7,13 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class CanBreakComponent(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<BlockPredicateSubcomponent> BlockPredicates { get; set; } = new();
public bool ShowInTooltip { get; set; }
public override void Parse(Queue<byte> data)
{
NumberOfPredicates = DataTypes.ReadNextVarInt(data);
@ -28,13 +28,13 @@ public class CanBreakComponent(DataTypes dataTypes, ItemPalette itemPalette, Sub
{
var data = new List<byte>();
data.AddRange(DataTypes.GetVarInt(NumberOfPredicates));
if(NumberOfPredicates > 0 && BlockPredicates.Count == 0)
if (NumberOfPredicates > 0 && BlockPredicates.Count == 0)
throw new ArgumentNullException($"Can not serialize a CanBreakComponent when the BlockPredicates is empty but NumberOfPredicates is > 0!");
foreach (var blockPredicate in BlockPredicates)
data.AddRange(blockPredicate.Serialize());
data.AddRange(DataTypes.GetBool(ShowInTooltip));
return new Queue<byte>(data);
}

View file

@ -7,13 +7,13 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class CanPlaceOnComponent(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<BlockPredicateSubcomponent> BlockPredicates { get; set; } = new();
public bool ShowInTooltip { get; set; }
public override void Parse(Queue<byte> data)
{
NumberOfPredicates = DataTypes.ReadNextVarInt(data);
@ -28,13 +28,13 @@ public class CanPlaceOnComponent(DataTypes dataTypes, ItemPalette itemPalette, S
{
var data = new List<byte>();
data.AddRange(DataTypes.GetVarInt(NumberOfPredicates));
if(NumberOfPredicates > 0 && BlockPredicates.Count == 0)
if (NumberOfPredicates > 0 && BlockPredicates.Count == 0)
throw new ArgumentNullException($"Can not serialize a CanPlaceOnComponent when the BlockPredicates is empty but NumberOfPredicates is > 0!");
foreach (var blockPredicate in BlockPredicates)
data.AddRange(blockPredicate.Serialize());
data.AddRange(DataTypes.GetBool(ShowInTooltip));
return new Queue<byte>(data);
}

View file

@ -5,7 +5,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class ChargedProjectilesComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class ChargedProjectilesComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public List<Item> Items { get; set; } = [];

View file

@ -5,11 +5,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class ContainerComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class ContainerComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public List<Item?> Items { get; set; } = [];
public override void Parse(Queue<byte> data)
{
var count = DataTypes.ReadNextVarInt(data);
@ -23,7 +23,7 @@ public class ContainerComponent(DataTypes dataTypes, ItemPalette itemPalette, Su
data.AddRange(DataTypes.GetVarInt(Items.Count));
foreach (var item in Items)
data.AddRange(DataTypes.GetItemSlot(item, ItemPalette));
return new Queue<byte>(data);
}
}

View file

@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class ContainerLootComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class ContainerLootComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public Dictionary<string, object>? Nbt { get; set; }
public override void Parse(Queue<byte> data)
{
Nbt = DataTypes.ReadNextNbt(data);

View file

@ -4,5 +4,5 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class CreativeSlotLockComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class CreativeSlotLockComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: EmptyComponent(dataTypes, itemPalette, subComponentRegistry);

View file

@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class CustomDataComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class CustomDataComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public Dictionary<string, object>? Nbt { get; set; } = new();
public override void Parse(Queue<byte> data)
{
Nbt = DataTypes.ReadNextNbt(data);

View file

@ -10,7 +10,7 @@ public class CustomModelDataComponent(DataTypes dataTypes, ItemPalette itemPalet
public List<bool> Flags { get; set; } = [];
public List<string> Strings { get; set; } = [];
public List<int> Colors { get; set; } = [];
public override void Parse(Queue<byte> data)
{
Floats = ReadList(data, static (dataTypes, componentData) => dataTypes.ReadNextFloat(componentData));

View file

@ -5,12 +5,12 @@ using MinecraftClient.Protocol.Message;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class CustomNameComponent(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;
public Dictionary<string, object>? CustomNameNbt { get; set; }
public override void Parse(Queue<byte> data)
{
CustomNameNbt = DataTypes.ReadNextNbt(data);

View file

@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class DamageComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class DamageComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public int Damage { get; set; }
public override void Parse(Queue<byte> data)
{
Damage = DataTypes.ReadNextVarInt(data);

View file

@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class DebugStickStateComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class DebugStickStateComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public Dictionary<string, object>? Nbt { get; set; }
public override void Parse(Queue<byte> data)
{
Nbt = DataTypes.ReadNextNbt(data);

View file

@ -4,12 +4,12 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class DyeColorComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class DyeColorComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public int Color { get; set; }
public bool ShowInTooltip { get; set; }
public override void Parse(Queue<byte> data)
{
Color = DataTypes.ReadNextInt(data);

View file

@ -8,7 +8,7 @@ public class EnchantmentGlintOverrideComponent(DataTypes dataTypes, ItemPalette
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public bool HasGlint { get; set; }
public override void Parse(Queue<byte> data)
{
HasGlint = DataTypes.ReadNextBool(data);

View file

@ -5,7 +5,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class EnchantmentsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class EnchantmentsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public int NumberOfEnchantments { get; set; }

View file

@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class EntityDataComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class EntityDataComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public Dictionary<string, object>? Nbt { get; set; }
public override void Parse(Queue<byte> data)
{
Nbt = DataTypes.ReadNextNbt(data);
@ -22,8 +22,10 @@ public class EntityDataComponent(DataTypes dataTypes, ItemPalette itemPalette, S
}
}
public class BucketEntityDataComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: EntityDataComponent(dataTypes, itemPalette, subComponentRegistry) {}
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) {}
public class BlockEntityDataComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: EntityDataComponent(dataTypes, itemPalette, subComponentRegistry)
{ }

View file

@ -3,5 +3,5 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class FireResistantComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class FireResistantComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: EmptyComponent(dataTypes, itemPalette, subComponentRegistry);

View file

@ -8,11 +8,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class FireworkExplosionComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class FireworkExplosionComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public FireworkExplosionSubComponent? FireworkExplosionSubComponent { get; set; }
public override void Parse(Queue<byte> data)
{
FireworkExplosionSubComponent = (FireworkExplosionSubComponent)SubComponentRegistry.ParseSubComponent(SubComponents.FireworkExplosion, data);

View file

@ -9,14 +9,14 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class FireworksComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
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<FireworkExplosionSubComponent> Explosions { get; set; } = [];
public override void Parse(Queue<byte> data)
{
FlightDuration = DataTypes.ReadNextVarInt(data);
@ -24,7 +24,7 @@ public class FireworksComponent(DataTypes dataTypes, ItemPalette itemPalette, Su
if (NumberOfExplosions > 0)
{
for(var i = 0; i < NumberOfExplosions; i++)
for (var i = 0; i < NumberOfExplosions; i++)
Explosions.Add(
(FireworkExplosionSubComponent)SubComponentRegistry.ParseSubComponent(SubComponents.FireworkExplosion,
data));
@ -40,8 +40,8 @@ public class FireworksComponent(DataTypes dataTypes, ItemPalette itemPalette, Su
{
if (NumberOfExplosions != Explosions.Count)
throw new Exception("Can't serialize FireworksComponent because NumberOfExplosions and the lenght of Explosions differ!");
foreach(var explosion in Explosions)
foreach (var explosion in Explosions)
data.AddRange(explosion.Serialize().ToList());
}
return new Queue<byte>(data);

View file

@ -7,7 +7,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class FoodComponentComponent(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 FoodComponentComponent(DataTypes dataTypes, ItemPalette itemPalette
public bool CanAlwaysEat { get; set; }
public float SecondsToEat { get; set; }
public List<EffectSubComponent> Effects { get; set; } = new();
public override void Parse(Queue<byte> data)
{
Nutrition = DataTypes.ReadNextVarInt(data);
@ -23,8 +23,8 @@ public class FoodComponentComponent(DataTypes dataTypes, ItemPalette itemPalette
CanAlwaysEat = DataTypes.ReadNextBool(data);
SecondsToEat = DataTypes.ReadNextFloat(data);
var numberOfEffects = DataTypes.ReadNextVarInt(data);
for(var i = 0; i < numberOfEffects; i++)
for (var i = 0; i < numberOfEffects; i++)
Effects.Add((EffectSubComponent)SubComponentRegistry.ParseSubComponent(SubComponents.Effect, data));
}
@ -37,9 +37,9 @@ public class FoodComponentComponent(DataTypes dataTypes, ItemPalette itemPalette
data.AddRange(DataTypes.GetFloat(SecondsToEat));
data.AddRange(DataTypes.GetVarInt(Effects.Count));
foreach(var effect in Effects)
foreach (var effect in Effects)
data.AddRange(effect.Serialize());
return new Queue<byte>(data);
}
}

View file

@ -3,5 +3,5 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class HideAdditionalTooltipComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class HideAdditionalTooltipComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: EmptyComponent(dataTypes, itemPalette, subComponentRegistry);

View file

@ -3,5 +3,5 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class HideTooltipComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class HideTooltipComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: EmptyComponent(dataTypes, itemPalette, subComponentRegistry);

View file

@ -4,7 +4,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class InstrumentComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class InstrumentComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
// holder ID: 0 = inline instrument data, N>0 = registry reference (id = N-1)
@ -20,7 +20,7 @@ public class InstrumentComponent(DataTypes dataTypes, ItemPalette itemPalette, S
public int UseDuration { get; set; }
public float Range { get; set; }
public override void Parse(Queue<byte> data)
{
InstrumentHolderId = DataTypes.ReadNextVarInt(data);

View file

@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class IntangibleProjectileComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class IntangibleProjectileComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public Dictionary<string, object>? Nbt { get; set; } = new();
public override void Parse(Queue<byte> data)
{
Nbt = DataTypes.ReadNextNbt(data);

View file

@ -5,12 +5,12 @@ using MinecraftClient.Protocol.Message;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class ItemNameComponent(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;
public Dictionary<string, object>? ItemNameNbt { get; set; }
public override void Parse(Queue<byte> data)
{
ItemNameNbt = DataTypes.ReadNextNbt(data);

View file

@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class LockComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class LockComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public Dictionary<string, object>? Nbt { get; set; }
public override void Parse(Queue<byte> data)
{
Nbt = DataTypes.ReadNextNbt(data);

View file

@ -5,14 +5,14 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class LodestoneTrackerComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
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<byte> data)
{
HasGlobalPosition = DataTypes.ReadNextBool(data);
@ -22,7 +22,7 @@ public class LodestoneTrackerComponent(DataTypes dataTypes, ItemPalette itemPale
Dimension = DataTypes.ReadNextString(data);
Position = DataTypes.ReadNextLocation(data);
}
Tracked = DataTypes.ReadNextBool(data);
}
@ -36,7 +36,7 @@ public class LodestoneTrackerComponent(DataTypes dataTypes, ItemPalette itemPale
data.AddRange(DataTypes.GetString(Dimension));
data.AddRange(DataTypes.GetLocation(Position));
}
data.AddRange(DataTypes.GetBool(Tracked));
return new Queue<byte>(data);
}

View file

@ -5,19 +5,19 @@ using MinecraftClient.Protocol.Message;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class LoreNameComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class LoreNameComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public int NumberOfLines { get; set; }
public List<string> Lines { get; set; } = [];
public List<Dictionary<string, object>> LinesNbt { get; set; } = [];
public override void Parse(Queue<byte> data)
{
NumberOfLines = DataTypes.ReadNextVarInt(data);
if (NumberOfLines <= 0) return;
for (var i = 0; i < NumberOfLines; i++)
{
var lineNbt = DataTypes.ReadNextNbt(data);

View file

@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class MapColorComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class MapColorComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public int Id { get; set; }
public override void Parse(Queue<byte> data)
{
Id = DataTypes.ReadNextInt(data);

View file

@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class MapDecorationsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class MapDecorationsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public Dictionary<string, object>? Nbt { get; set; } = new();
public override void Parse(Queue<byte> data)
{
Nbt = DataTypes.ReadNextNbt(data);

View file

@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class MapIdComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class MapIdComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public int Id { get; set; }
public override void Parse(Queue<byte> data)
{
Id = DataTypes.ReadNextVarInt(data);

View file

@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class MapPostProcessingComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class MapPostProcessingComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public int Type { get; set; }
public override void Parse(Queue<byte> data)
{
Type = DataTypes.ReadNextVarInt(data);

View file

@ -8,7 +8,7 @@ public class MaxDamageComponent(DataTypes dataTypes, ItemPalette itemPalette, Su
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public int MaxDamage { get; set; }
public override void Parse(Queue<byte> data)
{
MaxDamage = DataTypes.ReadNextVarInt(data);

View file

@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class MaxStackSizeComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class MaxStackSizeComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public int MaxStackSize { get; set; }
public override void Parse(Queue<byte> data)
{
MaxStackSize = DataTypes.ReadNextVarInt(data);

View file

@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class NoteBlockSoundComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class NoteBlockSoundComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public string Identifier { get; set; } = null!;
public override void Parse(Queue<byte> data)
{
Identifier = DataTypes.ReadNextString(data);

View file

@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class OmniousBottleAmplifierComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class OmniousBottleAmplifierComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public int Amplifier { get; set; }
public override void Parse(Queue<byte> data)
{
Amplifier = DataTypes.ReadNextVarInt(data);

View file

@ -4,15 +4,15 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class PotDecorationsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class PotDecorationsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public List<int> Items { get; set; } = [];
public override void Parse(Queue<byte> data)
{
var count = DataTypes.ReadNextVarInt(data);
for(var i = 0; i < count; i++)
for (var i = 0; i < count; i++)
Items.Add(DataTypes.ReadNextVarInt(data));
}

View file

@ -6,7 +6,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class PotionContentsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class PotionContentsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public bool HasPotionId { get; set; }
@ -14,7 +14,7 @@ public class PotionContentsComponent(DataTypes dataTypes, ItemPalette itemPalett
public bool HasCustomColor { get; set; }
public int CustomColor { get; set; }
public List<PotionEffectSubComponent> Effects { get; set; } = new();
public override void Parse(Queue<byte> data)
{
HasPotionId = DataTypes.ReadNextBool(data);
@ -44,7 +44,7 @@ public class PotionContentsComponent(DataTypes dataTypes, ItemPalette itemPalett
data.AddRange(DataTypes.GetVarInt(Effects.Count));
foreach (var effect in Effects)
data.AddRange(effect.Serialize());
return new Queue<byte>(data);
}
}

View file

@ -18,7 +18,7 @@ public class ProfileComponent(DataTypes dataTypes, ItemPalette itemPalette, SubC
public string? CapeAssetId { get; set; }
public string? ElytraAssetId { get; set; }
public ProfileSkinModel? Model { get; set; }
public override void Parse(Queue<byte> data)
{
ResetState();

View file

@ -5,11 +5,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class RarityComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class RarityComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public ItemRarity Rarity { get; set; }
public override void Parse(Queue<byte> data)
{
Rarity = (ItemRarity)DataTypes.ReadNextVarInt(data);

View file

@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class RecipesComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class RecipesComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public Dictionary<string, object>? Nbt { get; set; }
public override void Parse(Queue<byte> data)
{
Nbt = DataTypes.ReadNextNbt(data);

View file

@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class RepairCostComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class RepairCostComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public int Cost { get; set; }
public override void Parse(Queue<byte> data)
{
Cost = DataTypes.ReadNextVarInt(data);

View file

@ -5,5 +5,5 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class StoredEnchantmentsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class StoredEnchantmentsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: EnchantmentsComponent(dataTypes, itemPalette, subComponentRegistry);

View file

@ -7,7 +7,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class SuspiciousStewEffectsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class SuspiciousStewEffectsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public int NumberOfEffects { get; set; }
@ -28,7 +28,7 @@ public class SuspiciousStewEffectsComponent(DataTypes dataTypes, ItemPalette ite
if (NumberOfEffects != Effects.Count)
throw new InvalidOperationException("Can not serialize SuspiciousStewEffectsComponent1206 because umberOfEffects != Effects.Count!");
foreach (var effect in Effects)
{
data.AddRange(DataTypes.GetVarInt(effect.TypeId));

View file

@ -7,14 +7,14 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class ToolComponent(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<RuleSubComponent> Rules { get; set; } = new();
public float DefaultMiningSpeed { get; set; }
public int DamagePerBlock { get; set; }
public override void Parse(Queue<byte> data)
{
NumberOfRules = DataTypes.ReadNextVarInt(data);
@ -30,13 +30,13 @@ public class ToolComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComp
{
var data = new List<byte>();
data.AddRange(DataTypes.GetVarInt(NumberOfRules));
if(Rules.Count != NumberOfRules)
if (Rules.Count != NumberOfRules)
throw new ArgumentNullException($"Can not serialize a ToolComponent1206 when the Rules count != NumberOfRules!");
foreach (var rule in Rules)
data.AddRange(rule.Serialize());
data.AddRange(DataTypes.GetFloat(DefaultMiningSpeed));
data.AddRange(DataTypes.GetVarInt(DamagePerBlock));
return new Queue<byte>(data);

View file

@ -24,7 +24,7 @@ public class TrimComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComp
public string TrimPatternTypeDescription { get; set; } = null!;
public bool Decal { get; set; }
public bool ShowInTooltip { get; set; }
public override void Parse(Queue<byte> data)
{
TrimMaterialType = DataTypes.ReadNextVarInt(data);
@ -73,16 +73,16 @@ public class TrimComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComp
{
if (string.IsNullOrEmpty(AssetName))
throw new NullReferenceException("Can't serialize the TrimComponent because the Asset Name is 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)
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));
@ -97,15 +97,15 @@ public class TrimComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComp
{
if (string.IsNullOrEmpty(TrimPatternTypeAssetName))
throw new NullReferenceException("Can't serialize the TrimComponent because the TrimPatternTypeAssetName is null!");
data.AddRange(DataTypes.GetString(TrimPatternTypeAssetName));
data.AddRange(DataTypes.GetVarInt(TemplateItem));
data.AddRange(DataTypes.GetNbt(TrimPatternTypeDescriptionNbt));
data.AddRange(DataTypes.GetBool(Decal));
}
data.AddRange(DataTypes.GetBool(ShowInTooltip));
return new Queue<byte>(data);
}
}

View file

@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6;
public class UnbrekableComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class UnbrekableComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public bool Unbrekable { get; set; }
public override void Parse(Queue<byte> data)
{
Unbrekable = DataTypes.ReadNextBool(data);

View file

@ -9,7 +9,7 @@ namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_2
public class WritableBlookContentComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public List<BookPage> Pages { get; set; } = [];
public override void Parse(Queue<byte> data)
{
var count = DataTypes.ReadNextVarInt(data);
@ -19,10 +19,10 @@ public class WritableBlookContentComponent(DataTypes dataTypes, ItemPalette item
var rawContent = DataTypes.ReadNextString(data);
var hasFilteredContent = DataTypes.ReadNextBool(data);
var filteredContent = null as string;
if(hasFilteredContent)
if (hasFilteredContent)
filteredContent = DataTypes.ReadNextString(data);
Pages.Add(new BookPage(rawContent, hasFilteredContent, filteredContent));
}
}
@ -30,7 +30,7 @@ public class WritableBlookContentComponent(DataTypes dataTypes, ItemPalette item
public override Queue<byte> Serialize()
{
var data = new List<byte>();
data.AddRange(DataTypes.GetVarInt(Pages.Count));
foreach (var page in Pages)
@ -40,9 +40,9 @@ public class WritableBlookContentComponent(DataTypes dataTypes, ItemPalette item
if (page.HasFilteredContent)
{
if(page.FilteredContent is null)
if (page.FilteredContent is null)
throw new InvalidOperationException("Can not serialize WritableBlookContentComponent because page.HasFilteredContent = true, but FilteredContent is null!");
data.AddRange(DataTypes.GetString(page.FilteredContent));
}
}

View file

@ -17,7 +17,7 @@ public class WrittenBlookContentComponent(DataTypes dataTypes, ItemPalette itemP
public int NumberOfPages { get; set; }
public List<BookPage> Pages { get; set; } = [];
public bool Resolved { get; set; }
public override void Parse(Queue<byte> data)
{
RawTitle = DataTypes.ReadNextString(data);
@ -25,7 +25,7 @@ public class WrittenBlookContentComponent(DataTypes dataTypes, ItemPalette itemP
if (HasFilteredTitle)
FilteredTitle = DataTypes.ReadNextString(data);
Author = DataTypes.ReadNextString(data);
Generation = DataTypes.ReadNextVarInt(data);
NumberOfPages = DataTypes.ReadNextVarInt(data);
@ -37,13 +37,13 @@ public class WrittenBlookContentComponent(DataTypes dataTypes, ItemPalette itemP
var hasFilteredContent = DataTypes.ReadNextBool(data);
Dictionary<string, object>? filteredContentNbt = null;
string? filteredContent = null;
if (hasFilteredContent)
{
filteredContentNbt = DataTypes.ReadNextNbt(data);
filteredContent = ChatParser.ParseText(filteredContentNbt);
}
Pages.Add(new BookPage(rawContent, hasFilteredContent, filteredContent, rawContentNbt, filteredContentNbt));
}
@ -53,18 +53,18 @@ public class WrittenBlookContentComponent(DataTypes dataTypes, ItemPalette itemP
public override Queue<byte> Serialize()
{
var data = new List<byte>();
data.AddRange(DataTypes.GetString(RawTitle));
data.AddRange(DataTypes.GetBool(HasFilteredTitle));
if (HasFilteredTitle)
{
if(FilteredTitle is null)
if (FilteredTitle is null)
throw new InvalidOperationException("Can not serialize WrittenBookContentComponent because HasFilteredTitle is true but FilteredTitle is null!");
data.AddRange(DataTypes.GetString(FilteredTitle));
}
data.AddRange(DataTypes.GetString(Author));
data.AddRange(DataTypes.GetVarInt(Generation));
data.AddRange(DataTypes.GetVarInt(Pages.Count));

View file

@ -7,7 +7,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core;
namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_21;
public class JukeBoxPlayableComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
public class JukeBoxPlayableComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
{
public bool DirectMode { get; set; }
@ -18,7 +18,7 @@ public class JukeBoxPlayableComponent(DataTypes dataTypes, ItemPalette itemPalet
public float? Duration { get; set; }
public int? Output { get; set; }
public bool ShowTooltip { get; set; }
public override void Parse(Queue<byte> data)
{
DirectMode = DataTypes.ReadNextBool(data);
@ -46,22 +46,22 @@ public class JukeBoxPlayableComponent(DataTypes dataTypes, ItemPalette itemPalet
public override Queue<byte> Serialize()
{
var data = new List<byte>();
data.AddRange(DataTypes.GetBool(DirectMode));
if (!DirectMode)
{
if (string.IsNullOrEmpty(SongName?.Trim()))
throw new ArgumentNullException($"Can not serialize JukeBoxPlayableComponent due to SongName being null or empty!");
data.AddRange(DataTypes.GetString(SongName));
}
if (DirectMode)
{
if(SongType is null)
if (SongType is null)
throw new ArgumentNullException($"Can not serialize JukeBoxPlayableComponent due to SongType being null!");
data.AddRange(DataTypes.GetVarInt((int)SongType));
if (SongType == 0)
@ -91,9 +91,9 @@ public class JukeBoxPlayableComponent(DataTypes dataTypes, ItemPalette itemPalet
data.AddRange(DataTypes.GetVarInt((int)Output));
}
}
data.AddRange(DataTypes.GetBool(ShowTooltip));
return new Queue<byte>(data);
}
}

View file

@ -27,7 +27,7 @@ public class EquippableComponent(DataTypes dataTypes, ItemPalette itemPalette, S
{
Slot = DataTypes.ReadNextVarInt(data);
EquipSound = (SoundEventSubComponent)SubComponentRegistry.ParseSubComponent(SubComponents.SoundEvent, data);
HasModel = DataTypes.ReadNextBool(data);
if (HasModel)
Model = DataTypes.ReadNextString(data);

View file

@ -26,4 +26,5 @@ public class TypedEntityDataComponent261(DataTypes dataTypes, ItemPalette itemPa
}
public class BlockEntityDataComponent261(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
: TypedEntityDataComponent261(dataTypes, itemPalette, subComponentRegistry) {}
: TypedEntityDataComponent261(dataTypes, itemPalette, subComponentRegistry)
{ }

View file

@ -12,7 +12,7 @@ public class AttributeSubComponent(DataTypes dataTypes, SubComponentRegistry sub
public double Value { get; set; }
public int Operation { get; set; }
public int Slot { get; set; }
protected override void Parse(Queue<byte> data)
{
TypeId = DataTypes.ReadNextVarInt(data);
@ -28,10 +28,10 @@ public class AttributeSubComponent(DataTypes dataTypes, SubComponentRegistry sub
var data = new List<byte>();
data.AddRange(DataTypes.GetVarInt(TypeId));
data.AddRange(DataTypes.GetUUID(Uuid));
if (string.IsNullOrEmpty(Name?.Trim()))
throw new ArgumentNullException($"Can not serialize AttributeSubComponent due to Name being null or empty!");
data.AddRange(DataTypes.GetString(Name));
data.AddRange(DataTypes.GetDouble(Value));
data.AddRange(DataTypes.GetVarInt(Operation));

View file

@ -12,7 +12,7 @@ public class BlockPredicateSubcomponent(DataTypes dataTypes, SubComponentRegistr
public List<PropertySubComponent>? Properties { get; set; }
public bool HasNbt { get; set; }
public Dictionary<string, object>? Nbt { get; set; }
protected override void Parse(Queue<byte> data)
{
HasBlocks = DataTypes.ReadNextBool(data);
@ -31,7 +31,7 @@ public class BlockPredicateSubcomponent(DataTypes dataTypes, SubComponentRegistr
}
HasNbt = DataTypes.ReadNextBool(data);
if (HasNbt)
Nbt = DataTypes.ReadNextNbt(data);
}
@ -39,22 +39,22 @@ public class BlockPredicateSubcomponent(DataTypes dataTypes, SubComponentRegistr
public override Queue<byte> Serialize()
{
var data = new List<byte>();
// Block Sets
data.AddRange(DataTypes.GetBool(HasBlocks));
if (HasBlocks)
{
if(BlockSet is null)
if (BlockSet is null)
throw new ArgumentNullException($"Can not serialize a BlockPredicate when the BlockSet is empty but HasBlocks is true!");
data.AddRange(BlockSet.Serialize());
}
// Properties
data.AddRange(DataTypes.GetBool(HasProperities));
if (HasProperities)
{
if(Properties is null || Properties.Count == 0)
if (Properties is 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));
@ -66,12 +66,12 @@ public class BlockPredicateSubcomponent(DataTypes dataTypes, SubComponentRegistr
data.AddRange(DataTypes.GetBool(HasNbt));
if (HasNbt)
{
if(Nbt is null)
if (Nbt is null)
throw new ArgumentNullException($"Can not serialize a BlockPredicate when the Nbt is empty but HasNbt is true!");
data.AddRange(DataTypes.GetNbt(Nbt));
}
return new Queue<byte>(data);
}
}

View file

@ -9,7 +9,7 @@ public class BlockSetSubcomponent(DataTypes dataTypes, SubComponentRegistry subC
public int Type { get; set; }
public string? TagName { get; set; }
public List<int>? BlockIds { get; set; }
protected override void Parse(Queue<byte> data)
{
Type = DataTypes.ReadNextVarInt(data);
@ -18,9 +18,9 @@ public class BlockSetSubcomponent(DataTypes dataTypes, SubComponentRegistry subC
TagName = DataTypes.ReadNextString(data);
if (Type == 0) return;
BlockIds = [];
for (var i = 0; i < Type - 1; i++)
BlockIds.Add(DataTypes.ReadNextVarInt(data));
}
@ -33,16 +33,16 @@ public class BlockSetSubcomponent(DataTypes dataTypes, SubComponentRegistry subC
{
if (string.IsNullOrEmpty(TagName?.Trim()))
throw new ArgumentNullException($"Can not serialize an empty tag name when the Block Set type is 0!");
data.AddRange(DataTypes.GetString(TagName));
}
if (Type == 0) return new Queue<byte>(data);
if(BlockIds is null || BlockIds.Count == 0)
if (BlockIds is null || BlockIds.Count == 0)
throw new ArgumentNullException($"Can not serialize an empty list of Block IDs in a Block Set when the type is not 0!");
for(var i = 0; i < Type - 1; i++)
for (var i = 0; i < Type - 1; i++)
data.AddRange(DataTypes.GetVarInt(BlockIds[i]));
return new Queue<byte>(data);

View file

@ -13,7 +13,7 @@ public class DetailsSubComponent(DataTypes dataTypes, SubComponentRegistry subCo
public bool ShowIcon { get; set; }
public bool HasHiddenEffects { get; set; }
public DetailsSubComponent? Detail { get; set; }
protected override void Parse(Queue<byte> data)
{
Amplifier = DataTypes.ReadNextVarInt(data);
@ -22,8 +22,8 @@ public class DetailsSubComponent(DataTypes dataTypes, SubComponentRegistry subCo
ShowParticles = DataTypes.ReadNextBool(data);
ShowIcon = DataTypes.ReadNextBool(data);
HasHiddenEffects = DataTypes.ReadNextBool(data);
if(HasHiddenEffects)
if (HasHiddenEffects)
Detail = (DetailsSubComponent)SubComponentRegistry.ParseSubComponent(SubComponents.Details, data);
}
@ -39,9 +39,9 @@ public class DetailsSubComponent(DataTypes dataTypes, SubComponentRegistry subCo
if (HasHiddenEffects)
{
if(Detail is null)
if (Detail is null)
throw new ArgumentNullException($"Can not serialize a DetailSubComponent1206 when the Detail is empty but HasHiddenEffects is true!");
data.AddRange(Detail.Serialize());
}

View file

@ -8,7 +8,7 @@ public class EffectSubComponent(DataTypes dataTypes, SubComponentRegistry subCom
{
public PotionEffectSubComponent TypeId { get; set; } = null!;
public float Probability { get; set; }
protected override void Parse(Queue<byte> data)
{
TypeId = (PotionEffectSubComponent)SubComponentRegistry.ParseSubComponent(SubComponents.PotionEffect, data);

View file

@ -13,7 +13,7 @@ public class FireworkExplosionSubComponent(DataTypes dataTypes, SubComponentRegi
public List<int> FadeColors { get; set; } = [];
public bool HasTrail { get; set; }
public bool HasTwinkle { get; set; }
protected override void Parse(Queue<byte> data)
{
Shape = DataTypes.ReadNextVarInt(data);
@ -21,12 +21,12 @@ public class FireworkExplosionSubComponent(DataTypes dataTypes, SubComponentRegi
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);
}
@ -45,7 +45,7 @@ public class FireworkExplosionSubComponent(DataTypes dataTypes, SubComponentRegi
foreach (var color in Colors)
data.AddRange(DataTypes.GetInt(color));
}
data.AddRange(DataTypes.GetVarInt(NumberOfFadeColors));
if (NumberOfFadeColors > 0)
{
@ -55,7 +55,7 @@ public class FireworkExplosionSubComponent(DataTypes dataTypes, SubComponentRegi
foreach (var fadeColor in FadeColors)
data.AddRange(DataTypes.GetInt(fadeColor));
}
data.AddRange(DataTypes.GetBool(HasTrail));
data.AddRange(DataTypes.GetBool(HasTwinkle));
return new Queue<byte>(data);

View file

@ -8,7 +8,7 @@ public class PotionEffectSubComponent(DataTypes dataTypes, SubComponentRegistry
{
public int TypeId { get; set; }
public DetailsSubComponent Details { get; set; } = null!;
protected override void Parse(Queue<byte> data)
{
TypeId = DataTypes.ReadNextVarInt(data);

View file

@ -11,7 +11,7 @@ public class PropertySubComponent(DataTypes dataTypes, SubComponentRegistry subC
public string? ExactValue { get; set; }
public string? MinValue { get; set; }
public string? MaxValue { get; set; }
protected override void Parse(Queue<byte> data)
{
Name = DataTypes.ReadNextString(data);
@ -34,7 +34,7 @@ public class PropertySubComponent(DataTypes dataTypes, SubComponentRegistry subC
if (string.IsNullOrEmpty(Name?.Trim()))
throw new ArgumentNullException($"Can not serialize a Property sub-component if the Name is null or empty!");
data.AddRange(DataTypes.GetString(Name));
data.AddRange(DataTypes.GetBool(IsExactMatch));
@ -42,7 +42,7 @@ public class PropertySubComponent(DataTypes dataTypes, SubComponentRegistry subC
{
if (string.IsNullOrEmpty(ExactValue?.Trim()))
throw new ArgumentNullException($"Can not serialize a Property sub-component if the ExactValue is null or empty when the type is Exact Match!");
data.AddRange(DataTypes.GetString(ExactValue));
}
else
@ -50,12 +50,12 @@ public class PropertySubComponent(DataTypes dataTypes, SubComponentRegistry subC
data.AddRange(DataTypes.GetBool(MinValue is not null));
if (MinValue is not null)
data.AddRange(DataTypes.GetString(MinValue));
data.AddRange(DataTypes.GetBool(MaxValue is not null));
if (MaxValue is not null)
data.AddRange(DataTypes.GetString(MaxValue));
}
return new Queue<byte>(data);
}
}

View file

@ -11,18 +11,18 @@ public class RuleSubComponent(DataTypes dataTypes, SubComponentRegistry subCompo
public float Speed { get; set; }
public bool HasCorrectDropForBlocks { get; set; }
public bool CorrectDropForBlocks { get; set; }
protected override void Parse(Queue<byte> data)
{
Blocks = (BlockSetSubcomponent)SubComponentRegistry.ParseSubComponent(SubComponents.BlockSet, data);
HasSpeed = DataTypes.ReadNextBool(data);
if(HasSpeed)
if (HasSpeed)
Speed = DataTypes.ReadNextFloat(data);
HasCorrectDropForBlocks = DataTypes.ReadNextBool(data);
if(HasCorrectDropForBlocks)
if (HasCorrectDropForBlocks)
CorrectDropForBlocks = DataTypes.ReadNextBool(data);
}
@ -31,13 +31,13 @@ public class RuleSubComponent(DataTypes dataTypes, SubComponentRegistry subCompo
var data = new List<byte>();
data.AddRange(Blocks.Serialize());
data.AddRange(DataTypes.GetBool(HasSpeed));
if(HasSpeed)
if (HasSpeed)
data.AddRange(DataTypes.GetFloat(Speed));
data.AddRange(DataTypes.GetBool(HasCorrectDropForBlocks));
if(HasCorrectDropForBlocks)
if (HasCorrectDropForBlocks)
data.AddRange(DataTypes.GetBool(CorrectDropForBlocks));
return new Queue<byte>(data);
}
}

View file

@ -11,7 +11,7 @@ public class AttributeSubComponent121(DataTypes dataTypes, SubComponentRegistry
public double Value { get; set; }
public int Operation { get; set; }
public int Slot { get; set; }
protected override void Parse(Queue<byte> data)
{
TypeId = DataTypes.ReadNextVarInt(data);
@ -25,10 +25,10 @@ public class AttributeSubComponent121(DataTypes dataTypes, SubComponentRegistry
{
var data = new List<byte>();
data.AddRange(DataTypes.GetVarInt(TypeId));
if (string.IsNullOrEmpty(ResourceLocation?.Trim()))
throw new ArgumentNullException($"Can not serialize AttributeSubComponent121 due to ResourceLocation being null or empty!");
data.AddRange(DataTypes.GetString(ResourceLocation));
data.AddRange(DataTypes.GetDouble(Value));
data.AddRange(DataTypes.GetVarInt(Operation));

View file

@ -10,13 +10,13 @@ public class SoundEventSubComponent(DataTypes dataTypes, SubComponentRegistry su
public string? SoundName { get; set; }
public bool HasFixedRange { get; set; }
public float FixedRange { get; set; }
protected override void Parse(Queue<byte> data)
{
Type = DataTypes.ReadNextVarInt(data);
if (Type != 0) return;
SoundName = DataTypes.ReadNextString(data);
HasFixedRange = DataTypes.ReadNextBool(data);
@ -30,14 +30,14 @@ public class SoundEventSubComponent(DataTypes dataTypes, SubComponentRegistry su
data.AddRange(DataTypes.GetVarInt(Type));
if (Type != 0) return new Queue<byte>(data);
if (string.IsNullOrEmpty(SoundName?.Trim()))
throw new ArgumentNullException($"Can not serialize SoundEventSubComponent due to SoundName being null or empty!");
data.AddRange(DataTypes.GetString(SoundName));
data.AddRange(DataTypes.GetBool(HasFixedRange));
if(HasFixedRange)
if (HasFixedRange)
data.AddRange(DataTypes.GetFloat(FixedRange));
return new Queue<byte>(data);