1

I am trying to make a datapack that uses the started_riding advancement trigger. I need help fleshing out the details of how to make the predicate that I want. I want the advancement to only be given if a player starts riding a horse that has a saddle with a specific enchantment on it (Loyalty).

Summary of work done to figure it out on my own:

I have been able successfully filter for the horse wearing armor with the enchantment as:

"predicate": {
  "vehicle": {
    "type": "minecraft:horse",
    "equipment": {
      "chest": {
        "items": [
          "leather_horse_armor",
          "iron_horse_armor",
          "golden_horse_armor",
          "diamond_horse_armor"
        ],
        "enchantments": [
          {
            "enchantment": "loyalty",
            "levels": 3
          }
        ]
      }
    }
  }
}

but I have not seen a equivalent field to equipment.chest.items that will let me access the saddle item through the criteria interface. So I believe I have to go through nbt tags, but I have not been able to get it to work. My most recent attempts were

"predicate": {
  "vehicle": {
    "type": "horse",
    "nbt": "{SaddleItem:{id:\"saddle\", tag:{Enchantments:[{id:\"loyalty\", lvl:3s}]}}}"
  }
}

I also tried

"nbt": "{\"SaddleItem\":{\"id\":\"saddle\", \"tag\":{\"Enchantments\":[{\"id\":\"loyalty\", \"lvl\":3s}]}}}"

because I am still not clear on the escape quoting rules, but neither of those worked. When I get the horse's SaddleItem data in game (via /data get entity @e[type=horse,sort=nearest,limit=1] SaddleItem) I get this object back:

{
  id:"minecraft:saddle", 
  Count:1b, 
  tag: {
    RepairCost: 1,
    Enchantments: [
      {
        lvl: 3s,
        id: "minecraft:loyalty"
      }
    ]
  }
}

and that seems to mirror what I was inputting as the nbt data so I'm not sure where to go from there. I did also try adding in the Count and RepairCost fields but that didn't seem to help and I think I shouldn't need to?

Any guidance on how to form the started_riding predicate to select for a horse wearing a loyalty-enchanted saddle is greatly appreciated.

1 Answer 1

2

Seems that I was missing the minecraft: namespace identifier before the saddle and loyalty id fields. It seems like specifying the default minecraft namespace is not necessary for advancement fields but is for nbt tags.

A functioning nbt predicate to detect the enchanted saddle is:

"nbt": "{SaddleItem:{id:\"minecraft:saddle\", tag:{Enchantments:[{id:\"minecraft:loyalty\", lvl:3s}]}}}"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.