PARTICIPANT IN A FINALISTS JAM
This Blog is an entry in the completed Minetorials : Tutorials with a Minecraft Theme.

Minecraft Blogs / Tutorial

How to code Armor for minecraft 1.2.5 (SSP) [Minetorials entry]

  • 1,809 views, 1 today
  • 4
  • 0
  • 9
thynder's Avatar thynder
Level 43 : Master Modder
45
Hello, I will be showing you how to code a basic armor set.

It requires 3 new classes, a fresh minecraft
(no mods) and a set-up MCP. (If you don't know how to set-up MCP, just read along. If you do know how to set-up MCP, then skip to the coding part.)


  1. Setting Up MCP
To set-up MCP, you need to download the MCP version compatible with minecraft 1.2.5 (which I make this tutorial on).

You can download it here: http://www.mediafire.com/?c6liau295225253

After that, make a folder and extract the zip with winrar or 7-zip (or any other archiver software)

You'll see a list of folders showing up, what you want to do now is install modloader on your fresh minecraft. Then drag the minecraft.jar into the jars folder of MCP.

Then run the decompile.bat (or .sh on mac) and let it do its thing. It'll come up with a hunk failure, just leave that be, if you got any other errors, please retry the previous steps.

When it's done decompiling, you'll see even more folders have appeared, you can now use your text editor software to make classes (I use eclipse, but things like notepad++ work as well.)

2. Coding the armor
As I said this requires 3 classes: mod_YourModName.java ModItemArmor.java and ArmorMaterialMod.java

I will give you the code of these 3 classes one by one now:

mod_YourModName.java

package net.minecraft.src;

public class mod_YourModName extends BaseMod
{
public static final Item YourHelmet = (new ModItemArmor(5000, ArmorMaterialMod.YOURMATERIAL, ModLoader.addArmor("yourmaterial"), 0)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/YourArmor/YourHelmet.png")).setItemName("YourHelmet");
public static final Item YourChestPlate = (new ModItemArmor(5001, ArmorMaterialMod.YOURMATERIAL, ModLoader.addArmor("yourmaterial"), 1)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/YourArmor/YourChestplate.png")).setItemName("YourChestplate");
public static final Item YourLeggings = (new ModItemArmor(5002, ArmorMaterialMod.YOURMATERIAL, ModLoader.addArmor("yourmaterial"), 2)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/YourArmor/YourLeggings.png")).setItemName("YourLeggings");
public static final Item YourBoots = (new ModItemArmor(5003, ArmorMaterialMod.YOURMATERIAL, ModLoader.addArmor("yourmaterial"), 3)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/YourArmor/YourBoots.png")).setItemName("YourBoots");
public void load()
{
ModLoader.addName(YourHelmet, "Your Helmet");
ModLoader.addName(YourChestplate, "Your Chestplate");
ModLoader.addName(YourLeggings, "Your Leggings");
ModLoader.addName(YourBoots, "Your Boots");
YOURMATERIAL("yourmaterial", 7, 10, new int[] {2, 7, 5, 3}, 9);
ModLoader.addRecipe(new ItemStack (YourChestplate, 1), (new Object[] {"X X", "XXX", "XXX", Character.valueOf('X'), Block.cobblestone}));
ModLoader.addRecipe(new ItemStack (YourLeggings, 1), (new Object[] {"XXX", "X X", "X X", Character.valueOf('X'), Block.cobblestone}));
ModLoader.addRecipe(new ItemStack (YourBoots, 1), (new Object[] {" ", "X X", "X X", Character.valueOf('X'), Block.cobblestone}));
}

public String getVersion()
{
return "1.2.5";

}

}

ArmorMaterialMod.java

package net.minecraft.src;

import java.util.Random;

public enum ArmorMaterialMod
{
YOURMATERIAL("yourmaterial", 7, 10, new int[] {2, 7, 5, 3}, 9);
private int maxDamageFactor;
private int damageReductionAmountArray[];
private int enchantability;


private OreModArmorMaterial(String s, int i, int j, int ai[], int k)
{
maxDamageFactor = j;
damageReductionAmountArray = ai;
enchantability = k;
}

public int func_40576_a(int i)
{
return ItemArmor.getMaxDamageArray()[i] * maxDamageFactor;
}
public int getDamageReductionAmount(int i)
{
return damageReductionAmountArray[i];
}

public int getEnchantability()
{
return enchantability;
}


}

[b][i]ModItemArmor.java[/i][/b]

package net.minecraft.src;

public class ModItemArmor extends ItemArmor
{

private static final int maxDamageArray[] = {
11, 16, 15, 13
};
public final int armorType;
public final int damageReduceAmount;
public final int renderIndex;
private final ArmorMaterialMod material;

public ModItemArmor(int i, ArmorMaterialMod enumarmormaterial, int j, int k)
{
super(i, EnumArmorMaterial.DIAMOND, j, k);
material = enumarmormaterial;
armorType = k;
renderIndex = j;
damageReduceAmount = enumarmormaterial.getDamageReductionAmount(k);
setMaxDamage(enumarmormaterial.func_40576_a(k));
maxStackSize = 1;
}

public int getItemEnchantability()
{
return material.getEnchantability();d
}

static int[] getMaxDamageArray()
{
return maxDamageArray;
}

}

[size=small]3.[/size][size=medium] [b]Adjusting the armor[/b][/size]
[size=small]Now that you've coded it, you can adjust it to your likings, make it stronger or weaker, edit the names, the crafting recipe, etc.[/size]

[size=small]I'll explain some of the adjustments now:[/size]

[size=small]How to make it stronger:[/size]
[list=1]
[*][size=small]Go to ArmorMaterialMod.java[/size]
[*][size=small]Look for this line: [/size] YOURMATERIAL("yourmaterial", 7, 10, new int[] {2, 7, 5, 3}, 9);
[*]Edit YOURMATERIAL into the material of your armor (example: emerald)
[*]"yourmaterial" is the name of the material texture, which goes in minecraft.jar/armor (example: emerald_1.png and emerald_2.png)
[*]The 7 and 10 next to it are the strength, if you want stronger armor, make these higher
[/list]

How to edit the names:

[list=1]
[*]Go to mod_YourModName.java
[*]Every time I sead YourHelmet, YourChestplate, YourLeggings etc. change that to EmeraldHelmet, EmeraldChestplate and EmeraldLeggings (This is an example!)

[*]The ModLoader.addName line sets the in-game name of the item, it's the name between " ", the one before it is the variable, which you declared at the top lines (public static final Item YourHelmet <-- )
[/list]

How to edit the recipe:

[list=1]
[*]Go to mod_YourModName.java
[*]Look for the lines saying: ModLoader.addRecipe
[*]Go to the end and edit this: "# #", "###", "###", Character.valueOf('#'), Block.cobblestone});
[*]Edit it as much as you like. top middle bottom
[/list]

And there you have it, you coded your own armor set!

Just make the textures (YourHelmet.png, YourChestplate.png, YourLeggings.png, YourBoots.png) and make a folder called YourArmor, put these 4 textures in there and drop the folder in the minecraft.jar ( MCP/jars/minecraft.jar )
Also copy the diamond_1.png and diamond_2.png from minecraft.jar/armor and edit these so it looks like you want your armor to look. Then rename them to Emerald_1.png and Emerald_2.png (example!)

Drop these 2 textures in minecraft.jar/armor and you're done!

Enjoy the tutorial!
Tags

1 Update Logs

Error Fix : by thynder 07/31/2012 5:09:03 pmJul 31st, 2012

Sorry, I found an error in the code. It's fixed now.

If you find/get any errors in the code, please post it here.

Create an account or sign in to comment.

1
07/31/2012 4:31 pm
Level 46 : Master Unicorn
KillerUnicorns
KillerUnicorns's Avatar
Im having trouble with
ArmorMaterialMod.java theres a problem in this line

private OreModArmorMaterial(String s, int i, int j, int ai[], int k)

Im A noob and need help please respond fast
1
07/31/2012 5:08 pm
Level 43 : Master Modder
thynder
thynder's Avatar
Oh sorry, I simplified the template a bit, but I forgot this.

Change OreModArmorMaterial to ArmorMaterialMod
1
08/01/2012 5:25 pm
Level 46 : Master Unicorn
KillerUnicorns
KillerUnicorns's Avatar
Thanks!!!!!
1
07/30/2012 6:02 am
Level 80 : Elite Modder
JavaBuckets
JavaBuckets's Avatar
Well thats just right, also how i do :) Im a coder to... i do loads of stuff :) is there anyway we could do a mod together? also hope you are good at textured if yes, casue i suck :(
1
07/30/2012 3:41 pm
Level 43 : Master Modder
thynder
thynder's Avatar
Sure, I've already accepted you on skype
1
07/30/2012 3:44 pm
Level 80 : Elite Modder
JavaBuckets
JavaBuckets's Avatar
your skype name is thynder right?
1
07/31/2012 3:18 am
Level 43 : Master Modder
thynder
thynder's Avatar
darkthynder
1
07/30/2012 3:43 pm
Level 80 : Elite Modder
JavaBuckets
JavaBuckets's Avatar
Cool :)
1
07/30/2012 5:37 am
Level 27 : Expert Mage
NishyMode
NishyMode's Avatar
Nice tutorial :D
Diamond from me c:
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome