mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
Replace lowercase primary constructor parameter references (dataTypes., subComponentRegistry., itemPalette.) with PascalCase base class property references (DataTypes., SubComponentRegistry., ItemPalette.) in method bodies of all StructuredComponent and SubComponent subclasses. This eliminates CS9107 warnings where subclass primary constructor parameters shadow the base class properties they are assigned to. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
50 lines
2 KiB
C#
50 lines
2 KiB
C#
using System.Collections.Generic;
|
|
using MinecraftClient.Inventory.ItemPalettes;
|
|
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 PotionContentsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
|
|
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
|
|
{
|
|
public bool HasPotionId { get; set; }
|
|
public int PotionId { get; set; }
|
|
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);
|
|
if (HasPotionId)
|
|
PotionId = DataTypes.ReadNextVarInt(data);
|
|
|
|
HasCustomColor = DataTypes.ReadNextBool(data);
|
|
if (HasCustomColor)
|
|
CustomColor = DataTypes.ReadNextInt(data);
|
|
|
|
var numberOfEffects = DataTypes.ReadNextVarInt(data);
|
|
for (var i = 0; i < numberOfEffects; i++)
|
|
Effects.Add((PotionEffectSubComponent)SubComponentRegistry.ParseSubComponent(SubComponents.PotionEffect, data));
|
|
}
|
|
|
|
public override Queue<byte> Serialize()
|
|
{
|
|
var data = new List<byte>();
|
|
data.AddRange(DataTypes.GetBool(HasPotionId));
|
|
if (HasPotionId)
|
|
data.AddRange(DataTypes.GetVarInt(PotionId));
|
|
|
|
data.AddRange(DataTypes.GetBool(HasCustomColor));
|
|
if (HasCustomColor)
|
|
data.AddRange(DataTypes.GetInt(CustomColor));
|
|
|
|
data.AddRange(DataTypes.GetVarInt(Effects.Count));
|
|
foreach (var effect in Effects)
|
|
data.AddRange(effect.Serialize());
|
|
|
|
return new Queue<byte>(data);
|
|
}
|
|
}
|