Tutorial:Adding custom trims

This feature is exclusive to Java Edition.
 

This tutorial explains how to create a data pack and resource pack that adds custom trim materials or patterns. It assumes you already know how to create a data pack.

Custom trim patterns

A smithing recipe showing a custom "Stripes" trim pattern

This example adds a new "Stripes" pattern that works with all the vanilla armor types and colors.

Trim pattern

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[1]. Always leave and reopen the world to apply the new changes!

data/example/trim_pattern/stripes.json

{
  "asset_id": "example:stripes",
  "description": {
    "translate": "trim_pattern.example.stripes"
  }
}
  • [NBT Compound / JSON Object] The root object
    • [String] asset_id: A resource location which will be used in the resource pack.
    • [String][NBT List / JSON Array][NBT Compound / JSON Object] description: A JSON text component used for the tooltip on items.
    • [Boolean] decal: Optional, defaults to false. If true, the pattern texture will be masked based on the underlying armor.

Recipe

The next piece in the data pack is the smithing recipe. For the full JSON format, see Recipe § smithing_trim. The pattern field needs to be the ID of the trim pattern you added in the last step.

data/example/recipe/stripes_armor_trim.json

{
  "type": "minecraft:smithing_trim",
  "addition": "#minecraft:trim_materials",
  "base": "#minecraft:trimmable_armor",
  "template": "minecraft:stick",
  "pattern": "example:stripes"
}

Translation

Moving on to the resource pack, the first step is to create the translation that we referenced in the trim pattern's [NBT Compound / JSON Object] description field.

assets/example/lang/en_us.json

{
  "trim_pattern.example.stripes": "Stripes Armor Trim"
}

Atlas

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": "minecraft: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",
                "iron_darker": "trims/color_palettes/iron_darker",
                "gold_darker": "trims/color_palettes/gold_darker",
                "diamond_darker": "trims/color_palettes/diamond_darker",
                "netherite_darker": "trims/color_palettes/netherite_darker"
      }
    }
  ]
}
    • [NBT List / JSON Array] textures: A list of grayscale trim pattern textures that we want to generate permutations of with the colors defined below.
    • [String] palette_key: The same trim palette key as vanilla. The grayscale color palette key to use when mapping the colors from textures to the colors in permutations.
    • [NBT Compound / JSON Object] permutations: The same color palettes as vanilla. A map of the trim material's [String] asset_name (see below) to its color palette.

For the full JSON format, see Resource_pack § Atlases

Textures

The textures referenced in the atlas [NBT List / JSON Array] textures field should be grayscale images, using the same colors as the texture in [String] palette_key. The textures for this example can be downloaded here:

Custom trim materials

A smithing recipe showing a custom "Ender" trim material

This second example adds a new "Ender" material that works with all the vanilla armor types and colors.

Trim material

Let's start with the trim_material.

Changes to this file won't be applied when running /reload[1]. Always leave and reopen the world to apply the new changes!

data/example/trim_material/ender.json

{
  "asset_name": "ender",
  "description": {
    "color": "#258474",
    "translate": "trim_material.example.ender"
  },
}
  • [NBT Compound / JSON Object] The root object
    • [String] asset_name: A string which will be used in the resource pack.
    • [String][NBT List / JSON Array][NBT Compound / JSON Object] description: A JSON text component used for the tooltip on items. The color
       #258474
      is used here.
    • [NBT Compound / JSON Object] override_armor_assets: Optional. Map of armor material to override color palette.
      • [String] (Armor material): An overriding color palette.

Item tag and component

For a item to be usable to apply a given material, it needs to be added to the #minecraft:trim_materials item tag.

data/minecraft/tags/items/trim_materials.json

{
  "values": [
    "minecraft:ender_pearl"
  ]
}

The item also needs to have the minecraft:provides_trim_material item component. You can for example use /give @s minecraft:ender_pearl[minecraft:provides_trim_material="example:ender"] to give yourself an ender pearl that can be used in the recipe. It is not possible to make all items of a type provide a material by default.

