mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
In 1.20.6+, ComponentSerialization.STREAM_CODEC uses ByteBufCodecs.fromCodecWithRegistries (NBT tag format), not plain string. The previous implementation incorrectly used ReadNextString/GetString for custom_name (5), item_name (6), and lore (7) components. Fixed all three to use ReadNextNbt/GetNbt, preserving raw NBT data for round-trip serialization while still extracting readable text via ChatParser.ParseText(Dictionary). Other batch 4 components (custom_data, entity_data, bucket_entity_data, block_entity_data, debug_stick_state, map_decorations, recipes, lock, container_loot, intangible_projectile — all NBT; hide_additional_tooltip, hide_tooltip, fire_resistant, creative_slot_lock — all Unit/Empty; note_block_sound — ResourceLocation string) were verified correct. Made-with: Cursor
26 lines
No EOL
963 B
C#
26 lines
No EOL
963 B
C#
using System.Collections.Generic;
|
|
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 CustomNameComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry)
|
|
: StructuredComponent(dataTypes, itemPalette, subComponentRegistry)
|
|
{
|
|
public string CustomName { get; set; } = string.Empty;
|
|
public Dictionary<string, object>? CustomNameNbt { get; set; }
|
|
|
|
public override void Parse(Queue<byte> data)
|
|
{
|
|
CustomNameNbt = dataTypes.ReadNextNbt(data);
|
|
CustomName = ChatParser.ParseText(CustomNameNbt);
|
|
}
|
|
|
|
public override Queue<byte> Serialize()
|
|
{
|
|
var data = new List<byte>();
|
|
data.AddRange(DataTypes.GetNbt(CustomNameNbt));
|
|
return new Queue<byte>(data);
|
|
}
|
|
} |