Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Minecraft:Data component predicate: Difference between revisions

From SAS Gaming Wiki
SyncBot (talk | contribs)
Sync: new page from Minecraft
 
SyncBot (talk | contribs)
Sync: updated from Minecraft
Line 131: Line 131:


=== potion_contents ===
=== potion_contents ===
Checks {{nbt|string|potion}} field in the <code>[[Minecraft:Data component#potion_contents|potion_contents]]</code> data component. Fails if there is no {{nbt|string|potion}} field in the component.
Checks the <code>[[Minecraft:Data component#potion_contents|potion_contents]]</code> data component.


<div class="treeview">
<div class="treeview">
* {{nbt|string}}{{nbt|list|minecraft:potion_contents}}: {{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|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. The {{code|mob_effects}} predicate format is a mapping of effect types to properties of that effect. All fields are optional, only provided fields will be used for matching:
</div>
</div>
Example of the {{code|effects}} field matching on several different effects and criteria:
      "effects": {
        "minecraft:jump_boost": {
          "duration": 3600,
          "amplifier": 5,
          "ambient": true,
          "visible": true
        },
        "minecraft:speed": {
          "duration": {
            "min": 360,
            "max": 3600
          },
          "amplifier": {
            "min": 2
          }
        },
        "minecraft:resistance": {}
      }


=== stored_enchantments ===
=== stored_enchantments ===

Revision as of 11:09, 7 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.

bundle_contents

Checks item stacks in the bundle_contents data component.

container

Checks item stacks in the container data component.

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.

enchantments

Checks enchantments on the item (enchantments in the enchantments data component).

firework_explosion

Checks the firework_explosion data component.

fireworks

Checks explosion effects in the fireworks data component.

jukebox_playable

Checks jukebox song in the jukebox_playable data component.

potion_contents

Checks the potion_contents data component.

Example of the Template:Code field matching on several different effects and criteria:

     "effects": {
       "minecraft:jump_boost": {
         "duration": 3600,
         "amplifier": 5,
         "ambient": true,
         "visible": true
       },
       "minecraft:speed": {
         "duration": {
           "min": 360,
           "max": 3600
         },
         "amplifier": {
           "min": 2
         }
       },
       "minecraft:resistance": {}
     }

stored_enchantments

Checks enchantments on an enchanted book (enchantments in the stored_enchantments data component).

trim

Checks the trim data component.

writable_book_content

Checks pages in the writable_book_content data component. Raw texts are checked instead of filtered texts.

written_book_content

Checks written_book_content data component.

History

Template:HistoryTable

Navigation

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:数据组件谓词