Fix invulnerability damage and armour (#12190)
This commit is contained in:
@@ -971,7 +971,7 @@
|
||||
int i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5;
|
||||
int i1 = 25 - i;
|
||||
float f = damageAmount * i1;
|
||||
@@ -1768,24 +_,212 @@
|
||||
@@ -1768,24 +_,219 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -984,7 +984,11 @@
|
||||
+ if (invulnerabilityRelatedLastDamage == 0) return 0D; // no last damage, no reduction
|
||||
+ // last damage existed, this means the reduction *technically* is (new damage - last damage).
|
||||
+ // If the event damage was changed to something less than invul damage, hard lock it at 0.
|
||||
+ if (d < invulnerabilityRelatedLastDamage) return 0D;
|
||||
+ //
|
||||
+ // Cast the passed in double down to a float as double -> float -> double is lossy.
|
||||
+ // If last damage is a (float) 3.2D (since the events use doubles), we cannot compare
|
||||
+ // the new damage value of this damage instance by upcasting it again to a double as 3.2D != (double) (float) 3.2D.
|
||||
+ if (d.floatValue() < invulnerabilityRelatedLastDamage) return 0D;
|
||||
+ return (double) -invulnerabilityRelatedLastDamage;
|
||||
+ };
|
||||
+ final float originalInvulnerabilityReduction = invulnerabilityReductionEquation.apply((double) amount).floatValue();
|
||||
@@ -1118,7 +1122,10 @@
|
||||
+
|
||||
+ // Apply damage to armor
|
||||
+ if (!damageSource.is(DamageTypeTags.BYPASSES_ARMOR)) {
|
||||
+ float armorDamage = (float) (event.getDamage() + event.getDamage(DamageModifier.BLOCKING) + event.getDamage(DamageModifier.HARD_HAT));
|
||||
+ float armorDamage = (float) event.getDamage();
|
||||
+ armorDamage += (float) event.getDamage(DamageModifier.INVULNERABILITY_REDUCTION);
|
||||
+ armorDamage += (float) event.getDamage(DamageModifier.BLOCKING);
|
||||
+ armorDamage += (float) event.getDamage(DamageModifier.HARD_HAT);
|
||||
+ this.hurtArmor(damageSource, armorDamage);
|
||||
+ }
|
||||
+
|
||||
|
||||
Reference in New Issue
Block a user