Java 类net.minecraftforge.common.ISpecialArmor 实例源码

项目:armor-chroma    文件:GuiArmor.java   
/** @return The points gained from a single item in the player's armor
 * @see ForgeHooks#getTotalArmorValue() */
private static int getArmorPoints(EntityPlayer player, int slot) {
    ItemStack stack = player.inventory.armorItemInSlot(slot);

    if(stack != null) {
        Item item = stack.getItem();

        // Allow for custom calculations
        if(item instanceof ISpecialArmor) {
            return ((ISpecialArmor)item).getArmorDisplay(player, stack, slot);
        } else if(item instanceof ItemArmor) {
            return ((ItemArmor)item).damageReduceAmount;
        }
    }
    return 0;
}
项目:ExtraAcC    文件:ItemImagEnergyArmor.java   
@Override
public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) {
    if (source.isUnblockable()) {
        return new ISpecialArmor.ArmorProperties(0, 0.0D, 0);
    }
    double absorptionRatio = getBaseAbsorptionRatio() * getDamageAbsorptionRatio();
    int damageLimit = (int) (25 * itemManager.getEnergy(armor) / getEnergyPerDamage());
    return new ISpecialArmor.ArmorProperties(0, absorptionRatio, damageLimit);
}
项目:4Space-5    文件:EntityPlayer.java   
protected void damageEntity(DamageSource p_70665_1_, float p_70665_2_)
{
    if (!isEntityInvulnerable())
    {
        p_70665_2_ = ForgeHooks.onLivingHurt(this, p_70665_1_, p_70665_2_);
        if (p_70665_2_ <= 0.0F) {
            return;
        }
        if ((!p_70665_1_.isUnblockable()) && (isBlocking()) && (p_70665_2_ > 0.0F)) {
            p_70665_2_ = (1.0F + p_70665_2_) * 0.5F;
        }
        p_70665_2_ = ISpecialArmor.ArmorProperties.ApplyArmor(this, this.inventory.armorInventory, p_70665_1_, p_70665_2_);
        if (p_70665_2_ <= 0.0F) {
            return;
        }
        p_70665_2_ = applyPotionDamageCalculations(p_70665_1_, p_70665_2_);
        float f1 = p_70665_2_;
        p_70665_2_ = Math.max(p_70665_2_ - getAbsorptionAmount(), 0.0F);
        setAbsorptionAmount(getAbsorptionAmount() - (f1 - p_70665_2_));
        if (p_70665_2_ != 0.0F)
        {
            addExhaustion(p_70665_1_.getHungerDamage());
            float f2 = getHealth();
            setHealth(getHealth() - p_70665_2_);
            func_110142_aN().func_94547_a(p_70665_1_, f2, p_70665_2_);
        }
    }
}
项目:Gravitation-Suite-Reloaded    文件:ItemElectricArmor.java   
@Override
public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) {
    if (source.isUnblockable()) {
        return new ISpecialArmor.ArmorProperties(0, 0.0D, 0);
    }
    double absorptionRatio = this.baseAbsorptionRatio * this.damageAbsorptionRatio;

    int damageLimit = Integer.MAX_VALUE;
    if (this.energyPerDamage > 0) {
        damageLimit = (int)Math.min(damageLimit, 25.0D * ElectricItem.manager.getCharge(armor) / this.energyPerDamage);
    }
    return new ISpecialArmor.ArmorProperties(0, absorptionRatio, damageLimit);
}
项目:4Space-1.7    文件:EntityPlayer.java   
protected void damageEntity(DamageSource p_70665_1_, float p_70665_2_)
{
    if (!isEntityInvulnerable())
    {
        p_70665_2_ = ForgeHooks.onLivingHurt(this, p_70665_1_, p_70665_2_);
        if (p_70665_2_ <= 0.0F) {
            return;
        }
        if ((!p_70665_1_.isUnblockable()) && (isBlocking()) && (p_70665_2_ > 0.0F)) {
            p_70665_2_ = (1.0F + p_70665_2_) * 0.5F;
        }
        p_70665_2_ = ISpecialArmor.ArmorProperties.ApplyArmor(this, this.inventory.armorInventory, p_70665_1_, p_70665_2_);
        if (p_70665_2_ <= 0.0F) {
            return;
        }
        p_70665_2_ = applyPotionDamageCalculations(p_70665_1_, p_70665_2_);
        float f1 = p_70665_2_;
        p_70665_2_ = Math.max(p_70665_2_ - getAbsorptionAmount(), 0.0F);
        setAbsorptionAmount(getAbsorptionAmount() - (f1 - p_70665_2_));
        if (p_70665_2_ != 0.0F)
        {
            addExhaustion(p_70665_1_.getHungerDamage());
            float f2 = getHealth();
            setHealth(getHealth() - p_70665_2_);
            func_110142_aN().func_94547_a(p_70665_1_, f2, p_70665_2_);
        }
    }
}
项目:Electro-Magic-Tools    文件:ItemElectricGoggles.java   
@Override
public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) {
    if (source.isUnblockable()) {
        return new net.minecraftforge.common.ISpecialArmor.ArmorProperties(0, 0.0D, 0);
    } else {
        double absorptionRatio = getBaseAbsorptionRatio() * getDamageAbsorptionRatio();
        int energyPerDamage = getEnergyPerDamage();
        double damageLimit = energyPerDamage <= 0 ? 0 : (25 * ElectricItem.manager.getCharge(armor)) / energyPerDamage;
        return new net.minecraftforge.common.ISpecialArmor.ArmorProperties(0, absorptionRatio, (int) damageLimit);
    }
}
项目:Electro-Magic-Tools    文件:ItemNanoWing.java   
@Override
public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) {
    if (source.isUnblockable()) {
        return new net.minecraftforge.common.ISpecialArmor.ArmorProperties(0, 0.0D, 3);
    } else {
        double absorptionRatio = getBaseAbsorptionRatio() * getDamageAbsorptionRatio();
        int energyPerDamage = getEnergyPerDamage();
        double damageLimit = energyPerDamage <= 0 ? 0 : (25 * ElectricItem.manager.getCharge(armor)) / energyPerDamage;
        return new net.minecraftforge.common.ISpecialArmor.ArmorProperties(3, absorptionRatio, (int) damageLimit);
    }
}
项目:Electro-Magic-Tools    文件:ItemElectricBootsTraveller.java   
@Override
public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) {
    if (source.isUnblockable()) {
        return new net.minecraftforge.common.ISpecialArmor.ArmorProperties(0, 0.0D, 3);
    } else {
        double absorptionRatio = getBaseAbsorptionRatio() * getDamageAbsorptionRatio();
        int energyPerDamage = getEnergyPerDamage();
        double damageLimit = energyPerDamage <= 0 ? 0 : (25 * ElectricItem.manager.getCharge(armor)) / energyPerDamage;
        return new net.minecraftforge.common.ISpecialArmor.ArmorProperties(3, absorptionRatio, (int) damageLimit);
    }
}
项目:WeaponsMod    文件:ItemInfoHelmet.java   
/**
 * Inherited from ISpecialArmor, allows significant customization of damage
 * calculations.
 */
