Skip to content
bangetto edited this page Jan 5, 2024 · 19 revisions

Predicates can be in two places, in the model file or in the assets/minecraft/overrides folder, but in most cases it's recommended to use the second one, mainly for better organization and because that it makes your pack more compatible with other packs. Item predicates goes to .../item/<item_id.json> and armor goes to .../armor/<armormaterial_layer.json>. Now let's look at some examples!

La Baguette

This file is the overrides/item/bread.json, and replaces the bread model with the la_baguette model when it named La Baguette.

{
    "overrides": [
        {
          "predicate": {
            "name": "La Baguette"
          },
          "model": "example:la_baguette"
        }
    ]
}

Example is from ViaBackwards-Plus as an Easter egg by bangetto

Explanation

overrides is the opening tag. It tells Minecraft that the model can be changed.

predicate contains the conditions that all have to be met for a predicate to be true.

name is a condition. It detects the name of the item.

model if the predicate before it is true, the item will change to that model.

Broadsword

Names also can have regex like formatting.

{
"overrides": [
    {
        "predicate": {
            "name": "/(?i)(.)*broadsword(.)*/"
        },
        "model": "item/diamond_broadsword"
    }
]
}

Example is from Variant Armory by WordSalad & bangetto

Explanation

The / at the start and end says to Chime that this is a regex string.

(?i) means that the string is not case-sensitive, which means that even something like BrOaDsWorD will be detected too.

(.)* indicates that there can be other words around it, so it would even detect something like Mine Broadsword, Nobody can touch it.

Crown

You can override armor too!

This is file here is overrides/armor/gold_layer_1.json which predicate the name, and it's important to remember that armor is on 2 separate layers. 1 for the helmet and chest plate and 2 for the leggings and boots.

{
    "overrides": [
        {
            "predicate": {
                "name": "Crown"
            },
            "texture": "easteregg:textures/crown-layer"
        }
    ]
}

Example is from ViaBackwards-Plus as an Easter egg by bangetto

Arrow Quiver

You can also detect the count of the items

In this example if there's 16 or more arrows in one stack than it gone a change the model to the minecraft:item/arrow_quiver

{
  "overrides": [
    {
      "predicate": {
        "count": ">=16"
      },
      "model": "minecraft:item/arrow_quiver"
    }
  ]
}

Example is from Stellar Tweaks by Stardust

NBT

Same id, but different NBT thingy!

Painting Previews

This is overrides/item/painting.json, here we check the NBT data of the painting to predicate which painting it is. If you want to do NBT based predictions I recommend using a mod like NBT Tooltip, but you can make really cool packs considering that a lot of Items in Minecraft are almost the same just with a diferent NBT data.

{
    "overrides": [
        {
            "predicate": {
                "nbt": {
                    "EntityTag": {
                      "variant": "minecraft:burning_skull"
                    }
                  }
            },
            "model": "item/paint/burning_skull"
        }
  ]
}

Example is a part of What Painting I'm Looking At? by bangetto

Baby Axolotl in a Bucket

With the NBT we can detect the axolotl age, so if we want to detect that is that a baby we can use this code.

{
  "overrides": [
    {
      "predicate": {
        "nbt": {
          "Age": "<0"
          }
        },
      "model": "item/axolotl_bucket/axolotl_bucket_b"
    }
  ]
}

Example is a simplified part of Stellar Tweaks by Stardust

Longbow

It's a bit more difficult to add predicates for sub-models (like pullings of a bow), but let's walk trough it!

At the first predicate we specify that the "pulling" has to be 0 which in most programing languages is the equivalent of false, so the second prediction where we set it to 1 (aka.: true) Chime works as we want. BUT, we don't done yet, because the pulling of the bow isn't one stage, it's 3, so at the next to we also need to set the "pull" to 0.65 and 0.9 if we want to stick to the vanilla like bow pulling, but you can set this to different values so you can create a smoother bow animation if you want!

{
    "overrides": [
        {
            "predicate": {
                "pulling": 0,
                "name": "longbow"
            },
            "model": "item/longbow"
        },
        {
            "predicate": {
                "pulling": 1,
                "name": "longbow"
            },
            "model": "item/longbow_pulling_0"
        },
        {
            "predicate": {
                "pulling": 1,
                "pull": 0.65,
                "name": "longbow"
            },
            "model": "item/longbow_pulling_1"
        },
        {
            "predicate": {
                "pulling": 1,
                "pull": 0.9,
                "name": "longbow"
            },
            "model": "item/longbow_pulling_2"
        }
    ]
}

