Java 类net.minecraft.util.CombatRules 实例源码
项目:FirstAid
文件:ArmorUtils.java
/**
* 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;
}
项目:Backmemed
文件:EntityLivingBase.java
/**
* 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;
}
项目:Backmemed
文件:EntityLivingBase.java
/**
* 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;
}
}
}
项目:CustomWorldGen
文件:EntityLivingBase.java
/**
* 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;
}
项目:CustomWorldGen
文件:EntityLivingBase.java
/**
* 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;
}
}
}
项目:ExpandedRailsMod
文件:EntityLivingBase.java
/**
* 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;
}
项目:ExpandedRailsMod
文件:EntityLivingBase.java
/**
* 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;
}
}
}
项目:Mods
文件:TF2EventsCommon.java
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));
}