Translation

Moving on to the resource pack, the first step is to create the translation that we referenced in the trim material's [NBT Compound / JSON Object] description field.

assets/example/lang/en_us.json

{
  "trim_material.example.ender": "Ender Material"
}

Atlases

For trim materials, two atlas files need to be modified: 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/bolt",
        "trims/models/armor/bolt_leggings",
        "trims/models/armor/flow",
        "trims/models/armor/flow_leggings",
        "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",
        "trims/models/armor/silence",
        "trims/models/armor/silence_leggings",
        "trims/models/armor/wayfinder",
        "trims/models/armor/wayfinder_leggings",
        "trims/models/armor/raiser",
        "trims/models/armor/raiser_leggings",
        "trims/models/armor/shaper",
        "trims/models/armor/shaper_leggings",
        "trims/models/armor/host",
        "trims/models/armor/host_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"
      }
    }
  ]
}
    • [NBT List / JSON Array] textures: The same list of textures as vanilla.
    • [String] palette_key: The same trim palette key as vanilla. The grayscale color palette key to use when mapping the colors from textures to the colors in permutations.
    • [NBT Compound / JSON Object] permutations: The custom materials that we want to add permutations for. The key ender should match the [String] asset_name from the data pack.

Color palette texture

Scaled up color palette for the "ender" trim material

These atlas files reference a color palette texture which needs to be created. Since the vanilla palette key is used, the image has a width of 8 and a height of 1.

The textures for this example can be downloaded here:

Item models

The most time consuming step is to add the item model predicate to all the possible items. In this example it is only added for the iron chestplate.

assets/minecraft/items/iron_chestplate.json

{
  "model": {
    "type": "minecraft:select",
    "cases": [
      {
        "model": {
          "type": "minecraft:model",
          "model": "minecraft:item/iron_chestplate_quartz_trim"
        },
        "when": "minecraft:quartz"
      },
      {
        "model": {
          "type": "minecraft:model",
          "model": "minecraft:item/iron_chestplate_iron_trim"
        },
        "when": "minecraft:iron"
      },
      {
        "model": {
          "type": "minecraft:model",
          "model": "minecraft:item/iron_chestplate_netherite_trim"
        },
        "when": "minecraft:netherite"
      },
      {
        "model": {
          "type": "minecraft:model",
          "model": "minecraft:item/iron_chestplate_redstone_trim"
        },
        "when": "minecraft:redstone"
      },
      {
        "model": {
          "type": "minecraft:model",
          "model": "minecraft:item/iron_chestplate_copper_trim"
        },
        "when": "minecraft:copper"
      },
      {
        "model": {
          "type": "minecraft:model",
          "model": "minecraft:item/iron_chestplate_gold_trim"
        },
        "when": "minecraft:gold"
      },
      {
        "model": {
          "type": "minecraft:model",
          "model": "minecraft:item/iron_chestplate_emerald_trim"
        },
        "when": "minecraft:emerald"
      },
      {
        "model": {
          "type": "minecraft:model",
          "model": "minecraft:item/iron_chestplate_diamond_trim"
        },
        "when": "minecraft:diamond"
      },
      {
        "model": {
          "type": "minecraft:model",
          "model": "minecraft:item/iron_chestplate_lapis_trim"
        },
        "when": "minecraft:lapis"
      },
      {
        "model": {
          "type": "minecraft:model",
          "model": "minecraft:item/iron_chestplate_amethyst_trim"
        },
        "when": "minecraft:amethyst"
      },
      {
        "model": {
          "type": "minecraft:model",
          "model": "minecraft:item/iron_chestplate_resin_trim"
        },
        "when": "minecraft:resin"
      },
      {
        "model": {
          "type": "minecraft:model",
          "model": "example:item/iron_chestplate_ender_trim"
        },
        "when": "example:ender"
      }
    ],
    "fallback": {
      "type": "minecraft:model",
      "model": "minecraft:item/iron_chestplate"
    },
    "property": "minecraft:trim_material"
  }
}

