#tilda rather than equal

1 messages · Page 1 of 1 (latest)

timber patio
#

Why is this a tilda rather than an equal (I'm exploring a friend's datapack)

shrewd orbit
#

= does exact match
~ does performs a item sub-predicate data component predicate

#
Minecraft Wiki

Data component predicates (historically known as item sub-predicates) are used to check conditions about data components. They are used in minecraft:item_predicate argument type, item modifiers, loot predicates, advancement criteria, and entity and block predicates. They return a pass or fail result to the invoker, who acts differently based on ...

short brook
#

the = checks for an exact match. This means that it will fail if your item's custom data contains {gui_chest:1b,another_key:1b} because that contains one more key. That's why we use ~ which only checks if all keys specified match which in this case is just gui_chest

shrewd orbit
#

There are other cases where the ~ can do even more powerful checks, like counting the number of diamonds in a shulkerbox etc.

timber patio
#

thanks