Example is a simplified part of Variant Armory by WordSalad & bangetto

Recovery Compass

The compass is bit more difficult than the bow, because it has more sub-models.

For this to work we need to specify every angle of the compass, at least if we want a smooth compass, we can also put one predicate per line if we want, so we doesn't have a that long file, but it's less clean and less readable.

{
    "overrides": [
      { 
        "predicate": 
        { 
          "angle": 0.000000, 
          "name": "example"
        }, 
        "model": "item/recovery_compass"
      },
      { "predicate": { "angle": 0.015625, "name": "example" }, "model": "item/recovery_compass_17" },
      { "predicate": { "angle": 0.046875, "name": "example" }, "model": "item/recovery_compass_18" },
      { "predicate": { "angle": 0.078125, "name": "example" }, "model": "item/recovery_compass_19" },
      { "predicate": { "angle": 0.109375, "name": "example" }, "model": "item/recovery_compass_20" },
      { "predicate": { "angle": 0.140625, "name": "example" }, "model": "item/recovery_compass_21" },
      { "predicate": { "angle": 0.171875, "name": "example" }, "model": "item/recovery_compass_22" },
      { "predicate": { "angle": 0.203125, "name": "example" }, "model": "item/recovery_compass_23" },
      { "predicate": { "angle": 0.234375, "name": "example" }, "model": "item/recovery_compass_24" },
      { "predicate": { "angle": 0.265625, "name": "example" }, "model": "item/recovery_compass_25" },
      { "predicate": { "angle": 0.296875, "name": "example" }, "model": "item/recovery_compass_26" },
      { "predicate": { "angle": 0.328125, "name": "example" }, "model": "item/recovery_compass_27" },
      { "predicate": { "angle": 0.359375, "name": "example" }, "model": "item/recovery_compass_28" },
      { "predicate": { "angle": 0.390625, "name": "example" }, "model": "item/recovery_compass_29" },
      { "predicate": { "angle": 0.421875, "name": "example" }, "model": "item/recovery_compass_30" },
      { "predicate": { "angle": 0.453125, "name": "example" }, "model": "item/recovery_compass_31" },
      { "predicate": { "angle": 0.484375, "name": "example" }, "model": "item/recovery_compass_00" },
      { "predicate": { "angle": 0.515625, "name": "example" }, "model": "item/recovery_compass_01" },
      { "predicate": { "angle": 0.546875, "name": "example" }, "model": "item/recovery_compass_02" },
      { "predicate": { "angle": 0.578125, "name": "example" }, "model": "item/recovery_compass_03" },
      { "predicate": { "angle": 0.609375, "name": "example" }, "model": "item/recovery_compass_04" },
      { "predicate": { "angle": 0.640625, "name": "example" }, "model": "item/recovery_compass_05" },
      { "predicate": { "angle": 0.671875, "name": "example" }, "model": "item/recovery_compass_06" },
      { "predicate": { "angle": 0.703125, "name": "example" }, "model": "item/recovery_compass_07" },
      { "predicate": { "angle": 0.734375, "name": "example" }, "model": "item/recovery_compass_08" },
      { "predicate": { "angle": 0.765625, "name": "example" }, "model": "item/recovery_compass_09" },
      { "predicate": { "angle": 0.796875, "name": "example" }, "model": "item/recovery_compass_10" },
      { "predicate": { "angle": 0.828125, "name": "example" }, "model": "item/recovery_compass_11" },
      { "predicate": { "angle": 0.859375, "name": "example" }, "model": "item/recovery_compass_12" },
      { "predicate": { "angle": 0.890625, "name": "example" }, "model": "item/recovery_compass_13" },
      { "predicate": { "angle": 0.921875, "name": "example" }, "model": "item/recovery_compass_14" },
      { "predicate": { "angle": 0.953125, "name": "example" }, "model": "item/recovery_compass_15" },
      { "predicate": { "angle": 0.984375, "name": "example" }, "model": "item/recovery_compass" }
    ]
}

Example is a simplified part of ViaBackwards-Plus by bangetto

Clone this wiki locally