The majority of this file is the same as the vanilla iron_chestplate model, only the highlighted region is added.

This references another item model file, which needs to be created.

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 trims/items/chestplate_trim_ender sprite that was generated in the blocks.json atlas.

Because the override for all the other armor types hasn't been added, they will default to not showing any trim. To prevent this, the steps in this section need to be taken for each item in the #minecraft:trimmable_armor item tag.

Custom trimmable items

A smithing recipe of an axe added as a trimmable item

This example adds 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.

Item tag

The only change in the data pack is adding the item to the #minecraft:trimmable_armor item tag.

data/minecraft/tags/item/trimmable_armor.json

{
  "values": [
    "minecraft:iron_axe"
  ]
}

Item models

Moving to the resource pack by customizing the iron axe item model. This step is similar to the items models when adding a custom material, but this time all overrides need to be added.

assets/minecraft/items/iron_axe.json

{
  "model": {
    "type": "minecraft:select",
    "cases": [
      {
        "model": {
          "type": "minecraft:model",
          "model": "example:item/iron_axe_quartz_trim"
        },
        "when": "minecraft:quartz"
      },
      {
        "model": {
          "type": "minecraft:model",
          "model": "example:item/iron_axe_iron_trim"
        },
        "when": "minecraft:iron"
      },
      {
        "model": {
          "type": "minecraft:model",
          "model": "example:item/iron_axe_netherite_trim"
        },
        "when": "minecraft:netherite"
      },
      {
        "model": {
          "type": "minecraft:model",
          "model": "example:item/iron_axe_redstone_trim"
        },
        "when": "minecraft:redstone"
      },
      {
        "model": {
          "type": "minecraft:model",
          "model": "example:item/iron_axe_copper_trim"
        },
        "when": "minecraft:copper"
      },
      {
        "model": {
          "type": "minecraft:model",
          "model": "example:item/iron_axe_gold_trim"
        },
        "when": "minecraft:gold"
      },
      {
        "model": {
          "type": "minecraft:model",
          "model": "example:item/iron_axe_emerald_trim"
        },
        "when": "minecraft:emerald"
      },
      {
        "model": {
          "type": "minecraft:model",
          "model": "example:item/iron_axe_diamond_trim"
        },
        "when": "minecraft:diamond"
      },
      {
        "model": {
          "type": "minecraft:model",
          "model": "example:item/iron_axe_lapis_trim"
        },
        "when": "minecraft:lapis"
      },
      {
        "model": {
          "type": "minecraft:model",
          "model": "example:item/iron_axe_amethyst_trim"
        },
        "when": "minecraft:amethyst"
      },
      {
        "model": {
          "type": "minecraft:model",
          "model": "example:item/iron_axe_resin_trim"
        },
        "when": "minecraft:resin"
      }
    ],
    "fallback": {
      "type": "minecraft:model",
      "model": "minecraft:item/iron_axe"
    },
    "property": "minecraft:trim_material"
  }
}

The above file references custom item models for each material.

The following file needs to be created for each of the 11 listed materials.

assets/example/models/item/iron_axe_amethyst_trim.json

{
  "parent": "minecraft:item/handheld",
  "textures": {
    "layer0": "minecraft:item/iron_axe",
    "layer1": "example:trims/items/axe_trim_amethyst"
  }
}

Atlas

The above model files reference an axe_trim_amethyst texture. This texture does not exist, it needs to be generated by the paletted_permutations sprite source in the blocks.json atlas.

assets/minecraft/atlases/blocks.json

{
  "sources": [
    {
      "type": "paletted_permutations",
      "textures": [
        "example:trims/items/axe_trim"
      ],
      "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",
        "resin": "trims/color_palettes/resin"
      }
    }
  ]
}

Mask texture

The atlas references the axe_trim texture, which is a mask for which pixels to color with the color palette.

The texture for this example can be downloaded here:

See also

References

  1. a b MC-260446

Navigation