Hey guys So I had a little tutorial topic back in the day that was sort of popular, but that was a long time ago. Now the APIs have changed, Minecraft has been updated tons, and I'm trying to get back into modding. So I've decided to start a new tutorial topic on some of the harder stuff (the basics have been covered multiple times) that I learn while working on my mod.
Taking video tutorial requests on existing tutorials!
I will do my best to keep these tutorials up to date for as long as I can
When posting errors make sure to use code tags [ code][ /code] (without the spaces) and post the class code that the error pertains you while also either bolding or explicitly stating which line the error refers to, because sometimes the width of this forum is not great enough to correctly display the lines.
Tutorial List Custom Armor Custom Creative Tab
Custom Armor
For this tutorial I assume you already have your base mod class set up.
All existing vanilla textures can be found under YOURFORGEFOLDER\mcp\temp\bin\minecraft\armor and \textures
Ok, so we're going to learn how to create custom armor. To start, make sure you have these texture directories set up: one under YOURFORGEFOLDER\mcp\src\minecraft\mods\YOURMOD\textures\items
and the other also under textures but named "armor" (without the quotes). The inventory icons will go into the items folder while the on-character images go into armor.
Now onto the coding. Let's start with your base mod class. First you need to create a material for these items. You create an armor material like this:
public static EnumArmorMaterial tutArmor = EnumHelper.addArmorMaterial("TutArmor", 15, new int [] {2, 5, 4, 3}, 10);
Let's break this down. "TUTArmor" is self-explanatory, it's the armor name, but I'm not even sure where it's used or why it's needed. 15 is the endurance of the armor, I'm not sure how it's counted, but you can reference the other materials in the EnumArmorMaterial class. For convenience I have included them here:
CLOTH(5, new int[]{1, 3, 2, 1}, 15),//this is leather
CHAIN(15, new int[]{2, 5, 4, 1}, 12),
IRON(15, new int[]{2, 6, 5, 2}, 9),
GOLD(7, new int[]{2, 5, 3, 1}, 25),
DIAMOND(33, new int[]{3, 8, 6, 3}, 10);
This also brings us to the integer array and the number 10. The array says how many shields are filled by each piece of armor (they are counted in half shields). The 10 is the enchantability, which is also quite self-explanatory, just reference the other materials. Now underneath that declare and initialize the armor items like this:
public static Item tutHelm = new TutorialArmor(5000, tutArmor, 0, 0).setCreativeTab(CreativeTabs.tabCombat)
.setUnlocalizedName("tutHelm");
public static Item tutPlate = new TutorialArmor(5002, tutArmor, 0, 1).setCreativeTab(CreativeTabs.tabCombat)
.setUnlocalizedName("tutPlate");
public static Item tutLegs = new TutorialArmor(5003, tutArmor, 0, 2).setCreativeTab(CreativeTabs.tabCombat)
.setUnlocalizedName("tutLegs");
public static Item tutBoots = new TutorialArmor(5004, tutArmor, 0, 3).setCreativeTab(CreativeTabs.tabCombat)
.setUnlocalizedName("tutBoots");
If you have created an item already this shouldn't be too new. By the way, you will get an error because we haven't created the armor class yet, but we'll get to that. The first number in each initialization is the id, I'm assuming you already know how that works if you're this far into making a mod. The second parameter is the armor material, in here you put your armor material name. The second number is for the render prefix for the player. Some tutorials I followed had you add stuff to the proxy classes, but that didn't work for me nor do I think it was necessary, so I found an easier and better method to make the player render correctly. So, until I either figure why you might need to mess with the proxies for this or one of you do, leave this at 0. The third number is says what type of armor piece it is, 0 is the helmet, 1 the plate, etc. They are all shown in the code. The creative tab for these kind of items is the combat tab, but you can omit this part if you don't want/don't need people to access it easily in creative mode. For your own creative tab for your own mod I will make a tutorial later Setting the unlocalized name is probably for the textures, but since we override that later anyways I don't think it's too important, but you should probably leave it to be safe.
Now, you should know how to add the in-game names and crafting recipes, but if you don't I'll post them here. These go in the load method (I used sticks for the crafting because it was not necessary to create a new item for these demonstration purposes, just replace sticks with your item):
Let's get onto the armor class. It has to extend ItemArmor and once you have finished inheriting the constructor add this method for the inventory icons:
This is a lot simpler than it may look. The if statement checks what type of armor piece it is, to display the correct icon. The four strings you see state the location of the textures. The part before the colon is the folder under "mods" that I told you to create in the beginning. The part after the colon is the file name of the icon (without the .png). Now onto the perhaps more confusing looking player model textures for the armor. You have to have the method getArmorTexture override the method of the same name in Item. The finished method would look like this (with your mod items and images in place of mine):
Once again, you have an if statement to check the armor pieces. Note that the helmet, chest plate and boots are in first file, while the leggings are in the second one. Reference the existing armor images to create your own. Do not forget the first forward slash otherwise you'll have made the same mistake I made at first and be really confused as to why you were getting an error
Now you should be set! I hope this tutorial helped you further your mod and better understand the code you are developing
Custom Creative Tab
This is a lot easier than you might think. All you have to do is add this code to your mod class, replacing "Tut" to whatever you want:
public static CreativeTabs tabTut = new CreativeTabs("tabTut")
{
public ItemStack getIconItemStack()
{
return new ItemStack(Item.stick, 1, 0);
}
};
The stick, but once again you can change that to whatever you want, is used to display the tab (like the combat tab has a sword). Now when you use
.setCreativeTab()
you can just plug in your tab name like this:
.setCreativeTab(tabTut);
However, when you try this code you'll get a weird name when hovering over the tab. To correct this add this code to where all your other name registrations are:
After "itemGroup." comes whatever you put as the string for the name in the initializer of the tab. Then the last string is what you want to be displayed as the name.
That should be it Hope it helps!
Common Errors
Can't find the texture. Fix: Make sure you have the path perfectly correctly entered with a / preceding all of it.
Can't override a method. Fix: Either make sure you have correctly spelled the name and have all the same parameters as the super method and/or check to make sure you imported the correct classes from the Minecraft packages and nowhere else.
Holy you're back Josh! You taught me loads! Check out what Ive made since(click the link in the banner)
Haha yep And I hope to stay at least throughout the summer.
I've seen that mod and I have to say, it looks amazing! And to think, I helped its lead coder in his modding career
Hello Josh!
I'm using 1.5.2 Forge and Forge Modloader and my problem is that I can't override "public String getArmorTexture()" because there's no so such method in any of the super classes:(( The error it says is that it can't find the armor texture files in the vanilla armor folder, however I my return values are direct paths like "mods/millersmods/armor/mageset1_1.png"
Could you give some suggestions please?:)
You missed the part that was really important about that part I think I'll bold it so no one else will miss it. You need the first / before mods otherwise it can't find the textures.
Ohh the "/" was there I just accidentaly didn't copy it into my previous post. But I still have an error at the method header which says: remove annitation Override or create a "getArmorTexture()" in one of the superclasses (however my method header looks like: "public String getArmorTexture(ItemStack stack, Entity entity, int slot, int layer)" ) :/
I don't understand the problem at all, because, there is a getArmorTexture(...) in the super type (Item) but it just can't override it.
Do you have any ideas?
Does it extend ItemArmor correctly? If it does and you still have a problem then post the code here, it should make it a lot easier to fix
Thank you, Toffie. Had I not had to fix my internet I would have given him that same answer I'll make sure to put that as a note to watch out for in the OP!
Hey! It's nice to see you here again StrongJoshua. I've was making one mod with using your tutorials back in 1.3.2 (Or was it ever earlier?...) and now I think its time to start again. Your tutorials always helped me so thanks for them and please continue. Only bug I got is with the creative tab... Not sure why, but it doesn't show all of my items. I have
this.setCreativeTab(Collectables.tabCollect)
in every item class, but somewhy one of them doesn't show. I will try recompiling again, but any help would be appreciated.
If the "re-recompile" does not end up working then please post your code here and I'll try to find the error
Oh lol... After hour of searching trough the code, I found out that I used same ID for two items... Solved.
Haha it happens I think forge even says it, in the terminal, when you run the game through eclipse that there are conflicting IDs, you just have to be lucky and manage to see it when it flies through :3
Instead of using the LanguageRegistry why not use the getTranslatedTabLabel() method?
Using the LanguageRegistry allows Forge modders to add language specific translations in a unified database.
If you don't use it, other mods that expect your items to use the LanguageRegistry will not properly handle your items, and it will make supplying translations for your items in other languages more difficult.
Using the LanguageRegistry allows Forge modders to add language specific translations in a unified database.
If you don't use it, other mods that expect your items to use the LanguageRegistry will not properly handle your items, and it will make supplying translations for your items in other languages more difficult.
I get what you mean, but there is no reason for a different modder to have the name of a Creative Tab. For the translated stuff, yeah but I don't see the reason to translate a mod name which you usally have for the creative tab name either way.
The Meaning of Life, the Universe, and Everything.
Location:
Where the Red Fern Grows
Join Date:
6/3/2012
Posts:
126
Minecraft:
totestots
Member Details
I'd be happy for a tutorial on GUIs that take on a certain item, have the tileentity storing various information, and use it to handle whatever item you put in and output an item in return.
Rollback Post to RevisionRollBack
Tinkerer of magic, queen of the turtle army, and cuddler of all things fluffy
public BudderArmor(int ItemID, EnumArmorMaterial Material,
int par3, int par4) {
super(ItemID, Material, par3, par4);
// TODO Auto-generated constructor stub
}
Hey guys So I had a little tutorial topic back in the day that was sort of popular, but that was a long time ago. Now the APIs have changed, Minecraft has been updated tons, and I'm trying to get back into modding. So I've decided to start a new tutorial topic on some of the harder stuff (the basics have been covered multiple times) that I learn while working on my mod.
Taking video tutorial requests on existing tutorials!
I will do my best to keep these tutorials up to date for as long as I can
When posting errors make sure to use code tags [ code][ /code] (without the spaces) and post the class code that the error pertains you while also either bolding or explicitly stating which line the error refers to, because sometimes the width of this forum is not great enough to correctly display the lines.
Tutorial List
Custom Armor
Custom Creative Tab
All existing vanilla textures can be found under YOURFORGEFOLDER\mcp\temp\bin\minecraft\armor and \textures
Ok, so we're going to learn how to create custom armor. To start, make sure you have these texture directories set up: one under
YOURFORGEFOLDER\mcp\src\minecraft\mods\YOURMOD\textures\items
and the other also under textures but named "armor" (without the quotes). The inventory icons will go into the items folder while the on-character images go into armor.
Now onto the coding. Let's start with your base mod class. First you need to create a material for these items. You create an armor material like this:
Let's break this down. "TUTArmor" is self-explanatory, it's the armor name, but I'm not even sure where it's used or why it's needed. 15 is the endurance of the armor, I'm not sure how it's counted, but you can reference the other materials in the EnumArmorMaterial class. For convenience I have included them here:
This also brings us to the integer array and the number 10. The array says how many shields are filled by each piece of armor (they are counted in half shields). The 10 is the enchantability, which is also quite self-explanatory, just reference the other materials. Now underneath that declare and initialize the armor items like this:
If you have created an item already this shouldn't be too new. By the way, you will get an error because we haven't created the armor class yet, but we'll get to that. The first number in each initialization is the id, I'm assuming you already know how that works if you're this far into making a mod. The second parameter is the armor material, in here you put your armor material name. The second number is for the render prefix for the player. Some tutorials I followed had you add stuff to the proxy classes, but that didn't work for me nor do I think it was necessary, so I found an easier and better method to make the player render correctly. So, until I either figure why you might need to mess with the proxies for this or one of you do, leave this at 0. The third number is says what type of armor piece it is, 0 is the helmet, 1 the plate, etc. They are all shown in the code. The creative tab for these kind of items is the combat tab, but you can omit this part if you don't want/don't need people to access it easily in creative mode. For your own creative tab for your own mod I will make a tutorial later Setting the unlocalized name is probably for the textures, but since we override that later anyways I don't think it's too important, but you should probably leave it to be safe.
Now, you should know how to add the in-game names and crafting recipes, but if you don't I'll post them here. These go in the load method (I used sticks for the crafting because it was not necessary to create a new item for these demonstration purposes, just replace sticks with your item):
Let's get onto the armor class. It has to extend ItemArmor and once you have finished inheriting the constructor add this method for the inventory icons:
This is a lot simpler than it may look. The if statement checks what type of armor piece it is, to display the correct icon. The four strings you see state the location of the textures. The part before the colon is the folder under "mods" that I told you to create in the beginning. The part after the colon is the file name of the icon (without the .png). Now onto the perhaps more confusing looking player model textures for the armor. You have to have the method getArmorTexture override the method of the same name in Item. The finished method would look like this (with your mod items and images in place of mine):
Once again, you have an if statement to check the armor pieces. Note that the helmet, chest plate and boots are in first file, while the leggings are in the second one. Reference the existing armor images to create your own. Do not forget the first forward slash otherwise you'll have made the same mistake I made at first and be really confused as to why you were getting an error
Now you should be set! I hope this tutorial helped you further your mod and better understand the code you are developing
This is a lot easier than you might think. All you have to do is add this code to your mod class, replacing "Tut" to whatever you want:
The stick, but once again you can change that to whatever you want, is used to display the tab (like the combat tab has a sword). Now when you use
you can just plug in your tab name like this:
However, when you try this code you'll get a weird name when hovering over the tab. To correct this add this code to where all your other name registrations are:
After "itemGroup." comes whatever you put as the string for the name in the initializer of the tab. Then the last string is what you want to be displayed as the name.
That should be it Hope it helps!
Common Errors
Also, check out my YouTube channel: www.YouTube.com/StrongJoshua
Haha yep And I hope to stay at least throughout the summer.
I've seen that mod and I have to say, it looks amazing! And to think, I helped its lead coder in his modding career
Also, check out my YouTube channel: www.YouTube.com/StrongJoshua
Also, check out my YouTube channel: www.YouTube.com/StrongJoshua
Also, check out my YouTube channel: www.YouTube.com/StrongJoshua
That's a good idea! Once I learn it I'll make one, maybe even tomorrow
Also, check out my YouTube channel: www.YouTube.com/StrongJoshua
You missed the part that was really important about that part I think I'll bold it so no one else will miss it. You need the first / before mods otherwise it can't find the textures.
Also, check out my YouTube channel: www.YouTube.com/StrongJoshua
Does it extend ItemArmor correctly? If it does and you still have a problem then post the code here, it should make it a lot easier to fix
Also, check out my YouTube channel: www.YouTube.com/StrongJoshua
with this
Thank you, Toffie. Had I not had to fix my internet I would have given him that same answer I'll make sure to put that as a note to watch out for in the OP!
Also, check out my YouTube channel: www.YouTube.com/StrongJoshua
If the "re-recompile" does not end up working then please post your code here and I'll try to find the error
Also, check out my YouTube channel: www.YouTube.com/StrongJoshua
Haha it happens I think forge even says it, in the terminal, when you run the game through eclipse that there are conflicting IDs, you just have to be lucky and manage to see it when it flies through :3
Also, check out my YouTube channel: www.YouTube.com/StrongJoshua
Like this:
Using the LanguageRegistry allows Forge modders to add language specific translations in a unified database.
If you don't use it, other mods that expect your items to use the LanguageRegistry will not properly handle your items, and it will make supplying translations for your items in other languages more difficult.
I get what you mean, but there is no reason for a different modder to have the name of a Creative Tab. For the translated stuff, yeah but I don't see the reason to translate a mod name which you usally have for the creative tab name either way.
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.item.EnumArmorMaterial;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
public class BudderArmor extends ItemArmor{;
public BudderArmor(int ItemID, EnumArmorMaterial Material,
int par3, int par4) {
super(ItemID, Material, par3, par4);
// TODO Auto-generated constructor stub
}
public void registerIcons(IconRegister iRegister)
{
if(this.armorType == 0)
itemIcon = iRegister.registerIcon("Funnycracker715:budderHelm");
else if(this.armorType == 1)
itemIcon = iRegister.registerIcon("Funnycracker715:budderPlate");
else if(this.armorType == 2)
itemIcon = iRegister.registerIcon("Funnycracker715:budderLegs");
else if(this.armorType == 3)
itemIcon = iRegister.registerIcon("Funnycracker715:budderBoots");}
@Override
public String getArmorTexture(ItemStack armor, Entity entity, int slot, int layer)
{
if(slot == 0 || slot == 1 || slot == 3)
return "/mods/Funnycracker715/textures/armor/budder_1.png";
else if(slot == 2)return "/mods/Funnycracker715/textures/armor/budder_2.png";
else return null;}
{
}
}