Tutorial:Adding custom trims

Jump to navigation Jump to search
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[edit | edit source]

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[edit | edit source]

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"
  },
  "template_item": "minecraft:stick"
}
  • [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.
    • [String] template_item: The item representing this pattern.
    • [Boolean] decal: Optional, defaults to false. If true, the pattern texture will be masked based on the underlying armor.

Item tag[edit | edit source]

The stick needs to be added to the #minecraft:trim_templates item tag. This item tag is not referenced in a recipe, but is used in the game internally making the template usable in the smithing recipes. In version 1.21.4 this item tag was removed, so from this version this step is no longer required.

data/minecraft/tags/items/trim_templates.json

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

Recipe[edit | edit source]

The next piece in the data pack is the smithing recipe. For the full JSON format, see Recipe § smithing_trim.

data/example/recipe/stripes_armor_trim.json

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

Translation[edit | edit source]

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[edit | edit source]

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[edit | edit source]

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[edit | edit source]

This tutorial page needs to be updated.
 
Please update this page to reflect recent updates or newly available information.
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[edit | edit source]

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"
  },
  "ingredient": "minecraft:ender_pearl",
  "item_model_index": 0.85
}
  • [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.
    • [String] ingredient: The item representing this material.
    • [Float] item_model_index: A value between 0 and 1, used in the item models (see below).
    • [NBT Compound / JSON Object] override_armor_materials: Optional. Map of armor material to override color palette.

Item tag[edit | edit source]

The ender pearl needs to be added to the #minecraft:trim_materials item tag. This makes the material usable in the smithing recipes.

data/minecraft/tags/items/trim_materials.json

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

Translation[edit | edit source]

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[edit | edit source]

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[edit | edit source]

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[edit | edit source]

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. For the trims to appear properly in-game, the item model predicates must be in order from smallest trim_type to largest trim_type.

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_iron_darker_trim",
      "predicate": {
        "trim_type": 0.2
      }
    },
    {
      "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"
  }
}

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

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 the previous trim_type, in this case 0.8, which is diamond. 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[edit | edit source]

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[edit | edit source]

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[edit | edit source]

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/models/item/iron_axe.json

{
  "parent": "minecraft:item/handheld",
  "overrides": [
    {
      "model": "example:item/iron_axe_quartz_trim",
      "predicate": {
        "trim_type": 0.1
      }
    },
    {
      "model": "example:item/iron_axe_netherite_trim",
      "predicate": {
        "trim_type": 0.3
      }
    },
    {
      "model": "example:item/iron_axe_redstone_trim",
      "predicate": {
        "trim_type": 0.4
      }
    },
    {
      "model": "example:item/iron_axe_copper_trim",
      "predicate": {
        "trim_type": 0.5
      }
    },
    {
      "model": "example:item/iron_axe_gold_trim",
      "predicate": {
        "trim_type": 0.6
      }
    },
    {
      "model": "example:item/iron_axe_emerald_trim",
      "predicate": {
        "trim_type": 0.7
      }
    },
    {
      "model": "example:item/iron_axe_diamond_trim",
      "predicate": {
        "trim_type": 0.8
      }
    },
    {
      "model": "example:item/iron_axe_lapis_trim",
      "predicate": {
        "trim_type": 0.9
      }
    },
    {
      "model": "example:item/iron_axe_amethyst_trim",
      "predicate": {
        "trim_type": 1.0
      }
    }
  ],
  "textures": {
    "layer0": "minecraft:item/iron_axe"
  }
}

The above file references custom item models for each material.

The following file needs to be created for each of the 10 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[edit | edit source]

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[edit | edit source]

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[edit | edit source]

References[edit | edit source]

Navigation[edit | edit source]