mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
Audited batch 5 components (ChargedProjectiles, BundleContents, Container,
WritableBookContent, BlockState, PotDecorations) against official 1.20.6
decompiled STREAM_CODEC definitions. All network encodings were correct.
Removed redundant NumberOfItems/NumberOfPages/NumberOfProperties fields from
ContainerComponent, WritableBlookContentComponent, BlockStateComponent, and
PotDecorationsComponent. Serialize now uses the actual collection .Count
instead of a potentially stale cached value, matching the pattern already
used by ContainerComponent's Serialize and other components.
Also modernized loop style (foreach with deconstruction where applicable)
and fixed a typo in an exception message ("setialize" -> "serialize").
Made-with: Cursor
29 lines
1 KiB
C#
29 lines
1 KiB
C#
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 List<Item?> Items { get; set; } = [];
|
|
|
|
public override void Parse(Queue<byte> data)
|
|
{
|
|
var count = dataTypes.ReadNextVarInt(data);
|
|
for (var i = 0; i < count; i++)
|
|
Items.Add(dataTypes.ReadNextItemSlot(data, ItemPalette));
|
|
}
|
|
|
|
public override Queue<byte> Serialize()
|
|
{
|
|
var data = new List<byte>();
|
|
data.AddRange(DataTypes.GetVarInt(Items.Count));
|
|
foreach (var item in Items)
|
|
data.AddRange(DataTypes.GetItemSlot(item, itemPalette));
|
|
|
|
return new Queue<byte>(data);
|
|
}
|
|
}
|