/** @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; }
@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); }
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_); } } }
@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); }
@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); } }
@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); } }
/** * 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); }
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); } }
@Override public ArmorProperties getProperties(EntityLivingBase l, ItemStack s, DamageSource d, double amount, int slot) { return new ISpecialArmor.ArmorProperties(0, damageReduction, 50000); }
@Override public ISpecialArmor.ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) { return new ArmorProperties(0,0,0); }
@Override public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) { return new ISpecialArmor.ArmorProperties(0, damageReduction / 100, 50000); }
@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); }
@Override public ArmorProperties getProperties(EntityLiving var1, ItemStack var2, DamageSource var3, double var4, int var6) { return new ISpecialArmor.ArmorProperties(0, 0.2D, 50000); }