Files
Pumpkin/crates
TheDarkSword 207185340a fix: persist item data components dropped on save (#2421)
* fix: persist item data components dropped on save

`DataComponentImpl::write_data` defaults to returning `NbtTag::End`, so any
component relying on that default serialized to nothing. `write_item_stack`
walks the component patch and calls `write_data` on every entry, which meant
those components were silently dropped whenever an item stack was written to
NBT (chests, player inventories, chunk saves). Most of them already had a
deserializer, so the data just vanished on the next save/load.

Implement `write_data` for the data-carrying components that were missing it:
MaxDamage, Enchantable, Food, Tool, BlockEntityData, Container and
BundleContents. For the ones without a deserializer yet (MaxDamage,
Enchantable, Food, Tool) add the matching `read_data` and register them in the
`read_data` dispatcher so they round-trip through write_item_stack/
read_item_stack. The output follows the vanilla NBT shape for each component.

Add round-trip tests for the scalar and compound cases.

* test: use the assert_round_trip helper
2026-08-19 07:39:38 +02:00
..
2026-08-18 14:59:59 +02:00
2026-08-15 16:30:25 +02:00