diff options
author | md_5 <git@md-5.net> | 2018-09-17 16:40:35 +1000 |
---|---|---|
committer | md_5 <git@md-5.net> | 2018-09-17 16:40:35 +1000 |
commit | 79ada744cba8ddec39bd65adc12adefa9c8a45d3 (patch) | |
tree | ada90584f64cc5621d45b62b1fb82fee5093b97c /nms-patches | |
parent | 94b8708aca2424734417b82a4e872c85740bde16 (diff) | |
download | craftbukkit-79ada744cba8ddec39bd65adc12adefa9c8a45d3.tar craftbukkit-79ada744cba8ddec39bd65adc12adefa9c8a45d3.tar.gz craftbukkit-79ada744cba8ddec39bd65adc12adefa9c8a45d3.tar.lz craftbukkit-79ada744cba8ddec39bd65adc12adefa9c8a45d3.tar.xz craftbukkit-79ada744cba8ddec39bd65adc12adefa9c8a45d3.zip |
SPIGOT-4382: Fix damage_absorbed statistic
Diffstat (limited to 'nms-patches')
-rw-r--r-- | nms-patches/EntityLiving.patch | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/nms-patches/EntityLiving.patch b/nms-patches/EntityLiving.patch index 60392131..81bd53e5 100644 --- a/nms-patches/EntityLiving.patch +++ b/nms-patches/EntityLiving.patch @@ -539,7 +539,7 @@ i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5; int j = 25 - i; float f1 = f * (float) j; -@@ -1119,28 +1364,164 @@ +@@ -1119,28 +1364,167 @@ } } @@ -615,15 +615,15 @@ + } + }; + float absorptionModifier = absorption.apply((double) f).floatValue(); -+ + +- f = Math.max(f - this.getAbsorptionHearts(), 0.0F); +- this.setAbsorptionHearts(this.getAbsorptionHearts() - (f1 - f)); +- float f2 = f1 - f; + EntityDamageEvent event = CraftEventFactory.handleLivingEntityDamageEvent(this, damagesource, originalDamage, hardHatModifier, blockingModifier, armorModifier, resistanceModifier, magicModifier, absorptionModifier, hardHat, blocking, armor, resistance, magic, absorption); + if (event.isCancelled()) { + return false; + } -- f = Math.max(f - this.getAbsorptionHearts(), 0.0F); -- this.setAbsorptionHearts(this.getAbsorptionHearts() - (f1 - f)); -- float f2 = f1 - f; + f = (float) event.getFinalDamage(); + + // Resistance @@ -662,7 +662,10 @@ + absorptionModifier = (float) -event.getDamage(DamageModifier.ABSORPTION); + this.setAbsorptionHearts(Math.max(this.getAbsorptionHearts() - absorptionModifier, 0.0F)); + float f2 = absorptionModifier; - ++ ++ if (f2 > 0.0F && f2 < 3.4028235E37F && this instanceof EntityHuman) { ++ ((EntityHuman) this).a(StatisticList.DAMAGE_ABSORBED, Math.round(f2 * 10.0F)); ++ } if (f2 > 0.0F && f2 < 3.4028235E37F && damagesource.getEntity() instanceof EntityPlayer) { ((EntityPlayer) damagesource.getEntity()).a(StatisticList.DAMAGE_DEALT_ABSORBED, Math.round(f2 * 10.0F)); } @@ -714,7 +717,7 @@ } public CombatTracker getCombatTracker() { -@@ -1207,6 +1588,7 @@ +@@ -1207,6 +1591,7 @@ public AttributeMapBase getAttributeMap() { if (this.attributeMap == null) { this.attributeMap = new AttributeMapServer(); @@ -722,7 +725,7 @@ } return this.attributeMap; -@@ -1509,6 +1891,7 @@ +@@ -1509,6 +1894,7 @@ } if (this.onGround && !this.world.isClientSide) { @@ -730,7 +733,7 @@ this.setFlag(7, false); } } else { -@@ -1910,6 +2293,7 @@ +@@ -1910,6 +2296,7 @@ } if (!this.world.isClientSide) { @@ -738,7 +741,7 @@ this.setFlag(7, flag); } -@@ -2037,11 +2421,11 @@ +@@ -2037,11 +2424,11 @@ } public boolean isInteractable() { @@ -752,7 +755,7 @@ } protected void aA() { -@@ -2201,7 +2585,27 @@ +@@ -2201,7 +2588,27 @@ protected void q() { if (!this.activeItem.isEmpty() && this.isHandRaised()) { this.b(this.activeItem, 16); @@ -781,7 +784,7 @@ this.da(); } -@@ -2280,10 +2684,18 @@ +@@ -2280,10 +2687,18 @@ } if (flag1) { |