@Override
public ISpecialArmor.ArmorProperties getProperties(EntityLiving player, ItemStack armor, DamageSource source, double damage, int slot) {
    // Order in which this armor is assessed for damage. Higher(?) priority
    // items take damage first, and if none spills over, the other items
    // take no damage.
    int priority = 1;
    double armorDouble;

    if (player instanceof EntityPlayer) {
        armorDouble = getArmorDouble((EntityPlayer) player, armor);
    } else {
        armorDouble = 2;
    }

    // How much of incoming damage is absorbed by this armor piece.
    // 1.0 = absorbs all damage
    // 0.5 = 50% damage to item, 50% damage carried over
    double absorbRatio = 0.04 * armorDouble;

    // Maximum damage absorbed by this piece. Actual damage to this item
    // will be clamped between (damage * absorbRatio) and (absorbMax). Note
    // that a player has 20 hp (1hp = 1 half-heart)
    int absorbMax = (int) armorDouble * 75; // Not sure why this is
    // necessary but oh well
    if (source.isUnblockable()) {
        absorbMax = 0;
        absorbRatio = 0;
    }
    return new ArmorProperties(priority, absorbRatio, absorbMax);
}
项目:WeaponsMod    文件:ItemJetPack.java   
/**
 * Inherited from ISpecialArmor, allows significant customization of damage
 * calculations.
 */
@Override
public ISpecialArmor.ArmorProperties getProperties(EntityLiving player, ItemStack armor, DamageSource source, double damage, int slot) {
    // Order in which this armor is assessed for damage. Higher(?) priority
    // items take damage first, and if none spills over, the other items
    // take no damage.
    int priority = 1;
    double armorDouble;

    if (player instanceof EntityPlayer) {
        armorDouble = getArmorDouble((EntityPlayer) player, armor);
    } else {
        armorDouble = 2;
    }

    // How much of incoming damage is absorbed by this armor piece.
    // 1.0 = absorbs all damage
    // 0.5 = 50% damage to item, 50% damage carried over
    double absorbRatio = 0.04 * armorDouble;

    // Maximum damage absorbed by this piece. Actual damage to this item
    // will be clamped between (damage * absorbRatio) and (absorbMax). Note
    // that a player has 20 hp (1hp = 1 half-heart)
    int absorbMax = (int) armorDouble * 75; // Not sure why this is
    // necessary but oh well
    if (source.isUnblockable()) {
        absorbMax = 0;
        absorbRatio = 0;
    }
    return new ArmorProperties(priority, absorbRatio, absorbMax);
}
项目:WeaponsMod    文件:ItemJetBoots.java   
/**
 * Inherited from ISpecialArmor, allows significant customization of damage
 * calculations.
 */
