Falling damage is now affected by Feather Falling properly.

This commit is contained in:
sigonasr2 2016-08-23 21:03:33 -05:00
parent dab6ca8a5f
commit 6c16d1c816
3 changed files with 16 additions and 0 deletions

Binary file not shown.

View File

@ -3333,6 +3333,17 @@ public class GenericFunctions {
//We cleared the non-living entities, deal damage to the rest. //We cleared the non-living entities, deal damage to the rest.
} }
public static double CalculateFallResistance(LivingEntity l) {
int featherfalllv = 0;
ItemStack[] equips = l.getEquipment().getArmorContents();
for (int i=0;i<equips.length;i++) {
if (equips[i]!=null && equips[i].getType()!=Material.AIR && equips[i].containsEnchantment(Enchantment.PROTECTION_FALL)) {
featherfalllv+=equips[i].getEnchantmentLevel(Enchantment.PROTECTION_FALL);
}
}
return 1-(featherfalllv*0.01);
}
private static double CalculateBlastResistance(LivingEntity l) { private static double CalculateBlastResistance(LivingEntity l) {
int explosionlv = 0; int explosionlv = 0;
ItemStack[] equips = l.getEquipment().getArmorContents(); ItemStack[] equips = l.getEquipment().getArmorContents();

View File

@ -4135,6 +4135,11 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
if (ev.getCause()!=DamageCause.CUSTOM) { //This is not handled damage, so apply it. if (ev.getCause()!=DamageCause.CUSTOM) { //This is not handled damage, so apply it.
double dmgdealt = ev.getDamage(DamageModifier.BASE); double dmgdealt = ev.getDamage(DamageModifier.BASE);
CustomDamage.setupTrueDamage(ev); CustomDamage.setupTrueDamage(ev);
if (ev.getCause()==DamageCause.FALL) {
dmgdealt *= GenericFunctions.CalculateFallResistance((LivingEntity)ev.getEntity());
}
CustomDamage.ApplyDamage(dmgdealt, null, (LivingEntity)ev.getEntity(), null, ev.getCause().name(), CustomDamage.TRUEDMG); CustomDamage.ApplyDamage(dmgdealt, null, (LivingEntity)ev.getEntity(), null, ev.getCause().name(), CustomDamage.TRUEDMG);
ev.setCancelled(true); ev.setCancelled(true);
} else } else