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

Explanation

The > looks away from the number, this is why it means more.

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!

{
    "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 simplified and a part of Variant Armory by WordSalad & bangetto

Explanation

pull mean Is the bow being pulled [right clicked]. 0 means no, and 1 is yes.

Now pulling is how much the bow is pulled. 0 in this case means not even pulled, and 1 is the fully charged bow.
This example uses the vanilla numbers, but of course you can use different ones.

Recovery Compass

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

{
    "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 simplified and a part of ViaBackwards-Plus by bangetto

Explanation

angle indicates the direction the compas is pointing at.
This example uses the vanilla numbers, but you can make your compass less smooth if you want to.