SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Only cancel knockback if the damage event was canceled

By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
CraftBukkit/Spigot
2022-01-03 18:07:01 +01:00
parent cc34358a3e
commit 46f0dde817
5 changed files with 91 additions and 66 deletions

View File

@@ -110,14 +110,7 @@
return entityitem;
}
}
@@ -808,16 +857,17 @@
if (this.isInvulnerableTo(damagesource)) {
return false;
} else if (this.abilities.invulnerable && !damagesource.isBypassInvul()) {
+ this.forceExplosionKnockback = true; // SPIGOT-5258 - Make invulnerable players get knockback from explosions
return false;
} else {
this.noActionTime = 0;
@@ -814,10 +863,10 @@
if (this.isDeadOrDying()) {
return false;
} else {
@@ -130,7 +123,7 @@
}
if (this.level.getDifficulty() == EnumDifficulty.EASY) {
@@ -829,7 +879,13 @@
@@ -829,7 +878,13 @@
}
}
@@ -145,7 +138,7 @@
}
}
}
@@ -849,10 +905,29 @@
@@ -849,10 +904,29 @@
}
public boolean canHarmPlayer(EntityHuman entityhuman) {
@@ -178,7 +171,7 @@
}
@Override
@@ -894,8 +969,13 @@
@@ -894,8 +968,13 @@
}
}
@@ -193,7 +186,7 @@
if (!this.isInvulnerableTo(damagesource)) {
f = this.getDamageAfterArmorAbsorb(damagesource, f);
f = this.getDamageAfterMagicAbsorb(damagesource, f);
@@ -910,7 +990,7 @@
@@ -910,7 +989,7 @@
}
if (f != 0.0F) {
@@ -202,7 +195,7 @@
float f3 = this.getHealth();
this.setHealth(this.getHealth() - f);
@@ -921,6 +1001,7 @@
@@ -921,6 +1000,7 @@
}
}
@@ -210,7 +203,7 @@
}
@Override
@@ -1080,7 +1161,7 @@
@@ -1080,7 +1160,7 @@
f *= 0.2F + f2 * f2 * 0.8F;
f1 *= f2;
@@ -219,7 +212,7 @@
if (f > 0.0F || f1 > 0.0F) {
boolean flag = f2 > 0.9F;
boolean flag1 = false;
@@ -1119,8 +1200,15 @@
@@ -1119,8 +1199,15 @@
if (entity instanceof EntityLiving) {
f3 = ((EntityLiving) entity).getHealth();
if (j > 0 && !entity.isOnFire()) {
@@ -237,7 +230,7 @@
}
}
@@ -1148,8 +1236,11 @@
@@ -1148,8 +1235,11 @@
EntityLiving entityliving = (EntityLiving) iterator.next();
if (entityliving != this && entityliving != entity && !this.isAlliedTo((Entity) entityliving) && (!(entityliving instanceof EntityArmorStand) || !((EntityArmorStand) entityliving).isMarker()) && this.distanceToSqr((Entity) entityliving) < 9.0D) {
@@ -250,7 +243,7 @@
}
}
@@ -1158,9 +1249,26 @@
@@ -1158,9 +1248,26 @@
}
if (entity instanceof EntityPlayer && entity.hurtMarked) {
@@ -277,7 +270,7 @@
}
if (flag2) {
@@ -1205,7 +1313,14 @@
@@ -1205,7 +1312,14 @@
this.awardStat(StatisticList.DAMAGE_DEALT, Math.round(f5 * 10.0F));
if (j > 0) {
@@ -293,7 +286,7 @@
}
if (this.level instanceof WorldServer && f5 > 2.0F) {
@@ -1215,12 +1330,17 @@
@@ -1215,12 +1329,17 @@
}
}
@@ -312,7 +305,7 @@
}
}
@@ -1293,6 +1413,12 @@
@@ -1293,6 +1412,12 @@
public void updateTutorialInventoryAction(ItemStack itemstack, ItemStack itemstack1, ClickAction clickaction) {}
public Either<EntityHuman.EnumBedResult, Unit> startSleepInBed(BlockPosition blockposition) {
@@ -325,7 +318,7 @@
this.startSleeping(blockposition);
this.sleepCounter = 0;
return Either.right(Unit.INSTANCE);
@@ -1377,9 +1503,9 @@
@@ -1377,9 +1502,9 @@
super.jumpFromGround();
this.awardStat(StatisticList.JUMP);
if (this.isSprinting()) {
@@ -337,7 +330,7 @@
}
}
@@ -1413,7 +1539,11 @@
@@ -1413,7 +1538,11 @@
this.setDeltaMovement(vec3d2.x, d3 * 0.6D, vec3d2.z);
this.flyingSpeed = f;
this.resetFallDistance();
@@ -350,7 +343,7 @@
} else {
super.travel(vec3d);
}
@@ -1448,19 +1578,19 @@
@@ -1448,19 +1577,19 @@
i = Math.round((float) Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F);
if (i > 0) {
this.awardStat(StatisticList.SWIM_ONE_CM, i);
@@ -373,7 +366,7 @@
}
} else if (this.onClimbable()) {
if (d1 > 0.0D) {
@@ -1471,13 +1601,13 @@
@@ -1471,13 +1600,13 @@
if (i > 0) {
if (this.isSprinting()) {
this.awardStat(StatisticList.SPRINT_ONE_CM, i);
@@ -390,7 +383,7 @@
}
}
} else if (this.isFallFlying()) {
@@ -1543,12 +1673,24 @@
@@ -1543,12 +1672,24 @@
}
public void startFallFlying() {
@@ -416,7 +409,7 @@
}
@Override
@@ -1638,10 +1780,21 @@
@@ -1638,10 +1779,21 @@
return this.experienceLevel >= 30 ? 112 + (this.experienceLevel - 30) * 9 : (this.experienceLevel >= 15 ? 37 + (this.experienceLevel - 15) * 5 : 7 + this.experienceLevel * 2);
}
@@ -439,7 +432,7 @@
}
}
@@ -1718,15 +1871,22 @@
@@ -1718,15 +1870,22 @@
@Override
public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
@@ -465,7 +458,7 @@
this.inventory.armor.set(enumitemslot.getIndex(), itemstack);
}
@@ -1767,26 +1927,31 @@
@@ -1767,26 +1926,31 @@
protected void removeEntitiesOnShoulder() {
if (this.timeEntitySatOnShoulder + 20L < this.level.getGameTime()) {