Minecraft-Console-Client/MinecraftClient/Inventory
BruceChen a36ba23ba6 fix: StructuredComponents batch 1 audit — TrimComponent, ProfileComponent, WrittenBookContent, and NBT serialization
Audited all 8 high-complexity structured components against official 1.20.6
decompiled STREAM_CODEC definitions. Found and fixed bugs in 3 components
plus a systemic NBT serialization issue:

TrimComponent (ID 35):
- Serialize had TrimPatternType and ShowInTooltip incorrectly nested inside
  the TrimMaterialType==0 branch; moved them outside to match Parse logic
- Description fields (TrimMaterial.description, TrimPattern.description) were
  read/written as String but official codec uses ComponentSerialization
  (NBT Tag format); changed to ReadNextNbt/GetNbt

ProfileComponent (ID 46):
- Serialize was missing the HasUniqueId Bool prefix before UUID
- Serialize only wrote properties when count > 0 but omitted the VarInt count
  prefix entirely when empty; now always writes VarInt count

WrittenBookContentComponent (ID 34):
- Page content uses Filterable<Component> where Component is NBT-encoded via
  ComponentSerialization.STREAM_CODEC, not plain String; changed Parse to use
  ReadNextNbt and Serialize to use GetNbt
- Added RawContentNbt/FilteredContentNbt fields to BookPage record for
  round-trip NBT preservation
- Removed unnecessary ChatParser.ParseText on title (it's a plain string)

DataTypes.GetNbt:
- Added TAG_String root support for 1.20.4+ (chat components like "Page 1"
  are encoded as TAG_String, not TAG_Compound)
- Fixed root name handling: versions >= 1.20.2 omit the root compound name,
  but GetNbt was unconditionally writing it

Components confirmed correct (no changes needed):
- FoodComponentComponent (ID 20), ToolComponent (ID 22),
  InstrumentComponent (ID 40), PotionContentsComponent (ID 31),
  AttributeModifiersComponent (ID 12)

Made-with: Cursor
2026-03-20 00:09:05 +08:00
..
ItemPalettes Inventory, Terrain and Entity handling 2024-07-02 11:08:46 +02:00
BookPage.cs fix: StructuredComponents batch 1 audit — TrimComponent, ProfileComponent, WrittenBookContent, and NBT serialization 2026-03-20 00:09:05 +08:00
Container.cs Added enchanting 2022-10-12 19:51:01 +02:00
ContainerExtensions.cs Added slab handling for 1.20/.1 2023-06-23 16:25:18 +02:00
ContainerType.cs Fix all warnings & Trim (#2226) 2022-10-02 18:31:08 +08:00
ContainerTypeExtensions.cs Crowdin localization support (#2310) 2022-10-28 11:13:20 +08:00
Effects.cs [SKIP_BUILD] Change file encoding to UTF-8 with BOM 2022-11-28 13:55:05 +08:00
Enchantment.cs WIP: Added some strctured components 2024-09-11 19:12:31 +02:00
EnchantmentData.cs WIP: Added some strctured components 2024-09-11 19:12:31 +02:00
EnchantmentMapping.cs Fix enchantment name display for 1.20.6 structured components 2026-03-19 02:01:15 +08:00
EnchantmentPropertyInfo.cs Added enchanting 2022-10-12 19:51:01 +02:00
Enchantments.cs Fix enchantment name display for 1.20.6 structured components 2026-03-19 02:01:15 +08:00
Hand.cs [SKIP_BUILD] Change file encoding to UTF-8 with BOM 2022-11-28 13:55:05 +08:00
Item.cs Wire up 1.20.6 structured components to Item and fix GetItemSlot serialization 2026-03-19 00:34:10 +08:00
ItemMovingHelper.cs Implement command completion suggestions. 2022-12-06 15:50:17 +08:00
ItemRarity.cs WIP: Added some strctured components 2024-09-11 19:12:31 +02:00
ItemType.cs Inventory, Terrain and Entity handling 2024-07-02 11:08:46 +02:00
ItemTypeExtensions.cs Fix all warnings & Trim (#2226) 2022-10-02 18:31:08 +08:00
SuspiciousStewEffect.cs Added more structured components 2024-09-11 20:58:24 +02:00
TrimAssetOverride.cs Implemented all structured components, renamed them all to a better format 2024-10-05 13:37:52 +02:00
VillagerInfo.cs Implement command completion suggestions. 2022-12-06 15:50:17 +08:00
VillagerTrade.cs Fix all warnings & Trim (#2226) 2022-10-02 18:31:08 +08:00
WindowActionType.cs Added ShiftRightClick (#2582) 2023-09-16 19:39:55 +08:00