    001    package net.minecraft.enchantment;
    002
    003    import java.util.Random;
    004    import net.minecraft.item.ItemArmor;
    005    import net.minecraft.item.ItemStack;
    006
    007    public class EnchantmentDurability extends Enchantment
    008    {
    009        protected EnchantmentDurability(int par1, int par2)
    010        {
    011            super(par1, par2, EnumEnchantmentType.digger);
    012            this.setName("durability");
    013        }
    014
    015        /**
    016         * Returns the minimal value of enchantability needed on the enchantment level passed.
    017         */
    018        public int getMinEnchantability(int par1)
    019        {
    020            return 5 + (par1 - 1) * 8;
    021        }
    022
    023        /**
    024         * Returns the maximum value of enchantability nedded on the enchantment level passed.
    025         */
    026        public int getMaxEnchantability(int par1)
    027        {
    028            return super.getMinEnchantability(par1) + 50;
    029        }
    030
    031        /**
    032         * Returns the maximum level that the enchantment can have.
    033         */
    034        public int getMaxLevel()
    035        {
    036            return 3;
    037        }
    038
    039        public boolean func_92037_a(ItemStack par1ItemStack)
    040        {
    041            return par1ItemStack.isItemStackDamageable() ? true : super.func_92037_a(par1ItemStack);
    042        }
    043
    044        public static boolean func_92045_a(ItemStack par0ItemStack, int par1, Random par2Random)
    045        {
    046            return par0ItemStack.getItem() instanceof ItemArmor && par2Random.nextFloat() < 0.6F ? false : par2Random.nextInt(par1 + 1) > 0;
    047        }
    048    }