2018-07-19 06:42:43 +02:00
|
|
|
From fc3410f5aeb5f6b421aed828b1086bfc7729d5bf Mon Sep 17 00:00:00 2001
|
2018-06-21 03:59:11 +02:00
|
|
|
From: Brokkonaut <hannos17@gmx.de>
|
|
|
|
Date: Mon, 18 Jun 2018 15:46:23 +0200
|
|
|
|
Subject: [PATCH] Implement EntityKnockbackByEntityEvent
|
|
|
|
|
|
|
|
This event is called when an entity receives knockback by another entity.
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
2018-07-19 01:16:19 +02:00
|
|
|
index 1932d38a8..1d7b9c525 100644
|
2018-06-21 03:59:11 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
2018-07-19 01:16:19 +02:00
|
|
|
@@ -1168,6 +1168,12 @@ public abstract class EntityLiving extends Entity {
|
2018-06-21 03:59:11 +02:00
|
|
|
this.impulse = true;
|
|
|
|
float f1 = MathHelper.sqrt(d0 * d0 + d1 * d1);
|
|
|
|
|
|
|
|
+ // Paper start - preserve old velocity
|
|
|
|
+ double oldMotX = this.motX;
|
|
|
|
+ double oldMotY = this.motY;
|
|
|
|
+ double oldMotZ = this.motZ;
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
this.motX /= 2.0D;
|
|
|
|
this.motZ /= 2.0D;
|
|
|
|
this.motX -= d0 / (double) f1 * (double) f;
|
2018-07-19 01:16:19 +02:00
|
|
|
@@ -1180,6 +1186,18 @@ public abstract class EntityLiving extends Entity {
|
2018-06-21 03:59:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start - call EntityKnockbackByEntityEvent
|
|
|
|
+ org.bukkit.util.Vector delta = new org.bukkit.util.Vector(this.motX - oldMotX, this.motY - oldMotY, this.motZ - oldMotZ);
|
|
|
|
+ // Restore old velocity to be able to access it in the event
|
|
|
|
+ this.motX = oldMotX;
|
|
|
|
+ this.motY = oldMotY;
|
|
|
|
+ this.motZ = oldMotZ;
|
|
|
|
+ if (entity == null || new com.destroystokyo.paper.event.entity.EntityKnockbackByEntityEvent((LivingEntity) getBukkitEntity(), entity.getBukkitEntity(), f, delta).callEvent()) {
|
|
|
|
+ this.motX += delta.getX();
|
|
|
|
+ this.motY += delta.getY();
|
|
|
|
+ this.motZ += delta.getZ();
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
--
|
2018-06-30 07:40:52 +02:00
|
|
|
2.18.0
|
2018-06-21 03:59:11 +02:00
|
|
|
|