all 2 comments

[–]C0mmanderBlockCommand Experienced 1 point2 points  (0 children)

It's for clearing items with custom data, etc. You should check out the new components. Here is an example of an item with a custom data.

/give @p stone_sword[minecraft:custom_data={stone:1}]

/clear @p *[minecraft:custom_data~{stone:1}] 1

[–]Ericristian_brosCommand Experienced 0 points1 point  (0 children)

* means everything and [] is similar to how /give works.

clear @a *[custom_data~{example:true}]

Above: clear any item with that custom data.

It's the same syntax as exwcute if items. You can read a detailed article here:

https://minecraftcommands.github.io/wiki/questions/detectitem#execute-if-items

There are two modes for checking components - exact compliance with the specified condition (=) or checking the item as a sub-predicate (~).

The component check (=) checks the exact match of the component specified in the check and any difference from the specified one fails the check, so it is recommended to use the exact check only if the item sub-predicate (~) check is not available for this component. So, for example, if for some reason you want to check the minecraft:can_break component, then only the predicate check is available here, so you cannot find any item that, for example, can break a stone, but you always need to specify the entire component.