Unhandled item components persistence
Additions
-
ItemHelper#get/setRawComponents- gets/sets an item's components patch in Denizen NBT map format. -
ItemRawComponentsproperty - handles the property logic itself & filtering the components for handled values. -
ItemRawComponents.PerIdPropertyDataRemoversub-class - util for properties with map values where specific keys need to be removed for different ids (e.g. different types of block entities needing different data keys removed).
Changes
- All item properties in
PropertyRegistryare now registered with the newPropertyRegistry#registerItemPropertyand specify their internal component (or have a comment detailing their special case handling). -
Unrelated: small meta fix in
ItemColorbecause I saw it along the way.
[!NOTE] Some specific components have special handling directly in
ItemRawComponents(due to things like needing to remove specific map keys instead of the whole component), it's technically possible to make a fancier registration system so that no "hard-coded" logic is required, but since it's just a few components and there's a bunch of other 1.21 work, decided to go with this (at least for now).
[!NOTE] The component keys in the map currently don't have the
minecraft:namespace removal, but I think in this case it's fine/makes sense, seeing as the data within the map doesn't have it either, and it's meant to be a raw/direct representation of the item's data, so nice-ifying it doesn't make that much sense.
[!NOTE] Not sure if
raw_componentsis the best name? technically this is the item's component patch, so might conflict if we want to add something for the item's actual raw components in the future - not sure what would be a good name though,ItemTag.components_patch?ItemTag.raw_changed_components?
[!NOTE] For components where only specific parts need to be removed (e.g. only some entity data being handled by properties), it currently only removes them if the all the data can be removed, as there isn't any merging logic - this generally isn't a big issue as in most cases all the data can be handled by properties, but can make slightly messy looking items in some cases. Let me know if you think it's worth it trying to make some sort of merging logic.