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
|
|
@ -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