Fire entity knockback event for ownerless tnt (#7171)
This commit is contained in:
parent
7f85940143
commit
7ccefdcd6c
3 changed files with 39 additions and 7 deletions
|
@ -37,7 +37,7 @@ index 6fbde57320a58600f8c4b9ce598fa93bd2772e8b..cf907e0c1a89639639b6453032f8f6fe
|
|||
|
||||
protected void markHurt() {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 001179978a81f2f7f1c56270b2a131dda7aaa881..2900326a87d21c8a92edb303ed42fd11ea7f3010 100644
|
||||
index 001179978a81f2f7f1c56270b2a131dda7aaa881..4324c1d8d03f69bb40740269170fd70a317d299e 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -1561,7 +1561,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
|
@ -49,6 +49,15 @@ index 001179978a81f2f7f1c56270b2a131dda7aaa881..2900326a87d21c8a92edb303ed42fd11
|
|||
}
|
||||
|
||||
private boolean checkTotemDeathProtection(DamageSource source) {
|
||||
@@ -1824,7 +1824,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
this.knockback(strength, x, z, null, EntityKnockbackEvent.KnockbackCause.UNKNOWN);
|
||||
}
|
||||
|
||||
- public void knockback(double d0, double d1, double d2, Entity attacker, EntityKnockbackEvent.KnockbackCause cause) {
|
||||
+ public void knockback(double d0, double d1, double d2, @Nullable Entity attacker, EntityKnockbackEvent.KnockbackCause cause) { // Paper - add nullable to attacker param
|
||||
d0 *= 1.0D - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE);
|
||||
if (true || d0 > 0.0D) { // CraftBukkit - Call event even when force is 0
|
||||
//this.hasImpulse = true; // CraftBukkit - Move down
|
||||
@@ -1836,8 +1836,22 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
return;
|
||||
}
|
||||
|
@ -58,7 +67,7 @@ index 001179978a81f2f7f1c56270b2a131dda7aaa881..2900326a87d21c8a92edb303ed42fd11
|
|||
+ org.bukkit.util.Vector resultingMovement = event.getFinalKnockback();
|
||||
+ final org.bukkit.util.Vector deltaMovement = resultingMovement.clone().subtract(currentMovement);
|
||||
+ if (attacker != null) {
|
||||
+ final com.destroystokyo.paper.event.entity.EntityKnockbackByEntityEvent knockbackEvent = new com.destroystokyo.paper.event.entity.EntityKnockbackByEntityEvent((org.bukkit.entity.LivingEntity) getBukkitEntity(), attacker.getBukkitEntity(), (float) event.getForce(), deltaMovement);
|
||||
+ final com.destroystokyo.paper.event.entity.EntityKnockbackByEntityEvent knockbackEvent = new com.destroystokyo.paper.event.entity.EntityKnockbackByEntityEvent(this.getBukkitLivingEntity(), attacker.getBukkitEntity(), (float) event.getForce(), deltaMovement);
|
||||
+ if (!knockbackEvent.callEvent()) {
|
||||
+ return;
|
||||
+ }
|
||||
|
@ -164,3 +173,26 @@ index 0f700442a7559fac5d27d1fb6b3716f3853a9897..f3861cea4eb6a39fa16936383f8dabc6
|
|||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
index 00cfa26783ce0772c75166266ead258a415097bc..ade10a9fd93f4c0f04cd56ce5e1da06af4a05060 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
@@ -298,7 +298,17 @@ public class Explosion {
|
||||
Vec3 result = entity.getDeltaMovement().add(vec3d1);
|
||||
org.bukkit.event.entity.EntityKnockbackEvent event = CraftEventFactory.callEntityKnockbackEvent((org.bukkit.craftbukkit.entity.CraftLivingEntity) entity.getBukkitEntity(), this.source, org.bukkit.event.entity.EntityKnockbackEvent.KnockbackCause.EXPLOSION, d13, vec3d1, result.x, result.y, result.z);
|
||||
|
||||
- vec3d1 = (event.isCancelled()) ? Vec3.ZERO : new Vec3(event.getFinalKnockback().getX(), event.getFinalKnockback().getY(), event.getFinalKnockback().getZ());
|
||||
+ // Paper start - call EntityKnockbackByEntityEvent for explosions
|
||||
+ vec3d1 = (event.isCancelled()) ? Vec3.ZERO : new Vec3(event.getFinalKnockback().getX(), event.getFinalKnockback().getY(), event.getFinalKnockback().getZ()).subtract(entity.getDeltaMovement()); // changes on this line fix a bug where vec3d1 wasn't reassigned with the "change", but instead the final deltaMovement
|
||||
+ if (this.damageSource.getEntity() != null || this.source != null) {
|
||||
+ final org.bukkit.entity.Entity hitBy = this.damageSource.getEntity() != null ? this.damageSource.getEntity().getBukkitEntity() : this.source.getBukkitEntity();
|
||||
+ com.destroystokyo.paper.event.entity.EntityKnockbackByEntityEvent paperEvent = new com.destroystokyo.paper.event.entity.EntityKnockbackByEntityEvent(((LivingEntity) entity).getBukkitLivingEntity(), hitBy, (float) event.getForce(), org.bukkit.craftbukkit.util.CraftVector.toBukkit(vec3d1));
|
||||
+ if (!paperEvent.callEvent()) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ vec3d1 = org.bukkit.craftbukkit.util.CraftVector.toNMS(paperEvent.getAcceleration());
|
||||
+ }
|
||||
+ // Paper end - call EntityKnockbackByEntityEvent for explosions
|
||||
}
|
||||
// CraftBukkit end
|
||||
entity.setDeltaMovement(entity.getDeltaMovement().add(vec3d1));
|
||||
|
|
|
@ -49,10 +49,10 @@ index 8c0653012192144cd11c802d1ad9bf7e42e94f59..a47473c9875c70c52b9a61e0156e5596
|
|||
|
||||
public DamageSource outOfBorder() {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
index cd939ab6958e8eb632056d32f68e2fcae7735d64..32775780df3e6f34961119f10c81462c0f729045 100644
|
||||
index e13450b3422309aad5ea50902d87c59816d0a105..27c0f5d623ecf7ea09f51105938a5f254983b6e1 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
@@ -373,7 +373,7 @@ public class Explosion {
|
||||
@@ -383,7 +383,7 @@ public class Explosion {
|
||||
bukkitBlocks = event.blockList();
|
||||
this.yield = event.getYield();
|
||||
} else {
|
||||
|
|
|
@ -34,7 +34,7 @@ The results indicate that this logic is 5 times faster than Vanilla
|
|||
and 2.3 times faster than Lithium.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
index 6894366ebedc461e1e6703317d83f91fb8d4f09b..f0fbde839a527481314f54a1aefa0fc317ba2221 100644
|
||||
index 62f0db51e5d6dd36d618e7e890f30cc83af2fed3..695e90c35fc771bf101e04162ddcad1c6b698594 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
@@ -111,6 +111,271 @@ public class Explosion {
|
||||
|
@ -468,7 +468,7 @@ index 6894366ebedc461e1e6703317d83f91fb8d4f09b..f0fbde839a527481314f54a1aefa0fc3
|
|||
double d13;
|
||||
|
||||
if (entity instanceof LivingEntity) {
|
||||
@@ -324,6 +640,9 @@ public class Explosion {
|
||||
@@ -334,6 +650,9 @@ public class Explosion {
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -478,7 +478,7 @@ index 6894366ebedc461e1e6703317d83f91fb8d4f09b..f0fbde839a527481314f54a1aefa0fc3
|
|||
}
|
||||
|
||||
public void finalizeExplosion(boolean particles) {
|
||||
@@ -537,14 +856,14 @@ public class Explosion {
|
||||
@@ -547,14 +866,14 @@ public class Explosion {
|
||||
private BlockInteraction() {}
|
||||
}
|
||||
// Paper start - Optimize explosions
|
||||
|
|
Loading…
Reference in a new issue