Minecraft:Data component predicate: Difference between revisions
More actions
Sync: new page from Minecraft |
Sync: updated from Minecraft |
||
| (One intermediate revision by the same user not shown) | |||
| Line 131: | Line 131: | ||
=== potion_contents === | === potion_contents === | ||
Checks | Checks the <code>[[Minecraft:Data component#potion_contents|potion_contents]]</code> data component. | ||
<div class="treeview"> | <div class="treeview"> | ||
* {{nbt|string}}{{nbt|list| | * {{nbt|compound|minecraft:potion_contents}}: | ||
** {{nbt|string}}{{nbt|list|potions}}: Optional. {{json ref|potion type|Potion#Item_data|tag=1}}. If more than one potion type is specified, succeeds when any one of them matches the testing {{nbt|string|potion}} field. | |||
** {{nbt|compound|effects}}: Optional. A collection predicate of {{code|mob_effects}} predicates to match, which follow the same format as the {{code|minecraft:effects}} entity sub-predicate. See [[Minecraft:Predicate#JSON_format|Predicate]]. | |||
*** {{nbt|list|contains}}: Optional. A list of {{code|mob_effects}} predicates to match. | |||
*** {{nbt|list|count}}: Optional. A list of options for matching a specific number of mob effect predicates. | |||
**** {{nbt|compound}} | |||
***** {{nbt|compound|test}}: the {{code|mob_effects}} predicate to match. | |||
***** {{nbt|int}}{{nbt|compound|count}}: the number of matches required, or with min and max will match a range of counts. | |||
****** {{nbt|int|min}}: Optional. | |||
****** {{nbt|int|max}}: Optional. | |||
*** {{nbt|int}}{{nbt|compound|size}}: Optional. Require the mob effects list to have a specific size, or with min and max will match a range of sizes. | |||
**** {{nbt|int|min}}: Optional. | |||
**** {{nbt|int|max}}: Optional. | |||
</div> | </div> | ||
Latest revision as of 11:05, 8 October 2026
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 the potion_contents data component.
- Template:Nbt:
- Template:NbtTemplate:Nbt: Optional. Template:Json ref. If more than one potion type is specified, succeeds when any one of them matches the testing Template:Nbt field.
- Template:Nbt: Optional. A collection predicate of Template:Code predicates to match, which follow the same format as the Template:Code entity sub-predicate. See Predicate.
- Template:Nbt: Optional. A list of Template:Code predicates to match.
- Template:Nbt: Optional. A list of options for matching a specific number of mob effect predicates.
- Template:Nbt
- Template:Nbt: the Template:Code predicate to match.
- Template:NbtTemplate:Nbt: the number of matches required, or with min and max will match a range of counts.
- Template:Nbt: Optional.
- Template:Nbt: Optional.
- Template:Nbt
- Template:NbtTemplate:Nbt: Optional. Require the mob effects list to have a specific size, or with min and max will match a range of sizes.
- Template:Nbt: Optional.
- Template:Nbt: Optional.
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:数据组件谓词