Files
Purpur/patches/server/0097-Implement-EntityMoveEvent.patch
William Blake Galbreath f2e328d295 Updated Upstream (Paper)
Upstream has released updates that appears to apply and compile correctly

Paper Changes:
ad708dd3 Add option to allow iron golems to spawn in air (Closes #1965, Closes #1851)
b16fd5c3 Updated Upstream (Bukkit/CraftBukkit/Spigot)
2020-03-10 19:30:18 -05:00

46 lines
1.9 KiB
Diff

From c68fd9e81577be8d7e275878cc5f12c9ff517092 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Tue, 11 Feb 2020 21:56:48 -0600
Subject: [PATCH] Implement EntityMoveEvent
---
.../java/net/minecraft/server/EntityLiving.java | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index 60e2b4268c..e3dc406da5 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -17,6 +17,7 @@ import java.util.Random;
import java.util.Set;
import java.util.UUID;
import javax.annotation.Nullable;
+import net.pl3x.purpur.event.entity.EntityMoveEvent; // Purpur
import org.apache.commons.lang3.tuple.Pair;
// CraftBukkit start
@@ -2635,6 +2636,20 @@ public abstract class EntityLiving extends Entity {
this.collideNearby();
this.world.getMethodProfiler().exit();
+ // Purpur start
+ if (EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0) {
+ if (lastX != locX() || lastY != locY() || lastZ != locZ() || lastYaw != yaw || lastPitch != pitch) {
+ Location from = new Location(world.getWorld(), lastX, lastY, lastZ, lastYaw, lastPitch);
+ Location to = new Location (world.getWorld(), locX(), locY(), locZ(), yaw, pitch);
+ EntityMoveEvent event = new EntityMoveEvent(getBukkitLivingEntity(), from, to.clone());
+ if (!event.callEvent()) {
+ setLocation(from.getX(), from.getY(), from.getZ(), from.getYaw(), from.getPitch());
+ } else if (!to.equals(event.getTo())) {
+ setLocation(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch());
+ }
+ }
+ }
+ // Purpur end
}
private void n() {
--
2.24.0