mojira.dev
MC-270707

All fields seem to be required when checking components in predicates or advancements

I was working on an advancement trigger which is meant to trigger upon obtaining any item that has been trimmed with the amethyst material.

 

"amethyst": {
            "trigger": "minecraft:inventory_changed",
            "conditions": {
                "items": [
                    {
                        "components": {
                            "minecraft:trim": {
                                "material": "minecraft:amethyst"
                            }
                        }
                    }
                ]
            }
        }

However, this error message appears in the output log

 

 

Parsing error loading custom advancement minecraft:test_without_pattern: No key pattern in MapLike[{"material":"minecraft:amethyst"}] missed input: {"minecraft:trim":{"material":"minecraft:amethyst"}} missed input: {"amethyst":{"trigger":"minecraft:inventory_changed","conditions":{"items":[{"components":{"minecraft:trim":{"material":"minecraft:amethyst"}}}]}}}

 

I have also noticed similar behaviour when working with the charged_projectiles component, and this other bug report highlights it may also be affecting the lodestone_tracker pos.

MC-270041

 

This leads me to believe that with components in advancements and predicates, all components have to be specified.

 

This is not intended behaviour. I refer to the official article on snapshot 24w09a, which states with regard to predicate formats:

  • All specified components must be present an exactly equal on the target item, but additional components may be ignored

 

I have uploaded a datapack which can be used to test this out. Steps to reproduce:

1) Install the datapack on a creative world

2) Use a smithing table to apply a trim with pattern tide and material amethyst to any armor item, or use this command:

/give @s diamond_helmet[minecraft:trim={material:amethyst,pattern:tide}]

3) The advancement "Test with pattern" will be obtained, but there is a second advancement in the datapack, "Test without pattern" that does not check for the pattern and is meant to trigger upon obtaining an item with amethyst material but the pattern does not matter. This advancement will not appear at all and will cause the above error in the output log.

 

Linked issues

Attachments

Comments 4

This is intended, you need to use predicates instead of components to use subpredicate matches

Here's the working code:

{
  "criteria": {
    "amethyst": {
      "trigger": "minecraft:inventory_changed",
      "conditions": {
        "items": [
          {
            "predicates": {
              "minecraft:trim": {
                "material": "minecraft:amethyst"
              }
            }
          }
        ]
      }
    }
  }
}

Note: Not all components currently have an applicable subpredicate. For example, lodestone compasses don't have one; see MC-270041.

Cavinator1

(Unassigned)

Unconfirmed

(Unassigned)

1.20.5 Pre-Release 1

Retrieved