How to use Minecraft item textures variants in java?

377    Asked by JanFerguson in Java , Asked on Oct 6, 2022

 I remember, maybe two years ago now, that there was a new feature in Minecraft that allowed you to change the texture of an item in a resource pack depending on a certain NBT tag that was set for the item in your inventory.

I think this tag was something like "textureId" but I can't remember? It is not the damage value, but a new NBT property.

Does anyone recall what this is, and how to use it?

Answered by Jan Ferguson

Regarding the Minecraft item textures, you can use the CustomModelData nbt tag. In the .json file of the model you are editing, include one or more override models. Example:


{
  "parent": "item/handheld",
  "textures": {
    "layer0": "item/carrot_on_a_stick"
  },
  "overrides": [
    { "predicate": { "custom_model_data": 1}, "model": "item/carrot_on_a_stick/1" },
    { "predicate": { "custom_model_data": 2}, "model": "item/carrot_on_a_stick/2" }
  ]
}

This is an example where the texture of a carrot on a stick is changed. This is replacing the normal text in the carrot_on_a_stick.json . The models being accessed are in a folder next to carrot_on_a_stick.json called carrot_on_a_stick . The models are respectively called 1.json and 2.json.

You'll probably want to have some knowledge of Minecrafts json modelling. For that, I recommend this site. To give yourself one of the custom-textured items in-game, use /give @s minecraft:{CustomModelData:}.



Your Answer

Interviews

Parent Categories