Minecraft:Data component predicate
More actions
Template:Exclusive
Data component predicates (historically known as item sub-predicates) are used to check conditions about Minecraft:data components. They are used in minecraft:item_predicate argument type, Minecraft:item modifiers, loot predicates, advancement criteria, and entity and block Minecraft:predicates. They return a pass or fail result to the invoker, who acts differently based on this result.
List of data component predicate types
| ID | Data type and format | Minecraft:Data components to check |
|---|---|---|
| attribute_modifiers | Template:Nbt, see below | attribute_modifiers
|
| bundle_contents | Template:Nbt, see below | bundle_contents
|
| container | Template:Nbt, see below | container
|
| custom_data | Template:Nbt or Template:Nbt, see below | custom_data
|
| damage | Template:Nbt, see below | damage and max_damage
|
| enchantments | Template:Nbt, see below | enchantments
|
| firework_explosion | Template:Nbt, see below | firework_explosion
|
| fireworks | Template:Nbt, see below | fireworks
|
| jukebox_playable | Template:Nbt,see below | jukebox_playable
|
| potion_contents | Template:Nbt or Template:Nbt, see below | potion_contents
|
| stored_enchantments | Template:Nbt, see below | stored_enchantments
|
| trim | Template:Nbt, see below | trim
|
| writable_book_content | Template:Nbt, see below | writable_book_content
|
| written_book_content | Template:Nbt, see below | written_book_content
|
Formats
attribute_modifiers
Checks modifiers in the attribute_modifiers data component.
- Template:Nbt
- Template:Nbt: (Optional) A collection predicate of Minecraft:attribute modifier.
bundle_contents
Checks item stacks in the bundle_contents data component.
- Template:Nbt
- Template:Nbt: (Optional) A collection predicate of item stack.
container
Checks item stacks in the container data component.
- Template:Nbt
- Template:Nbt: (Optional) A collection predicate of item stack.
custom_data
Checks custom_data data component. See Template:Slink and Template:Slink.
Either as a JSON object or an NBT compound tag, or a string. If a string, it is resolved into an NBT compound tag.
damage
Checks remaining durability or damage value. Damage value is from the damage data component; remaining durability is the value max_damage data component minus damage value.
- Template:Nbt
- Template:Nbt: (Optional) Checks damage value. Matches an exact Template:Nbtvalue, or checks if the value is between a range.
- Template:Nbt: (Optional) Another format.
- Template:Nbt: (Optional) The maximum value.
- Template:Nbt: (Optional) The minimum value.
- Template:Nbt: (Optional) Checks remaining durability. Matches an exact Template:Nbtvalue, or checks if the value is between a range.
- Template:Nbt: (Optional) Another format.
- Template:Nbt: (Optional) The maximum value.
- Template:Nbt: (Optional) The minimum value.
enchantments
Checks enchantments on the item (enchantments in the enchantments data component).
- Template:Nbt: Array of conditions. The sub-predicate succeeds when all the conditions succeed.
- Template:Nbt: A condition.
- Template:NbtTemplate:Nbt: (Optional) Template:Json ref/enchantment. If more than one enchantment is specified, succeeds when any one of them is present.
- Template:Nbt: (Optional) Checks the level of the specified enchantment. Matches an exact Template:Nbtvalue, or checks if the value is between a range. If more than one enchantment is specified, succeeds when any one of them matches the level. If Template:NbtTemplate:Nbt is not specified, succeeds when any one of enchantments on the item matches the level.
- Template:Nbt: (Optional) Another format.
- Template:Nbt: (Optional) The maximum value.
- Template:Nbt: (Optional) The minimum value.
- Template:Nbt: A condition.
firework_explosion
Checks the firework_explosion data component.
fireworks
Checks explosion effects in the fireworks data component.
- Template:Nbt
- Template:Nbt: (Optional) A collection predicate of explosion effect.
- Template:Nbt: (Optional) Checks the flight duration of this firework rocket, i.e. the number of gunpowders used to craft it. Matches an exact Template:Nbtvalue, or checks if the value is between a range.
- Template:Nbt: (Optional) Another format.
- Template:Nbt: (Optional) The maximum value.
- Template:Nbt: (Optional) The minimum value.
jukebox_playable
Checks jukebox song in the jukebox_playable data component.
- Template:Nbt
- Template:NbtTemplate:Nbt: (Optional) Template:Json ref. If more than one jukebox song is specified, succeeds when any one of them matches the testing song.
potion_contents
Checks Template:Nbt field in the potion_contents data component. Fails if there is no Template:Nbt field in the component.
- Template:NbtTemplate:Nbt: Template:Json ref. If more than one potion type is specified, succeeds when any one of them matches the testing Template:Nbt field.
stored_enchantments
Checks enchantments on an enchanted book (enchantments in the stored_enchantments data component).
- Template:Nbt: Array of conditions. The sub-predicate successes when all the conditions succeed.
- Template:Nbt: A condition.
- Template:NbtTemplate:Nbt: (Optional) Template:Json ref/enchantment. If more than one enchantment is specified, succeeds when any one of them is present.
- Template:Nbt: (Optional) Checks the level of the specified enchantment. Matches an exact Template:Nbtvalue, or checks if the value is between a range. If more than one enchantment is specified, succeeds when any one of them matches the level. If Template:NbtTemplate:Nbt is not specified, succeeds when any one of enchantments on the item matches the level.
- Template:Nbt: (Optional) Another format.
- Template:Nbt: (Optional) The maximum value.
- Template:Nbt: (Optional) The minimum value.
- Template:Nbt: A condition.
trim
Checks the trim data component.
- Template:Nbt
- Template:NbtTemplate:Nbt: (Optional) Template:Json ref If more than one trim material is specified, succeeds when any one of them matches the testing trim material.
- Template:NbtTemplate:Nbt: (Optional) Template:Json ref If more than one trim pattern is specified, succeeds when any one of them matches the testing trim pattern.
writable_book_content
Checks pages in the writable_book_content data component. Raw texts are checked instead of filtered texts.
- Template:Nbt
- Template:Nbt: (Optional) A collection predicate of page.
written_book_content
Checks written_book_content data component.
- Template:Nbt
- Template:Nbt: (Optional) A collection predicate of page. Checks the raw texts of pages instead of filtered texts.
- Template:Nbt: (Optional) Matches the full string of author.
- Template:Nbt: (Optional) Matches the full string of title. Checks raw title instead of filtered title.
- Template:Nbt: (Optional) Checks the number of times this written book has been copied. 0 = original, 1 = copy of original, 2 = copy of copy, 3 = tattered. Matches an exact Template:Nbtvalue, or checks if the value is between a range.
- Template:Nbt: (Optional) Another format.
- Template:Nbt: (Optional) The maximum value.
- Template:Nbt: (Optional) The minimum value.
- Template:Nbt: (Optional) Checks whether the JSON text components have already been resolved (the Template:Nbt field in the data component is
true).
History
Template:Navbox Java Edition technical
Minecraft:de:Gegenstands-Unterprädikate Minecraft:fr:Prédicat de composant de données Minecraft:ja:データコンポーネントプレディケート Minecraft:pt:Predicado de componente de dado Minecraft:zh:数据组件谓词