diff --git a/patches/server/1062-Fix-invulnerability-reduction-in-EntityDamageEvent.patch b/patches/server/1064-Fix-invulnerability-reduction-in-EntityDamageEvent.patch similarity index 93% rename from patches/server/1062-Fix-invulnerability-reduction-in-EntityDamageEvent.patch rename to patches/server/1064-Fix-invulnerability-reduction-in-EntityDamageEvent.patch index f9259029579e3..3ab38918d114f 100644 --- a/patches/server/1062-Fix-invulnerability-reduction-in-EntityDamageEvent.patch +++ b/patches/server/1064-Fix-invulnerability-reduction-in-EntityDamageEvent.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Fix invulnerability reduction in EntityDamageEvent diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index e86314de8d908a0c3e9f17d3e163c11180cf3f59..84d84687c32ad6580c2fcd0730c597fc8ce90b9f 100644 +index e86314de8d908a0c3e9f17d3e163c11180cf3f59..c3d50a8448e95e3eccb494d8a678554d52f6ec72 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -1505,12 +1505,12 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -13,13 +13,13 @@ index e86314de8d908a0c3e9f17d3e163c11180cf3f59..84d84687c32ad6580c2fcd0730c597fc // Paper start - only call damage event when actuallyHurt will be called - move call logic down - event = this.handleEntityDamage(source, amount); -+ event = this.handleEntityDamage(source, amount, this.lastHurt); // Paper - fix invulnerability reduction in EntityDamageEvent ++ event = this.handleEntityDamage(source, amount, this.lastHurt); // Paper - fix invulnerability reduction in EntityDamageEvent - pass lastDamage reduction amount = computeAmountFromEntityDamageEvent(event); // Paper end - only call damage event when actuallyHurt will be called - move call logic down // CraftBukkit start - if (!this.actuallyHurt(world, source, (float) event.getFinalDamage() - this.lastHurt, event)) { -+ if (!this.actuallyHurt(world, source, (float) event.getFinalDamage(), event)) { ++ if (!this.actuallyHurt(world, source, (float) event.getFinalDamage(), event)) { // Paper - fix invulnerability reduction in EntityDamageEvent - no longer subtract lastHurt, that is part of the damage event calc now return false; } if (this instanceof ServerPlayer && event.getDamage() == 0 && originalAmount == 0) return false; // Paper - revert to vanilla damage - players are not affected by damage that is 0 - skip damage if the vanilla damage is 0 and was not modified by plugins in the event. @@ -28,7 +28,7 @@ index e86314de8d908a0c3e9f17d3e163c11180cf3f59..84d84687c32ad6580c2fcd0730c597fc } else { // Paper start - only call damage event when actuallyHurt will be called - move call logic down - event = this.handleEntityDamage(source, amount); -+ event = this.handleEntityDamage(source, amount, 0); // Paper - fix invulnerability reduction in EntityDamageEvent ++ event = this.handleEntityDamage(source, amount, 0); // Paper - fix invulnerability reduction in EntityDamageEvent - pass lastDamage reduction (none in this branch) amount = computeAmountFromEntityDamageEvent(event); // Paper end - only call damage event when actuallyHurt will be called - move call logic down // CraftBukkit start @@ -40,14 +40,14 @@ index e86314de8d908a0c3e9f17d3e163c11180cf3f59..84d84687c32ad6580c2fcd0730c597fc + private EntityDamageEvent handleEntityDamage(final DamageSource damagesource, float f, final float invulnerabilityRelatedLastDamage) { // Paper - fix invulnerability reduction in EntityDamageEvent float originalDamage = f; + // Paper start - fix invulnerability reduction in EntityDamageEvent -+ final com.google.common.base.Function invulnerabilityReductionFormular = d -> { ++ final com.google.common.base.Function invulnerabilityReductionEquation = d -> { + 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; + return (double) -invulnerabilityRelatedLastDamage; + }; -+ final float originalInvulnerabilityReduction = invulnerabilityReductionFormular.apply((double) f).floatValue(); ++ final float originalInvulnerabilityReduction = invulnerabilityReductionEquation.apply((double) f).floatValue(); + f += originalInvulnerabilityReduction; + // Paper end - fix invulnerability reduction in EntityDamageEvent @@ -60,7 +60,7 @@ index e86314de8d908a0c3e9f17d3e163c11180cf3f59..84d84687c32ad6580c2fcd0730c597fc - return CraftEventFactory.handleLivingEntityDamageEvent(this, damagesource, originalDamage, freezingModifier, hardHatModifier, blockingModifier, armorModifier, resistanceModifier, magicModifier, absorptionModifier, freezing, hardHat, blocking, armor, resistance, magic, absorption); + // Paper start - fix invulnerability reduction in EntityDamageEvent + return CraftEventFactory.handleLivingEntityDamageEvent(this, damagesource, originalDamage, freezingModifier, hardHatModifier, blockingModifier, armorModifier, resistanceModifier, magicModifier, absorptionModifier, freezing, hardHat, blocking, armor, resistance, magic, absorption, (damageModifierDoubleMap, damageModifierFunctionMap) -> { -+ damageModifierFunctionMap.put(DamageModifier.INVULNERABILITY_REDUCTION, invulnerabilityReductionFormular); ++ damageModifierFunctionMap.put(DamageModifier.INVULNERABILITY_REDUCTION, invulnerabilityReductionEquation); + damageModifierDoubleMap.put(DamageModifier.INVULNERABILITY_REDUCTION, (double) originalInvulnerabilityReduction); + }); + // Paper end - fix invulnerability reduction in EntityDamageEvent