    001package net.minecraft.item;
    002
    003public enum EnumArmorMaterial
    004{
    005    CLOTH(5, new int[]{1, 3, 2, 1}, 15),
    006    CHAIN(15, new int[]{2, 5, 4, 1}, 12),
    007    IRON(15, new int[]{2, 6, 5, 2}, 9),
    008    GOLD(7, new int[]{2, 5, 3, 1}, 25),
    009    DIAMOND(33, new int[]{3, 8, 6, 3}, 10);
    010
    011    /**
    012     * Holds the maximum damage factor (each piece multiply this by it's own value) of the material, this is the item
    013     * damage (how much can absorb before breaks)
    014     */
    015    private int maxDamageFactor;
    016
    017    /**
    018     * Holds the damage reduction (each 1 points is half a shield on gui) of each piece of armor (helmet, plate, legs
    019     * and boots)
    020     */
    021    private int[] damageReductionAmountArray;
    022
    023    /** Return the enchantability factor of the material */
    024    private int enchantability;
    025
    026    //Added by forge for custom Armor materials.
    027    public Item customCraftingMaterial = null;
    028
    029    private EnumArmorMaterial(int par3, int[] par4ArrayOfInteger, int par5)
    030    {
    031        this.maxDamageFactor = par3;
    032        this.damageReductionAmountArray = par4ArrayOfInteger;
    033        this.enchantability = par5;
    034    }
    035
    036    /**
    037     * Returns the durability for a armor slot of for this type.
    038     */
    039    public int getDurability(int par1)
    040    {
    041        return ItemArmor.getMaxDamageArray()[par1] * this.maxDamageFactor;
    042    }
    043
    044    /**
    045     * Return the damage reduction (each 1 point is a half a shield on gui) of the piece index passed (0 = helmet, 1 =
    046     * plate, 2 = legs and 3 = boots)
    047     */
    048    public int getDamageReductionAmount(int par1)
    049    {
    050        return this.damageReductionAmountArray[par1];
    051    }
    052
    053    /**
    054     * Return the enchantability factor of the material.
    055     */
    056    public int getEnchantability()
    057    {
    058        return this.enchantability;
    059    }
    060
    061    /**
    062     * Return the crafting material for this armor material, used to determine the item that can be used to repair an
    063     * armor piece with an anvil
    064     */
    065    public int getArmorCraftingMaterial()
    066    {
    067        switch (this)
    068        {
    069            case CLOTH:   return Item.leather.itemID;
    070            case CHAIN:   return Item.ingotIron.itemID;
    071            case GOLD:    return Item.ingotGold.itemID;
    072            case IRON:    return Item.ingotIron.itemID;
    073            case DIAMOND: return Item.diamond.itemID;
    074            default:      return (customCraftingMaterial == null ? 0 : customCraftingMaterial.itemID);
    075        }
    076    }
    077}