#2 data components in item definition

1 messages · Page 1 of 1 (latest)

sharp dagger
#

so I have this item definition

{
  "model": {
    "type": "minecraft:select",
    "property": "minecraft:component",
    "component": "minecraft:custom_data",
    "cases": [
      {
        "when": {
          "dagger": true
        },
        "model": {
          "type": "minecraft:select",
          "property": "minecraft:component",
          "component": "minecraft:custom_data",
          "cases": [
            {
              "when": {
                "used": true
              },
              "model": {
                "type": "minecraft:model",
                "model": "cults:item/used_dagger"
              }
            }
          ],
          "fallback": {
            "type": "minecraft:model",
            "model": "cults:item/dagger"
          }
        }
      }
    ],
    "fallback": {
      "type": "minecraft:model",
      "model": "minecraft:item/iron_sword"
    }
  }
}

that's supposed to have a different model when the sword has custom data dagger and another one when it also has used
give @s iron_sword[minecraft:custom_data={"dagger":true}] has the correct model but
give @s iron_sword[minecraft:custom_data={"dagger":true,"used":true}] just has the default

last pilot
jagged bluff
#

the component property type under select uses the direct component check, which means it will only show your model if the component exactly matches the item. you can use a predicate test with the condition model type for a predicate test on custom_data, but that starts to require awkward nesting
so i would generally instead recommend also adding custom_model_data and using the bespoke select property that exists for that component

#

(although for your case, condition might still be more than sufficient. just two layers necessary)