/** * Changed copy of the second part from {@link EnchantmentHelper#applyEnchantmentModifier(EnchantmentHelper.IModifier, ItemStack)} */ public static float applyEnchantmentModifiers(ItemStack stack, DamageSource source, float damage) { int k = EnchantmentHelper.getEnchantmentModifierDamage(() -> Iterators.singletonIterator(stack), source); k *= 4; if (k > 0) damage = CombatRules.getDamageAfterMagicAbsorb(damage, (float) k); return damage; }
/** * Reduces damage, depending on armor */ protected float applyArmorCalculations(DamageSource source, float damage) { if (!source.isUnblockable()) { this.damageArmor(damage); damage = CombatRules.getDamageAfterAbsorb(damage, (float)this.getTotalArmorValue(), (float)this.getEntityAttribute(SharedMonsterAttributes.ARMOR_TOUGHNESS).getAttributeValue()); } return damage; }
/** * Reduces damage, depending on potions */ protected float applyPotionDamageCalculations(DamageSource source, float damage) { if (source.isDamageAbsolute()) { return damage; } else { if (this.isPotionActive(MobEffects.RESISTANCE) && source != DamageSource.outOfWorld) { int i = (this.getActivePotionEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5; int j = 25 - i; float f = damage * (float)j; damage = f / 25.0F; } if (damage <= 0.0F) { return 0.0F; } else { int k = EnchantmentHelper.getEnchantmentModifierDamage(this.getArmorInventoryList(), source); if (k > 0) { damage = CombatRules.getDamageAfterMagicAbsorb(damage, (float)k); } return damage; } } }
public static float getDamageReduction(DamageSource source, EntityLivingBase living, float damage) { return CombatRules.getDamageAfterMagicAbsorb( CombatRules.getDamageAfterAbsorb(damage, living.getTotalArmorValue(), (float) living.getEntityAttribute(SharedMonsterAttributes.ARMOR_TOUGHNESS).getAttributeValue()), EnchantmentHelper.getEnchantmentModifierDamage(living.getArmorInventoryList(), source)); }