3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-16 11:30:06 +01:00

SPIGOT-4382: Fix damage_absorbed statistic

Dieser Commit ist enthalten in:
md_5 2018-09-17 16:40:35 +10:00
Ursprung 94b8708aca
Commit 79ada744cb

Datei anzeigen

@ -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) {