Components Requirement
Last updated
Last updated
This is essentially the 1.21+ version of an NBT requirement, which checks an item's . It also has similar quality-of-life improvements over Vanilla's system, but has some limitations due to the inflexibility of data components.
These custom functions can be used to evaluate the component itself, but not any data inside the component.
cs:any_of
Checks the target NBT against a list of provided values, passing if any of the values match. This is done by specifying a compound tag, with the only key being "cs:any_of
" and its value being the list of options.
Example:
This translates to:
If the item's rarity is either rare or epic, the check will pass. This is a very useful alternative to defining multiple possible component checks for the same thing.
It is also possible to define a range of accepted values if the tag being checked is a number.
Example:
Checks if an item's damage is somewhere between 50 and 100. Note that ranges are represented by a string value of two numbers separated by a hyphen ( - ). Decimal values are also accepted.