From 5f9ed411df3ceaa55afae5c6cc7aa445db3020aa Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Tue, 5 Oct 2021 14:19:27 -0700 Subject: [PATCH] Fix EntityPortalExitEvent not being called (#5617) --- .../api/add-back-EntityPortalExitEvent.patch | 21 ++++++++++ .../Add-back-EntityPortalExitEvent.patch | 41 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 patches/api/add-back-EntityPortalExitEvent.patch create mode 100644 patches/server/Add-back-EntityPortalExitEvent.patch diff --git a/patches/api/add-back-EntityPortalExitEvent.patch b/patches/api/add-back-EntityPortalExitEvent.patch new file mode 100644 index 0000000000..969ad87ac7 --- /dev/null +++ b/patches/api/add-back-EntityPortalExitEvent.patch @@ -0,0 +1,21 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic +Date: Wed, 12 May 2021 02:49:28 -0700 +Subject: [PATCH] add back EntityPortalExitEvent + +Was removed here: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/a2d787f6ebeb72fa7d5750788221fb9a0d838ac4 + +diff --git a/src/main/java/org/bukkit/event/entity/EntityPortalExitEvent.java b/src/main/java/org/bukkit/event/entity/EntityPortalExitEvent.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/event/entity/EntityPortalExitEvent.java ++++ b/src/main/java/org/bukkit/event/entity/EntityPortalExitEvent.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull; + *

+ * This event allows you to modify the velocity of the entity after they have + * successfully exited the portal. ++ *

++ * Cancelling this event does not prevent the teleport, but it does prevent ++ * any changes to velocity and location from taking place. + */ + public class EntityPortalExitEvent extends EntityTeleportEvent { + private static final HandlerList handlers = new HandlerList(); diff --git a/patches/server/Add-back-EntityPortalExitEvent.patch b/patches/server/Add-back-EntityPortalExitEvent.patch new file mode 100644 index 0000000000..5c4f5564a1 --- /dev/null +++ b/patches/server/Add-back-EntityPortalExitEvent.patch @@ -0,0 +1,41 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic +Date: Sun, 16 May 2021 09:39:46 -0700 +Subject: [PATCH] Add back EntityPortalExitEvent + + +diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/entity/Entity.java ++++ b/src/main/java/net/minecraft/world/entity/Entity.java +@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n + if (shapedetectorshape == null) { + return null; + } else { ++ // Paper start - Call EntityPortalExitEvent ++ Vec3 position = shapedetectorshape.pos; ++ float yaw = shapedetectorshape.yRot; ++ float pitch = shapedetectorshape.xRot; ++ Vec3 velocity = shapedetectorshape.speed; ++ org.bukkit.event.entity.EntityPortalExitEvent event = new org.bukkit.event.entity.EntityPortalExitEvent(this.getBukkitEntity(), this.getBukkitEntity().getLocation(), shapedetectorshape.portalEventInfo.getTo(), this.getBukkitEntity().getVelocity(), org.bukkit.craftbukkit.util.CraftVector.toBukkit(shapedetectorshape.speed)); ++ if (event.callEvent() && event.getTo() != null && this.isAlive()) { ++ position = Vec3.atLowerCornerOf(MCUtil.toBlockPosition(event.getTo())); ++ yaw = event.getTo().getYaw(); ++ pitch = event.getTo().getPitch(); ++ velocity = org.bukkit.craftbukkit.util.CraftVector.toNMS(event.getAfter()); ++ } ++ // Paper end + // CraftBukkit start + worldserver = shapedetectorshape.world; + this.unRide(); +@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n + + if (entity != null) { + entity.restoreFrom(this); +- entity.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, entity.getXRot()); +- entity.setDeltaMovement(shapedetectorshape.speed); ++ entity.moveTo(position.x, position.y, position.z, yaw, pitch); // Paper - respect EntityPortalExitEvent values ++ entity.setDeltaMovement(velocity); // Paper - respect EntityPortalExitEvent values + worldserver.addDuringTeleport(entity); + if (worldserver.getTypeKey() == DimensionType.END_LOCATION) { // CraftBukkit + ServerLevel.makeObsidianPlatform(worldserver, this); // CraftBukkit