For an item modifier, using "copy_custom_data" with "op" set to "replace" and "target" set to "{}" (aka the root NBT) will not work at all. No error message is displayed, either.
It works correctly if "op" is set to "merge".
Why this needs to be fixed:
Currently, this is the only way to remove any form of NBT data currently exists in a player.
(by putting the item tag data on a storage, remove it in the storage then using copy_custom_data on said storage to root NBT - it's wonky but it works in theory).
If this is not fixed, please add a way to remove NBT for players directly (which would be alot better). Thanks!
How to reproduce
Run
/data modify storage 236544:test custom_data set value {test:1}
Hold an item in your main hand
Run:
/item modify entity @s weapon {function:copy_custom_data,source:{type:storage,source:"236544:test"},ops:[{source:custom_data,target:"{}",op:replace}]}
Run
/data get entity @s SelectedItem.components."minecraft:custom_data"
β Theminecraft:custom_data
component doesnβt exist on the itemRun the same command as in Step 3, but with the
merge
operation instead ofreplace
:/item modify entity @s weapon {function:copy_custom_data,source:{type:storage,source:"236544:test"},ops:[{source:custom_data,target:"{}",op:merge}]}
Run
/data get entity @s SelectedItem.components."minecraft:custom_data"
β The
minecraft:custom_data
component is now{test:1}
Attachments
Comments 3
I can stil reproduce this in 1.20.5-rc2. I have also uploaded an updated datapack to match the changes in the current data pack format.
Thank you for your report!
We suspect that this does not occur in the latest version of Minecraft.
Is this issue present in the latest version of Minecraft?
This issue is being temporarily resolved as Awaiting Response. Once the requested information has been delivered, the report will be reopened automatically.
Quick Links:
π Bug Tracker Guidelines β π¬ Community Support β π§ Mojang Support (Technical Issues) β π§ Microsoft Support (Account Issues)
π Project Summary β βοΈ Feedback and Suggestions β π Game Wiki
Please attach an example pack, and include a better expected behavior than "it should work"