For example, to add an Item with metadata, you needed as many json files as the number of metadata (4 this time), but how to do it with 2 (reuse the same Model)
Minecraft-1.10.2 Minecraft-1.11.2 Minecraft-1.12.2
(* I haven't tried it, maybe other versions are possible)
(Hereafter, modid is the ID of the mod that adds the item)
First, create the following JSON file in assets / modid / models / ** block ** / ** At this time, make sure to add it to the Model position of the block instead of the item **
item_generated.json
{
"parent": "item/generated"
}
Next, create the following JSON file in assets / modid / blockstates / (Add as many metas to add to variants)
sample_item.json
{
"forge_marker": 1,
"defaults": {
"model": "modid:item_generated",
"transform": "forge:default-item",
"uvlock": true
},
"variants": {
"meta0": [{
"textures": {
"layer0": "modid:items/sample_item_0"
}
}],
"meta1": [{
"textures": {
"layer0": "modid:items/sample_item_1"
}
}],
"meta2": [{
"textures": {
"layer0": "modid:items/sample_item_2"
}
}],
"meta3": [{
"textures": {
"layer0": "modid:items/sample_item_3"
}
}]
}
}
Next is the registration of the Model added earlier.
ClientProxy.kt
for (i in 0 until 4) {
ModelLoader.setCustomModelResourceLocation(sampleItem, i,
ModelResourceLocation(ResourceLocation(modid, "sample_item"), "meta$i"))
}
The same is true for java
ClientProxy.java
for (int i = 0; i < 4; i++) {
ModelLoader.setCustomModelResourceLocation(sampleItem, i,
new ModelResourceLocation(new ResourceLocation(modid, "sample_item"), "meta" + i));
}
Perhaps if you play with the second argument of ModelResourceLocation, just like Block,
sample_item.json
{
"forge_marker": 1,
"defaults": {
"model": "modid:item_generated",
"transform": "forge:default-item",
"uvlock": true
},
"variants": {
"meta": {
"0":{ },
"1":{ },
"2":{ },
"3":{ }
}
}
I think it can be shaped like this ~~ But I stopped it because it's annoying ~~.
Recommended Posts