-
Bug
-
Resolution: Invalid
-
None
-
1.19.4 Pre-release 3
-
None
-
Windows 69, Java 4.20
-
Unconfirmed
-
(Unassigned)
The 23w04a snapshot added armor trims which can be used to customise the texture of items.
The complete data packs and resource packs of these examples can be found in the trim-examples repository.
For trim patterns and materials to work you need to enable the update_1_20 experimental data pack!
Adding a custom trim pattern
In this example we're going to add a new "Stripes" pattern that works with all the vanilla armor types and colors.
Data pack part
Let's start with the central file in the trim_pattern folder in the data pack.
Changes to this file won't be applied when running /reload. Always leave the world and rejoin to apply the new changes!
data/example/trim_pattern/stripes.json
{ "asset_id": "example:stripes", "description":
{ "translate": "trim_pattern.example.stripes" }, "template_item": "minecraft:stick" }
fasset_id: A resource location which will be used in the resource pack.fdescription: A text component shown in the item tooltip.ftemplate_item: The item representing this pattern.
The second and final piece required in the data pack is the recipe.
data/example/recipes/stripes_armor_trim.json
{ "type": "minecraft:smithing_trim", "addition":
{ "tag": "minecraft:trim_materials" }, "base":
{ "tag": "minecraft:trimmable_armor" }, "template":
{ "item": "minecraft:stick" }}
Resource pack part
We'll quickly add a language file used by the item tooltip:
assets/example/lang/en_us.json
{ "trim_pattern.example.stripes": "Stripes Armor Trim" }And now for the complicated bit: adding the texture permutations for the different colors and armor types. This is done by appending the minecraft:armor_trims atlas file.
assets/minecraft/atlases/armor_trims.json
{ "sources": [ { "type": "paletted_permutations", "textures": [ "example:trims/models/armor/stripes", "example:trims/models/armor/stripes_leggings" ], "palette_key": "trims/color_palettes/trim_palette", "permutations":
{ "quartz": "trims/color_palettes/quartz", "iron": "trims/color_palettes/iron", "gold": "trims/color_palettes/gold", "diamond": "trims/color_palettes/diamond", "netherite": "trims/color_palettes/netherite", "redstone": "trims/color_palettes/redstone", "copper": "trims/color_palettes/copper", "emerald": "trims/color_palettes/emerald", "lapis": "trims/color_palettes/lapis", "amethyst": "trims/color_palettes/amethyst" }} ] }
fsources: The list of sprite sources that will be merged with the vanilla atlas.ftype: We use the spaletted_permutations type here.ftextures: A list of grayscale trim pattern textures that we want to generate permutations of with the colors defined below.fpalette_key: The same trim palette key as vanilla.fpermutations: The same color palettes as vanilla.
It's important to use the same format in the ftextures list. When rendering armor, the game will use the fasset_id from the data pack and insert strims/models/armor/ to look for the texture.
The remaining two files are the texture files we specified in the atlas. You can download them here and put them in assets/example/textures/trims/models/armor/.
stripes_leggings.pngstripes.pngAdding a custom trim material
In this second example we're adding a new "Ender" material that works with all the vanilla armor types and colors.
Data pack part
Let's start now with the trim_material.
data/example/trim_material/ender.json
{ "asset_name": "ender", "description":
{ "color": "#258474", "translate": "trim_material.example.ender" }, "ingredient": "minecraft:ender_pearl", "item_model_index": 0.85 }
fasset_name: A string which will be used in the resource pack.fdescription: A text component shown in the item tooltip.fingredient: The item used in the smithing table for this material.fitem_model_index: A "random" number that we will reference in the predicates of the item models.fincompatible_armor_material (optional): If this material is incompatible with an armor material. Possible values: leather, chainmail, iron, gold, diamond, turtle, or netherite.
We need to add the ender pearl to the #minecraft:trim_materials item tag. This makes our material usable in the smithing recipes.
data/minecraft/tags/items/trim_materials.json
{ "values": [ "minecraft:ender_pearl" ] }Resource pack part
Now to finish off with the resource pack. Let's quickly add a language file used by the item tooltip:
assets/example/lang/en_us.json
{ "trim_material.example.ender": "Ender Material" }For trim materials, we need to append two atlas files: one for the armor entity rendering and one for the inventory item models.
assets/minecraft/atlases/armor_trims.json
{ "sources": [ { "type": "paletted_permutations", "textures": [ "trims/models/armor/coast", "trims/models/armor/coast_leggings", "trims/models/armor/sentry", "trims/models/armor/sentry_leggings", "trims/models/armor/dune", "trims/models/armor/dune_leggings", "trims/models/armor/wild", "trims/models/armor/wild_leggings", "trims/models/armor/ward", "trims/models/armor/ward_leggings", "trims/models/armor/eye", "trims/models/armor/eye_leggings", "trims/models/armor/vex", "trims/models/armor/vex_leggings", "trims/models/armor/tide", "trims/models/armor/tide_leggings", "trims/models/armor/snout", "trims/models/armor/snout_leggings", "trims/models/armor/rib", "trims/models/armor/rib_leggings", "trims/models/armor/spire", "trims/models/armor/spire_leggings" ], "palette_key": "trims/color_palettes/trim_palette", "permutations":
{ "ender": "example:trims/color_palettes/ender" }} ] }
assets/minecraft/atlases/blocks.json
{ "sources": [ { "type": "paletted_permutations", "textures": [ "trims/items/leggings_trim", "trims/items/chestplate_trim", "trims/items/helmet_trim", "trims/items/boots_trim" ], "palette_key": "trims/color_palettes/trim_palette", "permutations":
{ "ender": "example:trims/color_palettes/ender" }} ] }
fsources: The list of sprite sources that will be merged with the vanilla atlas.ftype: We use the spaletted_permutations type here.ftextures: The same list of textures as vanilla.fpalette_key: The same trim palette key as vanilla.fpermutations: Our custom materials that we want to add permutations for. Our key fender should match what we had for fasset_name in the data pack.
These atlas files reference a color palette which we need to create. Since we use the vanilla palette key, the image has a width of 8 and a height of 1. You can download it here: ender.png. Put it in assets/example/textures/trims/color_palettes/ender.png.
(Don't save the image below, which has been scaled up)
Finally, the most time consuming step is to add the item model predicate to all the possible items. In this example I only added it for the iron chestplate.
assets/minecraft/models/item/iron_chestplate.json
{ "parent": "minecraft:item/generated", "overrides": [ { "model": "minecraft:item/iron_chestplate_quartz_trim", "predicate":
{ "trim_type": 0.1 }}, { "model": "minecraft:item/iron_chestplate_netherite_trim", "predicate":
{ "trim_type": 0.3 }}, { "model": "minecraft:item/iron_chestplate_redstone_trim", "predicate":
{ "trim_type": 0.4 }}, { "model": "minecraft:item/iron_chestplate_copper_trim", "predicate":
{ "trim_type": 0.5 }}, { "model": "minecraft:item/iron_chestplate_gold_trim", "predicate":
{ "trim_type": 0.6 }}, { "model": "minecraft:item/iron_chestplate_emerald_trim", "predicate":
{ "trim_type": 0.7 }}, { "model": "minecraft:item/iron_chestplate_diamond_trim", "predicate":
{ "trim_type": 0.8 }}, { "model": "example:item/iron_chestplate_ender_trim", "predicate":
{ "trim_type": 0.85 }}, { "model": "minecraft:item/iron_chestplate_lapis_trim", "predicate":
{ "trim_type": 0.9 }}, { "model": "minecraft:item/iron_chestplate_amethyst_trim", "predicate":
{ "trim_type": 1.0 }} ], "textures":
{ "layer0": "minecraft:item/iron_chestplate" }}
This is mostly the vanilla iron chestplate item model, but we added an override with the j"trim_type": 0.85 predicate for our custom material. The order is important here!
This references another item model file, which we need to create.
assets/example/models/item/iron_chestplate_ender_trim.json
{ "parent": "minecraft:item/generated", "textures":
{ "layer0": "minecraft:item/iron_chestplate", "layer1": "minecraft:trims/items/chestplate_trim_ender" }}
This item model references the strims/items/chestplate_trim_ender sprite that was generated in the blocks.json atlas.
Since we haven't added the override for all the other armor types, they will default to the previous ftrim_type, in our case n0.8, which is diamonds.
Adding a custom trimmable item
In this example we're going to add the iron_axe as a trimmable item. Since this is not an armor item, we only need to worry about the item model. The trim pattern used will have no effect on the texture, only the trim material can be used in the model overrides.
Data pack part
The only change in the data pack is adding the item to the #minecraft:trimmable_armor item tag.