summary
"!" operator used outside of the root components field displays inconsistent behavior with its use in the root components field
steps to reproduce
1. run command:
/give @s amethyst_shard[custom_data={"some_custom_data":{}}]
2. hold the amethyst shard in your main hand
3. run command:
/item modify entity @s weapon.mainhand [{"function":"minecraft:set_components","components":{"minecraft:custom_data":{"!some_custom_data":{}}}}]
4. run command:
/data get entity @s SelectedItem
expected result
item's "custom data" field should either:
be empty, if "!" operator is permitted inside of another component
contain both "some_custom_data" and "!some_custom_data" if operator is not permitted inside of another component
actual result
item's "custom data" field contains only "!some_custom_data", as if the relevant tag were removed, but the tag signalling to remove that tag were also added.
Attachments
Comments 4
Thank you for your report!
After consideration, the issue is being closed as Invalid.
This report does not describe a bug.
Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support (Technical Issues) – 📧 Microsoft Support (Account Issues)
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki
There's nothing wrong here. You're telling it to set (i.e. replace) the component to the new contents, and it's setting it to exactly what you specified.
I see. In that case, I believe that I was getting confused by an inconsistency in the naming of item modifier functions? Because the `set_custom_data` function (which I had been attempting to use before trying a different route with `set_components`) merges into the custom_data component. Seeing this explanation, I can see this difference in behavior; The following item modifier will produce both the "some_custom_data" and "!some_custom_data" tags:
[{"function":"minecraft:set_custom_data","tag":{"!some_custom_data":{}}}]
Perhaps something like having separate `set_...` and `merge_...` variants of both functions would be less confusing, but that seems more fitting for the Minecraft Suggestions page than a bug report.
Thank you for the response!
Can confirm: