80

Custom Model Data tutorial + example pack - Changing the model of an item

Geegaz10/27/18 8:12 am history
80 emeralds 236.4k 148
11/3/2021 11:18 am
IMK011
Hello, I'm Geegaz !

As you may know, the first snapshots of the 1.14 introduced a new format for the JSON item models : "custom_model_data". It's also a new NBT tag you can use on an item with the format {CustomModelData:<data here>}.
Here's a guide/tutorial on how to use it.


This tutorial is not meant for basic ressource pack creation as it touches JSON format.


NBT tag :

The Custom Model Data is a NBT tag that can be added to an item. We will use the iron_ingot as an example.
It's very simple to use as it is not different from any other NBT tag.

Note :
- The data doesn't take commas, if you add them the command won't give an error but will not work.

/give @s minecraft:iron_ingot{CustomModelData:1234567}

JSON format :

To the command above to work, the item needs its JSON format to be defined.
The code below shows how it works.
We use "overrides":{"predicate":{}} to define in which case we'll override the item's model with our custom model or, in this case, the gold_ingot's model.
Here, we wil override it if the item has a CustomModelData of 1234567.

Notes :
- The data is composed of a number with up to 7 digits
*Edit: Since 1.14 the CustomModelData format changed, and using 8 digits doesn't work now*
- The data shouldn't start with 0, or it will give an "error" model
- Doing this only changes the item model. It won't work for blocks models but can change the block's item model (block in the inventory)

{
"parent": "item/generated",
"textures": {
"layer0": "item/iron_ingot"
},

"overrides": [
{"predicate": {"custom_model_data":1234567}, "model": "item/gold_ingot"}
]
}



General notes :
- Here I only changed the iron_ingot to a gold_ingot. But you can also use this format for custom models.
- A tool with durability can be changed, and the damage of the tool will not affect its custom model. It will allow adventure/rpg maps with weapon durability.
- Packs are not compatible ! A tool modified by multiple packs, even with different datas, will only use the first one in the order of the packs applied (the one on top of your active packs in the "ressourcepacks" window)

Hope this tutorial helped you, seeya !

Example pack download :
*Edit: reuploaded the pack to match changes made in 1.14*
- Mediafire -

This pack changes the iron ingot and the carved pumpkin
with the CustomModelData:1234567
Posted by
Geegaz
Level 67 : High Grandmaster Engineer
207

Create an account or sign in to comment.

148

IMK011
11/03/2021 11:18 am
Level 20 : Expert Spelunker
THANKS!
1
Czebosak
10/31/2021 2:46 am
Level 46 : Master Slime Tamer
history
i'm making a datapack with custom weapons but the method you showed doesnt really work as intended

screenshot

code
1
HoboMaggot
10/31/2021 3:51 am
Level 53 : Grandmaster Blob
Pretty sutre the katana image belongs in textures/items not models/items
1
Czebosak
10/31/2021 4:36 am
Level 46 : Master Slime Tamer
history
nope

try
1.17
1
Stantoncomet
10/04/2021 9:02 pm
Level 44 : Master Engineer
Thank you so much!
1
Nate the Penguin
09/12/2021 3:43 pm
Level 69 : High Grandmaster Pixel Painter
Ive been trying to think of ways I can let players use my items in survival, since you can't use commands. Ive figured out how to add them into loot tables of mobs and loot chests, but I still don't know how to make them craftable, even if I made custom crafting recipes there are only so many recipes I could come up with and there are over 250 items in one of my packs and some 400 in the other.

With optifine I can craft them by renaming the base item on an anvil, do you think there is some way in which I could do the same thing in vanilla?
1
Geegaz
09/13/2021 4:13 am
Level 67 : High Grandmaster Engineer
history
Currently it's not possible to craft items with NBT in a regular crafting table, so we have a few workarounds.

The easiest (and most common) method is by using a knowledge book as the output item - you might've seen it in a lot of packs, when you have recipes that require you to click on the knowledge book to get the item.
For that you need:
- an advancement to detect when the recipe is unlocked
- a function that resets the advancement and recipe
- a loot table to give the item (can also be a simple /give in the previous function)
Then, just put the function and loot table as rewards for the achievement.
The pros - you can craft the item directly in the regular crafting table, it works seamlessly and is quite easy to implement. The cons though - you can't see the item you're crafting, the recipe will never be in the recipe book, and a popup will appear every time.

The oldest method is floor crafting, but it's really not recommended as it can get very laggy if not implemented properly.

The most advanced method is making a custom crafter. It's very technical so I won't go in the details, but it's by far the most flexible method since you can make custom UIs, new types of crafting - nearly anything you want. Thankfully there are initiatives to make the creation of a custom crafter easier - I'd recommend checking out SmithedCrafter, a datapack that adds a fully functionnal crafter to which you can add your own recipes very easily !

If you need help with any of these - here are the Minecraft Commands and the Datapack Center discord server, they have a lot of great datapackers that will be able to help you !
2
Nate the Penguin
09/13/2021 5:59 am
Level 69 : High Grandmaster Pixel Painter
Thank you! I will look into all of these. Hopefully mojang will add nbt options later.
1
HoboMaggot
09/12/2021 10:34 pm
Level 53 : Grandmaster Blob
history
By custom crafting recipes do you mean using the official ones (for the vanilla crafting table)?
If you want to rename and change the custommodeldata of your output items, you cannot do so without a custom crafter or floor crafting
2
EHXTheAdventurer
08/13/2021 3:00 am
Level 1 : New Miner
I'd recommend using a custom namespace for the custom model and textures. Seems cleaner to me, and more consistent with the standards for datapacks (which I don't see why they wouldn't apply to resource packs as well).

The compatibility issue can be easily solved with a top-level cohesion resource pack that contains just the override models, with an override for each data value that's meant to be included. One should keep an eye out for CustomModelData ID collisions, though, and adjust things accordingly if necessary.
1
Geegaz
08/13/2021 3:47 am
Level 67 : High Grandmaster Engineer
Well, if I understood your comment properly you're only half-right.
Datapacks need a custom namespace and resourcepacks don't, but it's true organizing them in the same way as datapack can be cleaner.

There is an effort to avoid CMD ID collision and general datapack compatibility, thanks to a website created by Boomber, where each datapacker can give themselves a 4-digits ID to use in front of all their models. It allows manual merging of packs (creating a single resourcepack with all the overrides) without CMD ID collisions.

But about compatibility, the problem has already been studied and what you propose doesn't work. From what I gather, either you suggest putting things in namespaces so they can merge easily, either you suggest we use a toplevel pack with all possible overrides ?
Well, for the first solution, model overrides don't merge. If you have one pack that has overrides in the stick model, other packs that also have overrides in the stick model will take priority in the vertical order.
For the second idea, it's not bad but you still need to specify a path to the custom model in the override. So, it's just pushing the problem back.
... if your idea was something else, sorry but it wouldn't work either. It's been bugging the entire datapack community for a long time, and it's not easy to solve.
1
bigjosher
07/20/2021 1:22 pm
Level 1 : New Miner
how do you find the custom model data on one single item
1
Kiing_Watermelon
06/09/2021 11:31 am
Level 51 : Grandmaster Baconator
how do i add multiple textures?
for example i want two different textures for a carrot on a stick
1
Hurricane223
05/28/2021 6:40 pm
Level 14 : Journeyman Miner
Thank you so much!
1
TonkoBanjo
05/16/2021 4:10 am
Level 10 : Journeyman Taco
thank you very much i wanted to make a club penguin character in game and now i can
1
lilBerna
05/13/2021 8:49 pm
Level 1 : New Miner
Is there a way to create a model file that works for all items (on version 1.8)? I wanted to make it so all items look a certain way in first person but the only way i found was to make each item it's own model file :/
1
SuperMegaRorro
05/09/2021 1:57 pm
Level 3 : Apprentice Explorer
history
.
I created my own model but I don't know how to fix the position, so far I haven't found a way.