@Override
public ISpecialArmor.ArmorProperties getProperties(EntityLiving player, ItemStack armor, DamageSource source, double damage, int slot) {
    // Order in which this armor is assessed for damage. Higher(?) priority
    // items take damage first, and if none spills over, the other items
    // take no damage.
    int priority = 1;
    double armorDouble;

    if (player instanceof EntityPlayer) {
        armorDouble = getArmorDouble((EntityPlayer) player, armor);
    } else {
        armorDouble = 2;
    }

    // How much of incoming damage is absorbed by this armor piece.
    // 1.0 = absorbs all damage
    // 0.5 = 50% damage to item, 50% damage carried over
    double absorbRatio = 0.04 * armorDouble;

    // Maximum damage absorbed by this piece. Actual damage to this item
    // will be clamped between (damage * absorbRatio) and (absorbMax). Note
    // that a player has 20 hp (1hp = 1 half-heart)
    int absorbMax = (int) armorDouble * 75; // Not sure why this is
    // necessary but oh well
    if (source.isUnblockable()) {
        absorbMax = 0;
        absorbRatio = 0;
    }
    return new ArmorProperties(priority, absorbRatio, absorbMax);
}
项目:ExPetrum    文件:PlayerManager.java   
public static float handleArmorProtection(EntityPlayer player, DamageSource source, float amount, ItemStack armor, BodyPart damaged, EntityEquipmentSlot slotDamaged)
{
    if (source.isUnblockable())
    {
        return amount;
    }

    Item armorItem = armor.getItem();
    if (armorItem instanceof ISpecialArmor)
    {
        ISpecialArmor specialArmor = (ISpecialArmor) armorItem;
        float value = ArmorProperties.applyArmor(player, NonNullList.withSize(1, armor), source, amount);
        specialArmor.damageArmor(player, armor, source, (int) amount / 2, slotDamaged.getSlotIndex());
        return value;
    }
    else
    {
        Multimap<String, AttributeModifier> modifiers = armor.getAttributeModifiers(slotDamaged);
        float toughnessMod = 1;
        for (AttributeModifier mod : modifiers.get(SharedMonsterAttributes.ARMOR_TOUGHNESS.getName()))
        {
            if (mod.getOperation() == 0)
            {
                toughnessMod += mod.getAmount();
            }
            else
            {
                toughnessMod *= mod.getAmount();
            }
        }

        if (player instanceof EntityPlayerMP)
        {
            if (armor.attemptDamageItem((int) (amount / 2), player.world.rand, (EntityPlayerMP) player))
            {
                armor.setCount(0);
            }
        }

        return amount * (1 / toughnessMod);
    }
}
项目:Better-Mushroom-Islands    文件:Armours.java   
@Override
public ArmorProperties getProperties(EntityLivingBase l, ItemStack s, DamageSource d, double amount, int slot) {
    return new ISpecialArmor.ArmorProperties(0, damageReduction, 50000);
}
项目:Clothier    文件:ArmorGoldArmor.java   
@Override
public ISpecialArmor.ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot)
{
    return new ArmorProperties(0,0,0);
}
项目:Clothier    文件:ArmorAgate.java   
@Override
public ISpecialArmor.ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot)
{
    return new ArmorProperties(0,0,0);
}
项目:Realms-of-Chaos    文件:ItemROCArmor.java   
@Override
public ArmorProperties getProperties(EntityLivingBase player,
        ItemStack armor, DamageSource source, double damage, int slot) {
    return new ISpecialArmor.ArmorProperties(0, damageReduction / 100,
            50000);
}
项目:BL2    文件:ItemArmorShield.java   
@Override
public ArmorProperties getProperties(EntityLiving player, ItemStack armor,
        DamageSource source, double damage, int slot) {
    // if(true)//shield activated
    // {

    ShieldAtributes atr = new ShieldAtributes(armor);
    int prevCharge = atr.charge;
    if (atr.charge > 0) {
        atr.hitTicker = 20;
    }
    if (atr.charge > 0)// can take more of the damage
    {
        // use energy for one damage
        // atr.charge = atr.charge - 10;
        if (armor.getItemDamage() == 4) {
            float g = (float) Math.random() * 100;

            if (g < 5) {

            } else {
                getHit(atr, damage);
            }
        } else {
            getHit(atr, damage);
        }
    }
    atr.rechargeTicker = atr.rechargeDelay;

    // got hit

    // getHit(armor);

    atr.save(armor);
    if (prevCharge > 0)
        return new ISpecialArmor.ArmorProperties(10, atr.absorbed / damage,
                Integer.MAX_VALUE);
    else
        return new ISpecialArmor.ArmorProperties(0,
                getBaseAbsorptionRatio(), 0);
}
项目:FallingEarth    文件:ItemMeteoriticArmor.java   
@Override
public ArmorProperties getProperties(EntityLiving var1, ItemStack var2, DamageSource var3, double var4, int var6)
{
    return new ISpecialArmor.ArmorProperties(0, 0.2D, 50000);
}