Paper/Spigot-Server-Patches/0273-Implement-EntityKnockbackByEntityEvent.patch
Shane Freeder ea855e2b46 Updated Upstream (Bukkit/CraftBukkit/Spigot)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Developers!: You will need to clean up your work/Minecraft/1.13.2 folder
for this

Also, restore a patch that was dropped in the last upstream

Bukkit Changes:
279eeab3 Fix command description not being set
96e2bb18 Remove debug print from SyntheticEventTest

CraftBukkit Changes:
d3ed1516 Fix dangerously threaded beacons
217a293d Don't relocate joptsimple to allow --help to work.
1be05a21 Prepare for imminent Java 12 release
a49270b2 Mappings Update
5259d80c SPIGOT-4669: Fix PlayerTeleportEvent coordinates for relative teleports

Spigot Changes:
e6eb36f2 Rebuild patches
2019-03-20 01:55:16 +00:00

47 lines
1.9 KiB
Diff

From fe425522ea63caa0bf747aeff4b7d92b27dd1506 Mon Sep 17 00:00:00 2001
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
index deb50b84f..164e4b412 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -1251,6 +1251,12 @@ public abstract class EntityLiving extends Entity {
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;
@@ -1263,6 +1269,18 @@ public abstract class EntityLiving extends Entity {
}
}
+ // 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
}
}
--
2.21.0