{
"parent": "item/handheld",
"textures": {
"layer0": "item/custom/obs/obsidian_longsword"
},
"display": {
"firstperson_righthand": {
"translation": [ 0, 1, -3 ],
"rotation": [ 45, 90, 0 ],
"scale": [ 2, 2, 1 ]
},
"thirdperson_righthand": {
"translation": [ 0, 4, 2],
"rotation": [ 45, 90, 0 ],
"scale": [ 2, 2, 1 ]
},
"firstperson_leftthand": {
"translation": [ 0, 1, -3 ],
"rotation": [ -45, 90, 0 ],
"scale": [ 2, 2, 1 ]
},
"thirdperson_lefthand": {
"translation": [ 0, 4, 2 ],
"rotation": [ -45, 90, 0 ],
"scale": [ 2, 2, 1 ]
}
}
}
1
Geegaz
05/10/2021 7:19 am
Level 67 : High Grandmaster Engineer
history
Try raising the second value in each "translation" field !
The 3 numbers are an array for 3D translation, so changing the 2nd value will change the Y position of the model.
2
SuperMegaRorro
05/11/2021 8:07 am
Level 3 : Apprentice Explorer
thanks , it worked
1
mzxciap
05/08/2021 2:58 pm
Level 49 : Master Procrastinator
cool!
1
AlexTheDolphin0
04/01/2021 8:34 am
Level 38 : Artisan Dolphin
Does this exist on bedrock? I want 2 make something for my friends who use bedrock. Can't find anything on whether or not it exists.
1
Geegaz
04/01/2021 4:54 pm
Level 67 : High Grandmaster Engineer
Nope, this is only for Java Edition resource packs (1.14+)
1
syamilsqolbi
11/30/2020 2:21 am
Level 1 : New Miner
hi um, I'm trying to make a custom 3d model from iron ax to my model but when I get it with this code ..

/give @s iron_axe{CustomModelData:192007}

