User Tools

Site Tools


tutorial:armor_trim

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
tutorial:armor_trim [2024/05/12 11:37] – created herr_chaostutorial:armor_trim [2024/08/26 01:26] (current) solidblock
Line 1: Line 1:
-===== Adding a custom Armor Trim ===== +====== Adding an Armor Trim ====== 
-=== Introduction === +===== 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.\\ +In this page you will learn how to add a new armor trim. As many other tutorials, we will be using ''tutorial'' as the namespace. 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. :) 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.\\  +===== Register the item ===== 
-To register this item we need to register it as a new <file>SmithingTemplateItem.of(new Identifier(MOD_IDTRIM_ID))</file> The TrimId can be separate from the actual item name, but for ease of making we will use the same for both.\\  +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. 
-For the rest we will just need the basic thingamajig of item registration:+ 
 +To register this item we need to register it as a new ''%%<yarn class_8052>.<yarn method_48418>(Identifier.of("tutorial"trimId))%%'', where 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 [[items|item]] registration. Here we assume you have written a convenient static ''register'' method (see [[items]] tutorial). 
 <yarncode java [enable_line_numbers="true"]> <yarncode java [enable_line_numbers="true"]>
-// adding a new SmithingTemplateItem named "TUTORIAL_ARMOR_TRIM" with the MODID as "tutorial" and trimid as "tutorial_trim"  +public final class TutorialItems { 
-public static final Item TUTORIAL_ARMOR_TRIM = SmithingTemplateItem.of(new Identifier("tutorial", "tutorial_armor_trim"));   +    // adding a new SmithingTemplateItem named "TUTORIAL_ARMOR_TRIM" with the MODID as "tutorial" and trimid as "tutorial_trim"  
-// registering said Item with MODID "tutorial" and name "tutorial_armor_trim"  +    public static final class_1792 TUTORIAL_ARMOR_TRIM = register("tutorial_item_trim", class_8052.method_48418(new class_2960("tutorial", "tutorial_armor_trim")));
-public static void registerModItems() { +
-    Registry.register(Registries.ITEM, new Identifier("tutorial", "tutorial_armor_trim"), TUTORIAL_ARMOR_TRIM);  +
 } }
 </yarncode> </yarncode>
-and in the ModInitializer class:+ 
 +and in the ''ModInitializer'' class, initialize the class yet, if you haven't done it yet:
 <yarncode java [enable_line_numbers="true"]> <yarncode java [enable_line_numbers="true"]>
-// calling Item registration  +public class ExampleMod implements ModInitializer { 
-@Override   +    @Override 
-public void onInitialize() {   +    public void onInitialize() { 
-    ModItems.registerModItems();  +        TutorialItems.initialize(); 
 +    }
 } }
 </yarncode> </yarncode>
  
 And then just normal item textures if you desire so, but **NO LANG**, that comes later. 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)// ===+ 
 +===== Make it compatible with smithing table compatible =====
 To make it work with the smithing table, which is the goal, we need to create three files. 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 +==== Define the armor trim ==== 
-<file> +First we need to create a armor trim info file. This file is named ''tutorial_armor_trim.json'' and goes under ''resources/data/<namespace>/trim_pattern/''. These and any following names and paths have to be **exactly** like displayed (obviously you need to change namespace and item name, but you get what I mean).
-tutorial_armor_trim.json +
-</file> +
-and goes under+
-<file> +
-resources/data/minecraft/trim_pattern/ +
-</file> +
-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:\\  +Into this file we need to put these three things: 
-asset_id, wich is the bevor mentioned TrimId,\\  +  * ''asset_id''which is the before mentioned trimId 
-description, which links to the lang file (we'll get to that later)\\  +  * ''description'', which links to the lang file (we'll get to that later) 
-and the template_item, which is the item we're using.\\ +  * ''template_item'', which is the item we're using
  
 And this is what that looks like in the json file: And this is what that looks like in the json file:
-<code JavaScript>+<file JavaScript resources/data/tutorial/trim_pattern/tutorial_armor_trim.json>
 {   {  
   "asset_id": "minecraft:tutorial_armor_trim",     "asset_id": "minecraft:tutorial_armor_trim",  
Line 51: Line 48:
   "template_item": "tutorial:tutorial_armor_trim"     "template_item": "tutorial:tutorial_armor_trim"  
 } }
-</code> 
- 
-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  
-<file> 
-tutorial_armor_trim_smithing_trim.json 
 </file> </file>
