Basic Armor
Armor is very easy to understand, but the tutorial is kinda long.
First thing, if you want your armor to have different stats than the default armors in the game, is to create an Enum. Declare this next line of code inside your main mod file.
public static EnumArmorMaterial MYHTRIL= EnumHelper.addArmorMaterial("MYHTRIL", 47, new int[]{6, 10, 8, 6}, 28);
I'm going to start at the .addArmorMaterial line. First, "MYTHRIL" is the code name of your Enum.
Quickly skipping the 47, we move onto new int[]{}. This describes the amount of protection each armor piece will give, the first number being the helm, second the chestplate, third the legs and fourth the boots. These numbers show the amount on the shield bar of how much reduction these pieces will do. However, these are multiplied by the 47 to show how much damage is actually being reduce by the armor piece.
The 47 is a little difficult to understand at first. 47 is maximum damage factor, or the amount of damage each piece of armor can take before it breaks. This is multiplied by the next set of numbers to create the actual value. So, the armor pieces, don't actually take 47 hits and then break, they'll take 47 times the number allocated to each piece of armor.
Now to add the physical armor.
public final static Item MythHelm = (new BaseMythArmor(5000, MYTHRIL, 1, 0)).setUnlocalizedName("T45Helm").setCreativeTab(CreativeTabs.tabCombat);
public final static Item MythChest = (new BaseMythArmor(5001, MYTHRIL 1, 1)).setUnlocalizedName("T45Chest").setCreativeTab(CreativeTabs.tabCombat);
public final static Item MythLegs = (new BaseMythArmor(5002, MYTHRIL 1, 2)).setUnlocalizedName("T45Legs").setCreativeTab(CreativeTabs.tabCombat);
public final static Item MythBoots = (new BaseMythArmor(5003, MYTHRIL 1, 3)).setUnlocalizedName("T45Boots").setCreativeTab(CreativeTabs.tabCombat);
Just like declaring any other item, MythHelm and those names are the code name of the armor. BaseMythArmor is a class that you'll create to get the textures for the armors.
5000 is the ID, MYTHRIL is the Enum that you're calling. If you want to use an enum that already exists, do EnumArmorMaterial.<enummaterial>. The number 1 tells Minecraft his is the first set of armor you're using in your mod. If there's a second one, the number would also be 1. Don't ask me why.
The next set of numbers tell Minecraft what piece of armor that line is declaring. 0 is the helm, 1 is the chest, 2 is the legs and 3 is the boots.
setUnlocalizedName is the same as the item tutorial; so is setCreativeTab.
Now to create BaseMythArmor.class.
package tutorial.armor;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.item.EnumArmorMaterial;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.IArmorTextureProvider;
public class BaseMythArmor extends ItemArmor implements IArmorTextureProvider
{
public BaseMythArmor(int par1, EnumArmorMaterial par2EnumArmorMaterial, int par3, int par4)
{
super(par1, par2EnumArmorMaterial, par3, par4);
}
public void func_94581_a(IconRegister iconRegister)
{
iconIndex = iconRegister.registerIcon("blfngl" + ":" + this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".") + 1));
}
public String getArmorTextureFile(ItemStack par1)
{
if ( par1.itemID==TutorialMain.MythHelm.itemID||par1.itemID==TutorialMain.MythChest.itemID||par1.itemID==TutorialMain.MythBoots.itemID)
{
return "/blfngl/tutorial/textures/MythArmor_1.png";
}
if (par1.itemID==TutorialMain.MythLegs.itemID)
{
return "/blfngl/tutorial/textures/MythArmor_2.png";
}
return "/blfngl/tutorial/textures/MythArmor_1.png";
}
}
Skipping over the first two methods (you should know them by now), we see that getArmorTextureFile...gets the armor texture file. This is the image that will be the actual armor covering your player. The armor textures can be found in the minecraft.jar if you need some inspiration.
Looking at the first if statement we can see that it checks to make sure the player is wearing the helmet, chestplate and boots before adding the textures. The second if is the legs. This is how the textures "getting" works.
That should be it for armor! On to tools.
First thing, if you want your armor to have different stats than the default armors in the game, is to create an Enum. Declare this next line of code inside your main mod file.
public static EnumArmorMaterial MYHTRIL= EnumHelper.addArmorMaterial("MYHTRIL", 47, new int[]{6, 10, 8, 6}, 28);
I'm going to start at the .addArmorMaterial line. First, "MYTHRIL" is the code name of your Enum.
Quickly skipping the 47, we move onto new int[]{}. This describes the amount of protection each armor piece will give, the first number being the helm, second the chestplate, third the legs and fourth the boots. These numbers show the amount on the shield bar of how much reduction these pieces will do. However, these are multiplied by the 47 to show how much damage is actually being reduce by the armor piece.
The 47 is a little difficult to understand at first. 47 is maximum damage factor, or the amount of damage each piece of armor can take before it breaks. This is multiplied by the next set of numbers to create the actual value. So, the armor pieces, don't actually take 47 hits and then break, they'll take 47 times the number allocated to each piece of armor.
Now to add the physical armor.
public final static Item MythHelm = (new BaseMythArmor(5000, MYTHRIL, 1, 0)).setUnlocalizedName("T45Helm").setCreativeTab(CreativeTabs.tabCombat);
public final static Item MythChest = (new BaseMythArmor(5001, MYTHRIL 1, 1)).setUnlocalizedName("T45Chest").setCreativeTab(CreativeTabs.tabCombat);
public final static Item MythLegs = (new BaseMythArmor(5002, MYTHRIL 1, 2)).setUnlocalizedName("T45Legs").setCreativeTab(CreativeTabs.tabCombat);
public final static Item MythBoots = (new BaseMythArmor(5003, MYTHRIL 1, 3)).setUnlocalizedName("T45Boots").setCreativeTab(CreativeTabs.tabCombat);
Just like declaring any other item, MythHelm and those names are the code name of the armor. BaseMythArmor is a class that you'll create to get the textures for the armors.
5000 is the ID, MYTHRIL is the Enum that you're calling. If you want to use an enum that already exists, do EnumArmorMaterial.<enummaterial>. The number 1 tells Minecraft his is the first set of armor you're using in your mod. If there's a second one, the number would also be 1. Don't ask me why.
The next set of numbers tell Minecraft what piece of armor that line is declaring. 0 is the helm, 1 is the chest, 2 is the legs and 3 is the boots.
setUnlocalizedName is the same as the item tutorial; so is setCreativeTab.
Now to create BaseMythArmor.class.
package tutorial.armor;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.item.EnumArmorMaterial;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.IArmorTextureProvider;
public class BaseMythArmor extends ItemArmor implements IArmorTextureProvider
{
public BaseMythArmor(int par1, EnumArmorMaterial par2EnumArmorMaterial, int par3, int par4)
{
super(par1, par2EnumArmorMaterial, par3, par4);
}
public void func_94581_a(IconRegister iconRegister)
{
iconIndex = iconRegister.registerIcon("blfngl" + ":" + this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".") + 1));
}
public String getArmorTextureFile(ItemStack par1)
{
if ( par1.itemID==TutorialMain.MythHelm.itemID||par1.itemID==TutorialMain.MythChest.itemID||par1.itemID==TutorialMain.MythBoots.itemID)
{
return "/blfngl/tutorial/textures/MythArmor_1.png";
}
if (par1.itemID==TutorialMain.MythLegs.itemID)
{
return "/blfngl/tutorial/textures/MythArmor_2.png";
}
return "/blfngl/tutorial/textures/MythArmor_1.png";
}
}
Skipping over the first two methods (you should know them by now), we see that getArmorTextureFile...gets the armor texture file. This is the image that will be the actual armor covering your player. The armor textures can be found in the minecraft.jar if you need some inspiration.
Looking at the first if statement we can see that it checks to make sure the player is wearing the helmet, chestplate and boots before adding the textures. The second if is the legs. This is how the textures "getting" works.
That should be it for armor! On to tools.