but I just see the item is not visible but there (has no texture at all. not purple black box can you help me? please help me

this is the model "hammer.json":

{
"credit": "Made with Blockbench",
"parent": "minecraft:item/handheld",
"textures": {
"0": "item/19_gray",
"particle": "item/19_gray"
},
"elements": [
{
"from": [8, -10, 8],
"to": [9, 9, 9],
"faces": {
"north": {"uv": [0, 0, 1, 16], "texture": "#0"},
"east": {"uv": [0, 0, 1, 16], "texture": "#0"},
"south": {"uv": [0, 0, 1, 16], "texture": "#0"},
"west": {"uv": [0, 0, 1, 16], "texture": "#0"},
"up": {"uv": [0, 0, 1, 1], "texture": "#0"},
"down": {"uv": [0, 0, 1, 1], "texture": "#0"}
}
},
{
"from": [7, 9, 4],
"to": [10, 12, 13],
"faces": {
"north": {"uv": [0, 0, 3, 3], "texture": "#0"},
"east": {"uv": [0, 0, 9, 3], "texture": "#0"},
"south": {"uv": [0, 0, 3, 3], "texture": "#0"},
"west": {"uv": [0, 0, 9, 3], "texture": "#0"},
"up": {"uv": [0, 0, 3, 9], "texture": "#0"},
"down": {"uv": [0, 0, 3, 9], "texture": "#0"}
}
}
],
"display": {
"thirdperson_righthand": {
"translation": [-1.25, 11.75, 0.5],
"scale": [1.7793, 1.63672, 1.77148]
},
"thirdperson_lefthand": {
"translation": [-1.25, 11.75, 0.5],
"scale": [1.7793, 1.63672, 1.77148]
},
"firstperson_righthand": {
"translation": [-1.25, 11.75, 0.5],
"scale": [1.7793, 1.63672, 1.77148]
},
"firstperson_lefthand": {
"translation": [-1.25, 11.75, 0.5],
"scale": [1.7793, 1.63672, 1.77148]
},
"ground": {
"rotation": [-86.75, 0, 0],
"translation": [-1.25, 3, 0.5],
"scale": [1.7793, 1.63672, 1.77148]
},
"gui": {
"rotation": [0, 60, 0],
"translation": [0, 5.75, 0]
},
"fixed": {
"rotation": [0, 90, 0],
"translation": [0, 4.25, 0],
"scale": [1.25977, 1.19922, 1]
}
}
}


and this is the iron axe code

{
"parent": "item/generated",
"textures": {
"layer0": "item/iron_axe"
},
"overrides":
[
{ "predicate": { "custom_model_data":192007}, "model": "item/hammer" }
]
}

1
TurtleYoda
06/15/2021 11:50 am
Level 1 : New Miner
Did you put both "hammer.json" and "iron_axe.json" under /assets/minecraft/models/item/ ?
1
User3281260G
10/30/2020 11:46 pm
Level 1 : New Miner
so how would i change the texture for armor being worn depending on the {CustomModelData} tag, if possible?
1
St34lth
10/29/2020 4:40 am
Level 20 : Expert Sus
history
Hi whoever is reading this!
I am trying to make a resource pack that goes with a data pack I am working on. I have tried multiple methods with this resource pack and some of the responses in the comments. My texture isn't coming up yet I have replicated the example .json file identically except with my presonal twists please help me.

here is my code

{
"parent": "item/generated",
"textures": {
"layer0": "item/iron_ingot"
},

"overrides": [
{"predicate": {"custom_model_data":1234567}, "model": "assets/minecraft/models/item/swords/excalibur"}
]
}




I have tried adjusting multiple things but nothing is working? Is this a 1.16 issue or am I just plain stupid?
1
St34lth
10/29/2020 5:04 am
Level 20 : Expert Sus
history
Update I have done something that has now made it a black & purple box



Please help me whoever is reading this asap



{
"parent": "item/generated",
"textures": {
"layer0": "item/iron_sword"
},

"overrides": [
{"predicate": {"custom_model_data":1}, "model": "item/excalibur"}
]
}
1
St34lth
10/29/2020 5:44 am
Level 20 : Expert Sus
Just found that to remove the purple & black cube in your hand the item needs its own json file

Here is an example for copy & paste-ing


{
"parent": "item/handheld",
"textures": {
"layer0": "item/texture_name_here"
}
}




Make sure it is in its own json file and is named after the texture
1
Black_Blaze
10/10/2020 5:49 am
Level 1 : New Miner
I have a problem and I have no idea what can I do.

The Problem is to make a custom model data texture on a shield
1
JustAKat
09/14/2020 1:03 am
Level 10 : Journeyman Fisherman
history
Hi, managed to get the custom model data to work with the below, but the normal item without the custom model data now shows as a flat black-and-purple item (missing textures, which is strange). Any ideas how it can be resolved?


One of the files in assets/minecraft/models/item/coin:

{
"parent": "item/generated",
"textures": {
"layer0": "item/coin-platinum"
}
}



In assets/minecraft/models/item:
{
"parent": "item/generated",
"textures": {
"layer0": "item/sunflower"
},
"overrides": [
{ "predicate": { "custom_model_data": 220}, "model":"item/coin/coin-bronze"},
{ "predicate": { "custom_model_data": 222}, "model":"item/coin/coin-gold"},
{ "predicate": { "custom_model_data": 224}, "model":"item/coin/goin-platinum"},
{ "predicate": { "custom_model_data": 226}, "model":"item/coin/coin-silver"}
]
}
1
JustAKat
09/14/2020 1:55 am
Level 10 : Journeyman Fisherman
Nvm, figured it out from looking at the vanilla data.

{
"parent": "item/generated",
"textures": {
"layer0": "block/sunflower_front"
},
"overrides": [
{ "predicate": { "custom_model_data": 220}, "model":"item/coin/coin-bronze"},
{ "predicate": { "custom_model_data": 222}, "model":"item/coin/coin-gold"},
{ "predicate": { "custom_model_data": 224}, "model":"item/coin/goin-platinum"},
{ "predicate": { "custom_model_data": 226}, "model":"item/coin/coin-silver"}
]
}
1
3DG_
09/12/2020 10:07 pm
Level 1 : New Miner
history
My blue coin is appearing red, why is that? :(


{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "minecraft:item/emerald"
},

"overrides": [
{"predicate": {"custom_model_data": 4750001}, "model": "minecraft:custom/purplecoin"},
{"predicate": {"custom_model_data": 4750002}, "model": "minecraft:custom/bluecoin"},
{"predicate": {"custom_model_data": 4750003}, "model": "minecraft:custom/greencoin"},
{"predicate": {"custom_model_data": 4750004}, "model": "minecraft:custom/yellowcoin"},
{"predicate": {"custom_model_data": 4750005}, "model": "minecraft:custom/redcoin"}
]
}
1
DowneyD3
07/26/2020 7:13 pm
Level 1 : New Miner
Hello, im trying to add a custom sword, but in the game shows a black and purple block,



so, i think that paths is wrong?



Resource pack:

Minecraft > assets > models > custom_sword.json ???





Minecraft > assets > models > item > carrot_on_a_stick.json



{
"parent": "minecraft:item/handheld",
"textures": {
"layer0": "minecraft:item/carrot_on_a_stick"
},
"overrides": [
{ "predicate": {"custom_model_data": 321123}, "model": "models\custom_sword"}]

}



I dont know what i do :/
2
RadoslavL
01/18/2021 2:02 am
Level 1 : New Miner
What's the code in custom_sword.json?
1
ItsLightningBolt
07/28/2020 12:32 pm
Level 1 : New Explorer
history
Hello there! I've been playing around with custom models and all that, and from what I can tell, you need to have any custom models in a subfolder of the models folder like this:
assets/minecraft/models/item/customHope this helped!
1
AONK
06/19/2020 3:46 am
Level 24 : Expert Explorer
hi, i was wondering if it's possible to make a music disc with a Custom Model Data tag that can have its own music linked to it, so you can have the base game records as well as custom ones. any help would be appreciated
1
User3210625F
08/29/2020 6:08 pm
Level 1 : New Miner
I think you can do it in few command blocks:

give yourself a disc with CustomModelData tag linked to the texture you want, but also an Array tag or a custom name

I think jukebox is like a container (like a chest), so in its data you should find the item it contains, precisely in its tag RecordItem.

You just have to make an execute command to test if jukebox contains your specific disc. Stopsound for the music the disc will start automatically when u put it in the jukebox and then playsound of the music u want. You can add some custom sounds in your resourcepack.
I didnt test yet, i m pretty sure it will work
2
Geegaz
06/24/2020 3:39 am
Level 67 : High Grandmaster Engineer
No, it's not possible. You would need the help of a datapack for that, detecting when a disc with a custom model is used (in minecraft, the music that discs play is hardcoded).

But you can still add custom models for music discs though, even if it's not gonna change the music they play.
4
broskibble
06/16/2020 8:34 pm
Level 5 : Apprentice Miner
tysm
1
Verdigrix
05/12/2020 12:32 pm
Level 64 : High Grandmaster Senpai
When I load the game, my crossbow model shows up as a purple and black cube, I've tried multiple things but can't seem to get it to work, here is the code

{
"parent": "item/generated",
"textures": {
"layer0": "item/crossbow_standby"
},
"display": {
"thirdperson_righthand": {
"rotation": [ -90, 0, -60 ],
"translation": [ 2, 0.1, -3 ],
"scale": [ 0.9, 0.9, 0.9 ]
},
"thirdperson_lefthand": {
"rotation": [ -90, 0, 30 ],
"translation": [ 2, 0.1, -3 ],
"scale": [ 0.9, 0.9, 0.9 ]
},
"firstperson_righthand": {
"rotation": [ -90, 0, -55 ],
"translation": [ 1.13, 3.2, 1.13],
"scale": [ 0.68, 0.68, 0.68 ]
},
"firstperson_lefthand": {
"rotation": [ -90, 0, 35 ],
"translation": [ 1.13, 3.2, 1.13],
"scale": [ 0.68, 0.68, 0.68 ]
}
},
"overrides": [
{ "predicate": { "custom_model_data": 1}, "model": "item/50.cal"}
{
"predicate": {
"pulling": 1
},
"model": "item/crossbow_pulling_0"
},
{
"predicate": {
"pulling": 1,
"pull": 0.58
},
"model": "item/crossbow_pulling_1"
},
{
"predicate": {
"pulling": 1,
"pull": 1.0
},
"model": "item/crossbow_pulling_2"
},
{
"predicate": {
"charged": 1
},
"model": "item/crossbow_arrow"
},
{
"predicate": {
"charged": 1,
"firework": 1
},
"model": "item/crossbow_firework"
},
{
"predicate": {
"pulling": 1,
"custom_model_data": 1
},
"model": "item/50.calfire0"
},
{
"predicate": {
"pulling": 1,
"pull": 0.58,
"custom_model_data": 1
},
"model": "item/50.calfire1"
},
{
"predicate": {
"pulling": 1,
"pull": 1.0,
"custom_model_data": 1
},
"model": "item/50.calfire2"
},
{
"predicate": {
"charged": 1,
"custom_model_data": 1
},
"model": "item/50.calfire2"
},
{
"predicate": {
"charged": 1,
"firework": 1,
"custom_model_data": 1
},
"model": "item/50.calfire2"

}
]
}
1
Geegaz
05/12/2020 12:54 pm
Level 67 : High Grandmaster Engineer
Did you pass it through a json validator to see if there are any json mistakes ? I use this one (link).
2
Verdigrix
05/12/2020 1:29 pm
Level 64 : High Grandmaster Senpai
history
Thx

Edit: I ran the code through and fixed it, but it still shows up as a textureless cube in my hand
1
dragonmaster
05/13/2020 4:41 am
Level 40 : Master Dragon
I'd suggest moving the first predicate to right after the "crossbow_firework" one

Also, assuming you fixed the missing comma after the first predicate (the custom_model_data: 1 one) make sure the problem isn't with the model itself. If a normal crossbow is a purple/black cube then the whole file probably has a syntax error. If it's just the custom_model_data one your custom model is either invalid or not at the path you specified.

The output log is usually your friend (you can enable it in the settings of the Minecraft launcher)
1
NexionPVP
05/02/2020 8:41 pm
Level 1 : New Miner
could you combine this with custom crafting recipes using a data pack

I'm trying to make a craftable weapon for survival that i can craft
1
Geegaz
05/04/2020 6:47 am
Level 67 : High Grandmaster Engineer
Be careful though, you can't craft items with nbt. That's a big limitations datapacks have to get around. So in short, no you can't combine it with regular crafting. You can add custom recipes but you'll have to use workarounds to add nbt to these items.
3
NexionPVP
05/04/2020 2:25 pm
Level 1 : New Miner
yea I ended up using a method of testing to see if the player has the items in their inventory and if they did then it asks if they want to craft it if they click yes then it gives them an advancement that gives them the item and clears there inventory of those certain items and then takes away the advancement so they can get it again
1
TheSova
04/27/2020 4:17 pm
Level 17 : Journeyman Procrastinator
history
Hi, i iried to use "item/generated" value for "parent" tag on the spawn egg and basic egg now displays missing texture. Have you any information about the "parent" tag becsuse i tried and failed to find information
1
Geegaz
04/30/2020 2:11 am
Level 67 : High Grandmaster Engineer
to use "item/generated", you souldn't have any model data, just textures. They should be named layer0 (and layer1 in the case of some items like leather armor, eggs and potions). So in the end, a model using "item/generated" should look like this:
{
"parent": "item/generated",
"textures": {
"layer0": "path/to/texture",
"layer1": "path/to/other/texture"
}
}

Note that usually, in the few models that need 2 layers, layer1 displays on top of layer0.
1
TimOD
04/22/2020 5:43 am
Level 1 : New Miner
history
Hi, idk if this is the right place but... could you change the texture of an item to a 3d texture if it has different nbt data? Would use .json and blockbench. I would like to change different dyed firework stars as diffrent custom items... but how?

Edit:
the problem is that after crafting there is no hint on what the nbt data exacly is or it saxs that it has changed but not into what.
1
Geegaz
04/26/2020 12:26 pm
Level 67 : High Grandmaster Engineer
It's not possible, you would have to use Custom Model Data for that.
1

Welcome