User Tools

Site Tools


tutorial:armor_trim

Adding an Armor Trim

Introduction

In this page you will learn how to add a new armor trim. For this tutorial we will be using tutorial as the mod id. This page is really a heavy spell check since we need to make a lot of files with specific names.
If you, and lets be real that's most of you, are just here to copy and paste, don't worry all important things are in big nice code blocks and the GitHub repo is at the end of this page. :)

Registering the Item

In theory we don't need to add a new item since this is more data packed than it is modded, but if you would do this using only a data pack we would be missing the nice tooltip in the description of the Armor Trim item.
To register this item we need to register it as a new SmithingTemplateItem.of(new Identifier(MODID, TRIMID) The TrimId can be separate from the actual item name, but for ease of making we will use the same for both.
For the rest we will just need the basic thingamajig of item registration:

  1. // adding a new SmithingTemplateItem named "TUTORIAL_ARMOR_TRIM" with the MODID as "tutorial" and trimid as "tutorial_trim"
  2. public static final Item TUTORIAL_ARMOR_TRIM = SmithingTemplateItem.of(new Identifier("tutorial", "tutorial_armor_trim"));
  3.  
  4. // registering said Item with MODID "tutorial" and name "tutorial_armor_trim"
  5. public static void registerModItems() {
  6. Registry.register(Registries.ITEM, new Identifier("tutorial", "tutorial_armor_trim"), TUTORIAL_ARMOR_TRIM);
  7. }
and in the ModInitializer class:
  1. // calling Item registration
  2. @Override
  3. public void onInitialize() {
  4. ModItems.registerModItems();
  5. }

And then just normal item textures if you desire so, but NO LANG, that comes later.

Making it smithing table compatible. (drawing the rest of the owl)

To make it work with the smithing table, which is the goal, we need to create three files. First we need to create a armor trim info file. This file is named

tutorial_armor_trim.json

and goes under:

resources/data/minecraft/trim_pattern/

these and any following names and paths have to be exactly like displayed (obviously you need to change ModId and item name, but you get what I mean).

Into this file we need to put these three things:
asset_id, which is the before mentioned TrimId
description, which links to the lang file (we'll get to that later)
and the template_item, which is the item we're using.

And this is what that looks like in the json file:

{  
  "asset_id": "minecraft:tutorial_armor_trim",  
  "description": {  
    "translate": "trim_pattern.tutorial.tutorial_armor_trim"  
  },  
  "template_item": "tutorial:tutorial_armor_trim"  
}

The second file we need, is the smithing trim recipe.
The file can be named whatever, but it's recommended to name it something related like

tutorial_armor_trim_smithing_trim.json

and it is placed at:

resources/data/minecraft/recipes/

Other than that, this is just a recipe file and nothing interesting:

{  
  "type": "minecraft:smithing_trim",  
  "addition": {  
    "tag": "minecraft:trim_materials"  
  },  
  "base": {  
    "tag": "minecraft:trimmable_armor"  
  },  
  "template": {  
    "item": "tutorial:tutorial_armor_trim"  
  }  
}

Take note that only the last parameter ever changes and the first three stay the same.

The third file is technically optional, but we will still make it, because it's needed for the tag search in the creative inventory and maybe something else (idk, haven't checked).
It is named:

trim_templates.json

and goes to:

resources/data/minecraft/tags/items/

Inside the file is:

{  
  "replace": false,  
  "values": [  
    "tutorial:tutorial_armor_trim"  
  ]  
}

Now if we would theoretically test this, it would work but we would be greeted by the beautiful missing texture texture.
So we need to:

Make assets

Lets begin with making the trim textures first and then do the lang.

Trim textures

The first file we need just points to the different texture locations and that's pretty much it.
The file is named:

armor_trims.json

and belongs into the directory:

resources/assets/minecraft/atlases/

Inside is:

{  
  "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",  
        "trims/models/armor/wayfinder",  
        "trims/models/armor/wayfinder_leggings",  
        "trims/models/armor/shaper",  
        "trims/models/armor/shaper_leggings",  
        "trims/models/armor/silence",  
        "trims/models/armor/silence_leggings",  
        "trims/models/armor/raiser",  
        "trims/models/armor/raiser_leggings",  
        "trims/models/armor/host",  
        "trims/models/armor/host_leggings",  
 
        "trims/models/armor/tutorial_armor_trim",  
        "trims/models/armor/tutorial_armor_trim_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"  
      }  
    }  
  ]  
}

Now, the file has a lot inside but the only change is this tiny part:

"trims/models/armor/tutorial_armor_trim",\\ 
"trims/models/armor/tutorial_armor_trim_leggings"


The rest is just vanilla code we cant go around.

The last two files we need for textures are:

tutorial_armor_trim.png

and:

tutorial_armor_trim_leggings.png

just like we've changed above. And that's also where they go. Both go into this directory:

resources/assets/minecraft/textures/trims/models/armor/

But now the question is:

How do I create these textures

There are a lot of ways you could do this. For example you could:
Use skindex or any other skineditor to have a 3d view of what you're doing, but that would give you one texture and you need two or you could edit existing trims and go free style, but the best way I've found so far is to take one of the armor textures and put it into a pixel editing tool of your choice and then also get the color palette and paint over the armor texture. Then, when you're finished drawing, you just erase the original armor texture. By doing it this way you know where the armor can be modified, or better said where it should.

With that done the trim effectively works, but in the tooltip of the armor trim and trimmed item we will have this ugly text:

trim_pattern.tutorial.tutorial_armor_trim


But this is an easy fix with some:

Translation

In the

en_us.json

file under:

resources/assets/tutorial/lang/

we need to put this, just mentioned, ugly text. Like this:

{  
  "trim_pattern.tutorial.tutorial_armor_trim": "Tutorial Armor Trim"  
}

But with this final step, we are done. Have fun with your new armor trims.

If you have any more questions you can ask them on the Farbic discord and ping me @herrchaos or just look at the source code of this tutorial at: GitHub

tutorial/armor_trim.txt · Last modified: 2024/05/12 15:13 by herr_chaos