-and it is placed at+ 
-<file> +==== Add smithing recipe ==== 
-resources/data/minecraft/recipes/ +The second file we need, is the smithing trim recipe. 
-</file> + 
-Other than that, this is just recipe file and nothing interesting: +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/<namespace>/recipe/'' (since 1.21) or ''resources/data/<namespace>/recipes/'' (before 1.21). Other than that, this is just recipe file and nothing interesting: 
-<code JavaScript>+<file JavaScript resources/data/tutorial/recipe/tutorial_armor_trim_smithing_trim.json>
 {   {  
   "type": "minecraft:smithing_trim",     "type": "minecraft:smithing_trim",  
Line 76: Line 67:
   }     }  
 } }
-</code> 
-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: 
-<file> 
-trim_templates.json 
-</file> 
-and goes to: 
-<file> 
-resources/data/minecraft/tags/items/ 
 </file> </file>
 +Take note that only the last parameter ever changes and the first three stay the same.
 +
 +==== Add it to tags ====
 +The third file is technically optional, but we will still make it, because it's needed for the [[tags|tag]] search in the creative inventory and maybe something else. It is named ''trim_templates.json'' and goes to ''resources/data/<namespace>/tags/item/'' (since 1.21) or ''resources/data/<namespace>/tags/items/'' (before 1.21).
 +
 Inside the file is: Inside the file is:
-<code JavaScript>+<file JavaScript resources/data/minecraft/tags/item/trim_templates.json>
 {   {  
   "replace": false,     "replace": false,  
Line 96: Line 81:
   ]     ]  
 } }
-</code>+</file>
  
-Now if we would theoretically test this. It would workbut we would be greeted by the beautiful missing texture texture.\\  +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: 
-So we need to: + 
-== Make assets ==+===== Make assets =====
 Lets begin with making the trim textures first and then do the lang. 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.\\  +==== Add textures ==== 
-The file is name: +The first file we need just points to the different texture locations and that's pretty much it. 
-<file> + 
-armor_trims.json +The file is named ''armor_trims.json'' and belongs into the directory ''resources/assets/<namespace>/atlases/''Inside is: 
-</file> +<file JavaScript resources/assets/minecraft/atlases/armor_trims.json>
-and belongs into the directory+
-<file> +
-resources/assets/minecraft/atlases/ +
-</file> +
-Inside is: +
-<code JavaScript>+
 {   {  
   "sources": [     "sources": [  
Line 175: Line 154:
   ]     ]  
 } }
-</code>+</file>
  
-Now, the file has as lot inside but the only change is this tiny part:\\  +Now, the file has lot inside but the only change is this tiny part:
-<file>"trims/models/armor/tutorial_armor_trim",</file> \\  +
-<file>"trims/models/armor/tutorial_armor_trim_leggings"</file>\\  +
-The rest is just vanilla code we cant go around.\\ +
  
-The last two file we need for textures are: +  * ''trims/models/armor/tutorial_armor_trim'' 
-<file> +  * ''trims/models/armor/tutorial_armor_trim_leggings''
-tutorial_armor_trim.png +
-</file> +
-and: +
-<file> +
-tutorial_armor_trim_leggings.png +
-</file> +
-just like we change above. And that's also where they go. Both go into this directory: +
-<file> +
-resources/assets/minecraft/textures/trims/models/armor/ +
-</file> +
-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 even 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: <file>trim_pattern.tutorial.tutorial_armor_trim</file>\\  +The rest is just vanilla code we cant go around. 
-But this is an easy fix with some: + 
-== Translation == +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 directory ''resources/assets/minecraft/textures/trims/models/armor/''
-In the <file>en_us.json</file> file under: <file>resources/assets/tutorial/lang/</file> we need to put this just mentioned ugly text. Like this: + 
-<code JavaScript>+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. 
 + 
 +==== Add translations ==== 
 +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''. Therefore we need to add translations (see [[lang]]). 
 + 
 +In the ''en_us.json'' file under: ''resources/assets/tutorial/lang/'', we need to put thisjust mentionedugly text. Like this: 
 +<file JavaScript resources/assets/tutorial/lang/en_us.json>
 {   {  
   "trim_pattern.tutorial.tutorial_armor_trim": "Tutorial Armor Trim"     "trim_pattern.tutorial.tutorial_armor_trim": "Tutorial Armor Trim"  
 } }
-</code+</file
-But with this final step, we are done. Have fun with your new armor trims.\\ +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:  [[https://github.com/HerrChaos/smithing-template-tutorial-mod|GitHub]] 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:  [[https://github.com/HerrChaos/smithing-template-tutorial-mod|GitHub]]
tutorial/armor_trim.1715513820.txt.gz · Last modified: 2024/05/12 11:37 by herr_chaos