mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
Added more components + added item palette reference
This commit is contained in:
parent
76e873ed54
commit
49319fe781
44 changed files with 667 additions and 29 deletions
|
|
@ -0,0 +1,50 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
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 int Amplifier { get; set; }
|
||||
public int Duration { get; set; }
|
||||
public bool Ambient { get; set; }
|
||||
public bool ShowParticles { get; set; }
|
||||
public bool ShowIcon { get; set; }
|
||||
public bool HasHiddenEffects { get; set; }
|
||||
public DetailsSubComponent1206? Detail { get; set; }
|
||||
|
||||
protected override void Parse(Queue<byte> data)
|
||||
{
|
||||
Amplifier = dataTypes.ReadNextVarInt(data);
|
||||
Duration = dataTypes.ReadNextVarInt(data);
|
||||
Ambient = dataTypes.ReadNextBool(data);
|
||||
ShowParticles = dataTypes.ReadNextBool(data);
|
||||
ShowIcon = dataTypes.ReadNextBool(data);
|
||||
HasHiddenEffects = dataTypes.ReadNextBool(data);
|
||||
|
||||
if(HasHiddenEffects)
|
||||
Detail = (DetailsSubComponent1206)subComponentRegistry.ParseSubComponent(SubComponents.Details, data);
|
||||
}
|
||||
|
||||
public override Queue<byte> Serialize()
|
||||
{
|
||||
var data = new List<byte>();
|
||||
data.AddRange(DataTypes.GetVarInt(Amplifier));
|
||||
data.AddRange(DataTypes.GetVarInt(Duration));
|
||||
data.AddRange(DataTypes.GetBool(Ambient));
|
||||
data.AddRange(DataTypes.GetBool(ShowParticles));
|
||||
data.AddRange(DataTypes.GetBool(ShowIcon));
|
||||
data.AddRange(DataTypes.GetBool(HasHiddenEffects));
|
||||
|
||||
if (HasHiddenEffects)
|
||||
{
|
||||
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());
|
||||
}
|
||||
|
||||
return new Queue<byte>(data);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
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 PotionEffectSubComponent1206 TypeId { get; set; }
|
||||
public float Probability { get; set; }
|
||||
|
||||
protected override void Parse(Queue<byte> data)
|
||||
{
|
||||
TypeId = (PotionEffectSubComponent1206)subComponentRegistry.ParseSubComponent(SubComponents.PotionEffect, data);
|
||||
Probability = dataTypes.ReadNextFloat(data);
|
||||
}
|
||||
|
||||
public override Queue<byte> Serialize()
|
||||
{
|
||||
var data = new List<byte>();
|
||||
data.AddRange(TypeId.Serialize());
|
||||
data.AddRange(DataTypes.GetFloat(Probability));
|
||||
return new Queue<byte>(data);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
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 int TypeId { get; set; }
|
||||
public DetailsSubComponent1206 Details { get; set; }
|
||||
|
||||
protected override void Parse(Queue<byte> data)
|
||||
{
|
||||
TypeId = dataTypes.ReadNextVarInt(data);
|
||||
Details = (DetailsSubComponent1206)subComponentRegistry.ParseSubComponent(SubComponents.Details, data);
|
||||
}
|
||||
|
||||
public override Queue<byte> Serialize()
|
||||
{
|
||||
var data = new List<byte>();
|
||||
data.AddRange(DataTypes.GetVarInt(TypeId));
|
||||
data.AddRange(Details.Serialize());
|
||||
return new Queue<byte>(data);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
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 BlockSetSubcomponent1206 Blocks { get; set; }
|
||||
public bool HasSpeed { get; set; }
|
||||
public float Speed { get; set; }
|
||||
public bool HasCorrectDropForBlocks { get; set; }
|
||||
public bool CorrectDropForBlocks { get; set; }
|
||||
|
||||
protected override void Parse(Queue<byte> data)
|
||||
{
|
||||
Blocks = (BlockSetSubcomponent1206)subComponentRegistry.ParseSubComponent(SubComponents.BlockSet, data);
|
||||
HasSpeed = dataTypes.ReadNextBool(data);
|
||||
|
||||
if(HasSpeed)
|
||||
Speed = dataTypes.ReadNextFloat(data);
|
||||
|
||||
HasCorrectDropForBlocks = dataTypes.ReadNextBool(data);
|
||||
|
||||
if(HasCorrectDropForBlocks)
|
||||
CorrectDropForBlocks = dataTypes.ReadNextBool(data);
|
||||
}
|
||||
|
||||
public override Queue<byte> Serialize()
|
||||
{
|
||||
var data = new List<byte>();
|
||||
data.AddRange(Blocks.Serialize());
|
||||
data.AddRange(DataTypes.GetBool(HasSpeed));
|
||||
if(HasSpeed)
|
||||
data.AddRange(DataTypes.GetFloat(Speed));
|
||||
|
||||
data.AddRange(DataTypes.GetBool(HasCorrectDropForBlocks));
|
||||
if(HasCorrectDropForBlocks)
|
||||
data.AddRange(DataTypes.GetBool(CorrectDropForBlocks));
|
||||
|
||||
return new Queue<byte>(data);
|
||||
}
|
||||
}
|
||||
|
|
@ -6,4 +6,8 @@ public class SubComponents
|
|||
public const string BlockSet = "BlockSet";
|
||||
public const string Property = "Property";
|
||||
public const string Attribute = "Attribute";
|
||||
public const string Effect = "Effect";
|
||||
public const string PotionEffect = "PotionEffect";
|
||||
public const string Details = "Details";
|
||||
public const string Rule = "Rule";
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue