mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
Implemented all structured components, renamed them all to a better format
This commit is contained in:
parent
4dea688ca2
commit
0da4a718cb
67 changed files with 971 additions and 108 deletions
|
|
@ -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<AttributeSubComponent1206> Attributes { get; set; } = new();
|
||||
public List<AttributeSubComponent> Attributes { get; set; } = new();
|
||||
public bool ShowInTooltip { get; set; }
|
||||
|
||||
public override void Parse(Queue<byte> 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);
|
||||
}
|
||||
|
|
@ -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<BannerLayer> Layers { get; set; } = [];
|
||||
|
||||
public override void Parse(Queue<byte> 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<byte> Serialize()
|
||||
{
|
||||
var data = new List<byte>();
|
||||
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<byte>(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; }
|
||||
}
|
||||
|
|
@ -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<byte> data)
|
||||
{
|
||||
DyeColor = dataTypes.ReadNextVarInt(data);
|
||||
}
|
||||
|
||||
public override Queue<byte> Serialize()
|
||||
{
|
||||
var data = new List<byte>();
|
||||
data.AddRange(DataTypes.GetVarInt(DyeColor));
|
||||
return new Queue<byte>(data);
|
||||
}
|
||||
}
|
||||
|
|
@ -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<Bee> Bees { get; set; } = [];
|
||||
|
||||
public override void Parse(Queue<byte> 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<byte> Serialize()
|
||||
{
|
||||
var data = new List<byte>();
|
||||
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<byte>(data);
|
||||
}
|
||||
}
|
||||
|
||||
public record Bee(Dictionary<string, object>? EntityDataNbt, int TicksInHive, int MinTicksInHive);
|
||||
|
|
@ -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<byte> data)
|
||||
{
|
||||
NumberOfProperties = dataTypes.ReadNextVarInt(data);
|
||||
for(var i = 0; i < NumberOfProperties; i++)
|
||||
Properties.Add((dataTypes.ReadNextString(data), dataTypes.ReadNextString(data)));
|
||||
}
|
||||
|
||||
public override Queue<byte> Serialize()
|
||||
{
|
||||
var data = new List<byte>();
|
||||
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<byte>(data);
|
||||
}
|
||||
}
|
||||
|
|
@ -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; }
|
||||
|
|
@ -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<BlockPredicateSubcomponent1206> BlockPredicates { get; set; } = new();
|
||||
public List<BlockPredicateSubcomponent> BlockPredicates { get; set; } = new();
|
||||
public bool ShowInTooltip { get; set; }
|
||||
|
||||
public override void Parse(Queue<byte> 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);
|
||||
}
|
||||
|
|
@ -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<BlockPredicateSubcomponent1206> BlockPredicates { get; set; } = new();
|
||||
public List<BlockPredicateSubcomponent> BlockPredicates { get; set; } = new();
|
||||
public bool ShowInTooltip { get; set; }
|
||||
|
||||
public override void Parse(Queue<byte> 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);
|
||||
}
|
||||
|
|
@ -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; }
|
||||
|
|
@ -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<Item> Items { get; set; } = [];
|
||||
|
||||
public override void Parse(Queue<byte> 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<byte> Serialize()
|
||||
{
|
||||
var data = new List<byte>();
|
||||
data.AddRange(DataTypes.GetVarInt(NumberOfItems));
|
||||
for (var i = 0; i < NumberOfItems; i++)
|
||||
data.AddRange(DataTypes.GetItemSlot(Items[i], itemPalette));
|
||||
|
||||
return new Queue<byte>(data);
|
||||
}
|
||||
}
|
||||
|
|
@ -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<string, object>? Nbt { get; set; }
|
||||
|
||||
public override void Parse(Queue<byte> data)
|
||||
{
|
||||
Nbt = dataTypes.ReadNextNbt(data);
|
||||
}
|
||||
|
||||
public override Queue<byte> Serialize()
|
||||
{
|
||||
var data = new List<byte>();
|
||||
data.AddRange(DataTypes.GetNbt(Nbt));
|
||||
return new Queue<byte>(data);
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
|
|
@ -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<string, object>? Nbt { get; set; } = new();
|
||||
|
|
@ -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; }
|
||||
|
||||
|
|
@ -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;
|
||||
|
|
@ -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; }
|
||||
|
|
@ -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<string, object>? Nbt { get; set; }
|
||||
|
||||
public override void Parse(Queue<byte> data)
|
||||
{
|
||||
Nbt = dataTypes.ReadNextNbt(data);
|
||||
}
|
||||
|
||||
public override Queue<byte> Serialize()
|
||||
{
|
||||
var data = new List<byte>();
|
||||
data.AddRange(DataTypes.GetNbt(Nbt));
|
||||
return new Queue<byte>(data);
|
||||
}
|
||||
}
|
||||
|
|
@ -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; }
|
||||
|
|
@ -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; }
|
||||
|
|
@ -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; }
|
||||
|
|
@ -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<string, object>? Nbt { get; set; }
|
||||
|
||||
public override void Parse(Queue<byte> data)
|
||||
{
|
||||
Nbt = dataTypes.ReadNextNbt(data);
|
||||
}
|
||||
|
||||
public override Queue<byte> Serialize()
|
||||
{
|
||||
var data = new List<byte>();
|
||||
data.AddRange(DataTypes.GetNbt(Nbt));
|
||||
return new Queue<byte>(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) {}
|
||||
|
|
@ -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);
|
||||
|
|
@ -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<byte> data)
|
||||
{
|
||||
FireworkExplosionSubComponent = (FireworkExplosionSubComponent)subComponentRegistry.ParseSubComponent(SubComponents.FireworkExplosion, data);
|
||||
}
|
||||
|
||||
public override Queue<byte> Serialize()
|
||||
{
|
||||
return FireworkExplosionSubComponent!.Serialize();
|
||||
}
|
||||
}
|
||||
|
|
@ -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<FireworkExplosionSubComponent> Explosions { get; set; } = [];
|
||||
|
||||
public override void Parse(Queue<byte> 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<byte> Serialize()
|
||||
{
|
||||
var data = new List<byte>();
|
||||
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<byte>(data);
|
||||
}
|
||||
}
|
||||
|
|
@ -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<EffectSubComponent1206> Effects { get; set; } = new();
|
||||
public List<EffectSubComponent> Effects { get; set; } = new();
|
||||
|
||||
public override void Parse(Queue<byte> 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<byte> Serialize()
|
||||
|
|
@ -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);
|
||||
|
|
@ -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);
|
||||
|
|
@ -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<byte> 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<byte> Serialize()
|
||||
{
|
||||
var data = new List<byte>();
|
||||
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<byte>(data);
|
||||
}
|
||||
}
|
||||
|
|
@ -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<string, object>? Nbt { get; set; } = new();
|
||||
|
|
@ -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;
|
||||
|
|
@ -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<string, object>? Nbt { get; set; }
|
||||
|
||||
public override void Parse(Queue<byte> data)
|
||||
{
|
||||
Nbt = dataTypes.ReadNextNbt(data);
|
||||
}
|
||||
|
||||
public override Queue<byte> Serialize()
|
||||
{
|
||||
var data = new List<byte>();
|
||||
data.AddRange(DataTypes.GetNbt(Nbt));
|
||||
return new Queue<byte>(data);
|
||||
}
|
||||
}
|
||||
|
|
@ -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<byte> data)
|
||||
{
|
||||
HasGlobalPosition = dataTypes.ReadNextBool(data);
|
||||
|
||||
if (HasGlobalPosition)
|
||||
{
|
||||
Dimension = dataTypes.ReadNextString(data);
|
||||
Position = dataTypes.ReadNextLocation(data);
|
||||
}
|
||||
|
||||
Tracked = dataTypes.ReadNextBool(data);
|
||||
}
|
||||
|
||||
public override Queue<byte> Serialize()
|
||||
{
|
||||
var data = new List<byte>();
|
||||
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<byte>(data);
|
||||
}
|
||||
}
|
||||
|
|
@ -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; }
|
||||
|
|
@ -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<string, object>? Nbt { get; set; } = new();
|
||||
|
|
@ -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; }
|
||||
|
|
@ -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; }
|
||||
|
|
@ -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; }
|
||||
|
|
@ -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; }
|
||||
|
|
@ -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<byte> data)
|
||||
{
|
||||
Identifier = dataTypes.ReadNextString(data);
|
||||
}
|
||||
|
||||
public override Queue<byte> Serialize()
|
||||
{
|
||||
var data = new List<byte>();
|
||||
data.AddRange(DataTypes.GetString(Identifier));
|
||||
return new Queue<byte>(data);
|
||||
}
|
||||
}
|
||||
|
|
@ -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<byte> data)
|
||||
{
|
||||
Amplifier = dataTypes.ReadNextVarInt(data);
|
||||
}
|
||||
|
||||
public override Queue<byte> Serialize()
|
||||
{
|
||||
var data = new List<byte>();
|
||||
data.AddRange(DataTypes.GetVarInt(Amplifier));
|
||||
return new Queue<byte>(data);
|
||||
}
|
||||
}
|
||||
|
|
@ -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<int> Items { get; set; } = [];
|
||||
|
||||
public override void Parse(Queue<byte> data)
|
||||
{
|
||||
NumberOfItems = dataTypes.ReadNextVarInt(data);
|
||||
for(var i = 0; i < NumberOfItems; i++)
|
||||
Items.Add(dataTypes.ReadNextVarInt(data));
|
||||
}
|
||||
|
||||
public override Queue<byte> Serialize()
|
||||
{
|
||||
var data = new List<byte>();
|
||||
data.AddRange(DataTypes.GetVarInt(NumberOfItems));
|
||||
for(var i = 0; i < NumberOfItems; i++)
|
||||
data.AddRange(DataTypes.GetVarInt(Items[i]));
|
||||
return new Queue<byte>(data);
|
||||
}
|
||||
}
|
||||
|
|
@ -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<PotionEffectSubComponent1206> Effects { get; set; } = new();
|
||||
public List<PotionEffectSubComponent> Effects { get; set; } = new();
|
||||
|
||||
public override void Parse(Queue<byte> 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<byte> Serialize()
|
||||
|
|
@ -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<ProfileProperty> ProfileProperties { get; set; } = [];
|
||||
|
||||
public override void Parse(Queue<byte> 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<byte> Serialize()
|
||||
{
|
||||
var data = new List<byte>();
|
||||
|
||||
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<byte>(data);
|
||||
}
|
||||
}
|
||||
|
||||
public record ProfileProperty(string Name, string Value, bool HasSignature, string? Signature);
|
||||
|
|
@ -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; }
|
||||
|
|
@ -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<string, object>? Nbt { get; set; }
|
||||
|
||||
public override void Parse(Queue<byte> data)
|
||||
{
|
||||
Nbt = dataTypes.ReadNextNbt(data);
|
||||
}
|
||||
|
||||
public override Queue<byte> Serialize()
|
||||
{
|
||||
var data = new List<byte>();
|
||||
data.AddRange(DataTypes.GetNbt(Nbt));
|
||||
return new Queue<byte>(data);
|
||||
}
|
||||
}
|
||||
|
|
@ -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; }
|
||||
|
|
@ -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);
|
||||
public class StoredEnchantmentsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
|
||||
: EnchantmentsComponent(dataTypes, itemPalette, subComponentRegistry);
|
||||
|
|
@ -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; }
|
||||
|
|
@ -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<RuleSubComponent1206> Rules { get; set; } = new();
|
||||
public List<RuleSubComponent> 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);
|
||||
|
|
@ -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<TrimAssetOverride>? 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<byte> 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<byte> Serialize()
|
||||
{
|
||||
var data = new List<byte>();
|
||||
|
||||
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<byte>(data);
|
||||
}
|
||||
}
|
||||
|
|
@ -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<BookPage> Pages { get; set; } = [];
|
||||
|
|
@ -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; }
|
||||
|
|
@ -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; }
|
||||
|
|
@ -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<PropertySubComponent1206>? Properties { get; set; }
|
||||
public List<PropertySubComponent>? Properties { get; set; }
|
||||
public bool HasNbt { get; set; }
|
||||
public Dictionary<string, object>? 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);
|
||||
|
|
@ -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; }
|
||||
|
|
@ -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<byte> 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<byte> Serialize()
|
||||
|
|
@ -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<byte> data)
|
||||
{
|
||||
TypeId = (PotionEffectSubComponent1206)subComponentRegistry.ParseSubComponent(SubComponents.PotionEffect, data);
|
||||
TypeId = (PotionEffectSubComponent)subComponentRegistry.ParseSubComponent(SubComponents.PotionEffect, data);
|
||||
Probability = dataTypes.ReadNextFloat(data);
|
||||
}
|
||||
|
||||
|
|
@ -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<int> Colors { get; set; } = [];
|
||||
public int NumberOfFadeColors { get; set; }
|
||||
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);
|
||||
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<byte> Serialize()
|
||||
{
|
||||
var data = new List<byte>();
|
||||
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<byte>(data);
|
||||
}
|
||||
}
|
||||
|
|
@ -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<byte> data)
|
||||
{
|
||||
TypeId = dataTypes.ReadNextVarInt(data);
|
||||
Details = (DetailsSubComponent1206)subComponentRegistry.ParseSubComponent(SubComponents.Details, data);
|
||||
Details = (DetailsSubComponent)subComponentRegistry.ParseSubComponent(SubComponents.Details, data);
|
||||
}
|
||||
|
||||
public override Queue<byte> Serialize()
|
||||
|
|
@ -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; }
|
||||
|
|
@ -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<byte> data)
|
||||
{
|
||||
Blocks = (BlockSetSubcomponent1206)subComponentRegistry.ParseSubComponent(SubComponents.BlockSet, data);
|
||||
Blocks = (BlockSetSubcomponent)subComponentRegistry.ParseSubComponent(SubComponents.BlockSet, data);
|
||||
HasSpeed = dataTypes.ReadNextBool(data);
|
||||
|
||||
if(HasSpeed)
|
||||
|
|
@ -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";
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue