DenizenScript / Denizen

NPC and general Spigot scripting, using the Denizen Scripting Language!
https://denizenscript.com/
MIT License
207 stars 104 forks source link

`ItemTag.custom_data`, `raw_nbt` deprecation #2625

Closed tal5 closed 3 months ago

tal5 commented 3 months ago

Additions

Changes

[!NOTE] custom_data currently removes Denizen data from the value (as it's persisted elsewhere), and adds it back before setting to avoid it getting removed. This seemed like the best way to impl it imo, as you can get/set the data as usual without the limitations raw_nbt had (e.g. not being able to remove keys), and matches how most properties work without risking Denizen data getting messed up, but lmk if you have any alternative ideas.

[!NOTE] Clearing custom_data can probably be optimized a bit more then using the same denizen-key-adding setting custom data uses, but it's a niche enough use case to justify not getting into micro-optimzations (at least right now) imo.

[!NOTE] raw_nbt is back-supported by running old values through the DFU - this is the best way I could find to not have old items being stored just break, which might not be perfect since it only gets partial NBT data, but seems to work well enough and is better than nothing.