Reputation: 17
I'm trying to make a texture pack that changes a crossbow's texture based on a specific tag for ex.
If a crossbow tag is "Cool_Crossbow" then it uses cool_crossbow.png
This is how I set the crossbows tag:
ItemStack item = new ItemStack(Material.CROSSBOW);
ItemMeta meta = item.getItemMeta();
NamespacedKey key = new NamespacedKey(hex, "One_Punch_Bow");
meta.getPersistentDataContainer().set(key, PersistentDataType.STRING, "One Punch Bow");
I did some digging on how to set a texture based on a tag and this is what I came up with:
{
"parent": "item/generated",
"textures": {
"layer0": "item/my_custom_crossbow_model"
},
"overrides": [
{
"predicate": {
"tag": {
"One_Punch_Bow": "One Punch Bow"
}
},
"model": "item/my_custom_crossbow_model"
}
]
}
Unfortunately, this doesn't work (not surprised tbh). What is wrong here idk. Also please tell me if this even is the correct way to do this
Upvotes: 1
Views: 104
Reputation: 696
There is no predicate tag base on this wiki page
You can use custom_model_data
{
"parent": "item/generated",
"textures": {
"layer0": "item/my_custom_crossbow_model"
},
"overrides": [
{
"predicate": {
"custom_model_data": INTEGER
},
"model": "item/my_custom_crossbow_model"
}
]
}
And then you can set custom model data with this
ItemMeta meta = item.getItemMeta();
meta.setCustomModelData(INTEGER)
Also I recommend to search for help at this site https://www.spigotmc.org/
Upvotes: 1