diff --git a/paper-server/nms-patches/net/minecraft/world/level/Explosion.patch b/paper-server/nms-patches/net/minecraft/world/level/Explosion.patch index 1f1eb8ec9b..7a2387c08d 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/Explosion.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/Explosion.patch @@ -98,7 +98,7 @@ } double d12 = (1.0D - d7) * (double) getSeenPercent(vec3d, entity) * (double) this.damageCalculator.getKnockbackMultiplier(entity); -@@ -248,6 +296,14 @@ +@@ -248,6 +296,17 @@ d10 *= d13; Vec3D vec3d1 = new Vec3D(d8, d9, d10); @@ -107,13 +107,16 @@ + Vec3D result = entity.getDeltaMovement().add(vec3d1); + org.bukkit.event.entity.EntityKnockbackEvent event = CraftEventFactory.callEntityKnockbackEvent((org.bukkit.craftbukkit.entity.CraftLivingEntity) entity.getBukkitEntity(), source, org.bukkit.event.entity.EntityKnockbackEvent.KnockbackCause.EXPLOSION, d13, vec3d1, result.x, result.y, result.z); + -+ vec3d1 = (event.isCancelled()) ? Vec3D.ZERO : new Vec3D(event.getFinalKnockback().getX(), event.getFinalKnockback().getY(), event.getFinalKnockback().getZ()); ++ // SPIGOT-7640: Need to subtract entity movement from the event result, ++ // since the code below (the setDeltaMovement call as well as the hitPlayers map) ++ // want the vector to be the relative velocity will the event provides the absolute velocity ++ vec3d1 = (event.isCancelled()) ? Vec3D.ZERO : new Vec3D(event.getFinalKnockback().getX(), event.getFinalKnockback().getY(), event.getFinalKnockback().getZ()).subtract(entity.getDeltaMovement()); + } + // CraftBukkit end entity.setDeltaMovement(entity.getDeltaMovement().add(vec3d1)); if (entity instanceof EntityHuman) { EntityHuman entityhuman = (EntityHuman) entity; -@@ -290,9 +346,63 @@ +@@ -290,9 +349,63 @@ SystemUtils.shuffle(this.toBlow, this.level.random); ObjectListIterator objectlistiterator = this.toBlow.iterator(); @@ -177,7 +180,7 @@ this.level.getBlockState(blockposition).onExplosionHit(this.level, blockposition, this, (itemstack, blockposition1) -> { addOrAppendStack(list, itemstack, blockposition1); -@@ -317,7 +427,11 @@ +@@ -317,7 +430,11 @@ BlockPosition blockposition1 = (BlockPosition) objectlistiterator1.next(); if (this.random.nextInt(3) == 0 && this.level.getBlockState(blockposition1).isAir() && this.level.getBlockState(blockposition1.below()).isSolidRender(this.level, blockposition1.below())) { @@ -190,7 +193,7 @@ } } } -@@ -325,6 +439,7 @@ +@@ -325,6 +442,7 @@ } private static void addOrAppendStack(List> list, ItemStack itemstack, BlockPosition blockposition) {