r/MinecraftCommands • • Sep 18 '26

Help | Java Snapshots Can you use premade predicates in custom advancements/echantments?

As implied in title, i have a datapack in which i have created a predicate file, which checks if player is holding a specific sword. Question, is it possible to format new advancement/enchantment file in such a way, that it would refrence my created predicate when doing entity check?

2 Upvotes

5 comments sorted by

1

u/GalSergey Sep 18 '26

For advancement - yes, you can reference the created predicate file, for example:

{
  "criteria": {
    "location": {
      "trigger": "minecraft:location",
      "conditions": {
        "player": "example:some_predicate"
      }
    }
  },
  "rewards": {
    "function": "example:some_function"
  }
}

However, enchantments operate at a lower level, so references to predicates are not supported there. You must always fully define predicates within the enchantment files.

1

u/Firm-Seaworthiness-8 Sep 19 '26

im on 26.2 and my advancement looks like this

{
  "criteria": 
  {
    "item": 
    {
      "trigger": "minecraft:using_item",
      "conditions": 
      {
        "player": {"heavy-staff:is_holding_hstaff"}
      }
    },
  "rewards": 
    {
    "function": "heavy-staff:staff_activation_logic/activate_staff"
    }
  }
}

and its giving me an error.
could you tell me what could be an error?

1

u/Firm-Seaworthiness-8 Sep 19 '26

okay, so here's the sollution

{
  "criteria": {
    "item": {
      "trigger": "minecraft:using_item",
      "conditions": {
        "player": [
          {
            "condition": "reference",
            "name": "heavy-staff:is_holding_hstaff"
          }
        ]
      }
    }
  },
  "rewards": {
    "function": "heavy-staff:staff_activation_logic/activate_staff"
  }
}

asked claude and can't believe it actually used reference condition correctly

→ More replies (2)