aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0615-Add-back-EntityPortalExitEvent.patch
diff options
context:
space:
mode:
authormaxcom1 <[email protected]>2024-03-23 22:26:17 +0100
committerGitHub <[email protected]>2024-03-23 17:26:17 -0400
commitb6001403e9703cadaa6e8c8558e732b91c3c6d6e (patch)
treea8c57bbc334a8ad48d4ad2b43db335667b142bee /patches/server/0615-Add-back-EntityPortalExitEvent.patch
parent9ec7dfcbc41c6e625de0050b6997160a75df9f44 (diff)
downloadPaper-b6001403e9703cadaa6e8c8558e732b91c3c6d6e.tar.gz
Paper-b6001403e9703cadaa6e8c8558e732b91c3c6d6e.zip
Add methods to change entity physics (#10334)
Diffstat (limited to 'patches/server/0615-Add-back-EntityPortalExitEvent.patch')
-rw-r--r--patches/server/0615-Add-back-EntityPortalExitEvent.patch50
1 files changed, 50 insertions, 0 deletions
diff --git a/patches/server/0615-Add-back-EntityPortalExitEvent.patch b/patches/server/0615-Add-back-EntityPortalExitEvent.patch
new file mode 100644
index 0000000000..566d9576da
--- /dev/null
+++ b/patches/server/0615-Add-back-EntityPortalExitEvent.patch
@@ -0,0 +1,50 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Jake Potrebic <[email protected]>
+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 f93e74226e3306a59e17dce1e4f8e72d61d75d49..7dbbf0884b70acb37c3400364736fa8f6b68c964 100644
+--- a/src/main/java/net/minecraft/world/entity/Entity.java
++++ b/src/main/java/net/minecraft/world/entity/Entity.java
+@@ -3291,6 +3291,28 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
+ } else {
+ // CraftBukkit start
+ worldserver = shapedetectorshape.world;
++ // Paper start - Call EntityPortalExitEvent
++ Vec3 position = shapedetectorshape.pos;
++ float yaw = shapedetectorshape.yRot;
++ float pitch = this.getXRot(); // Keep entity pitch as per moveTo line below
++ Vec3 velocity = shapedetectorshape.speed;
++ CraftEntity bukkitEntity = this.getBukkitEntity();
++ org.bukkit.event.entity.EntityPortalExitEvent event = new org.bukkit.event.entity.EntityPortalExitEvent(bukkitEntity,
++ bukkitEntity.getLocation(), new Location(worldserver.getWorld(), position.x, position.y, position.z, yaw, pitch),
++ bukkitEntity.getVelocity(), org.bukkit.craftbukkit.util.CraftVector.toBukkit(shapedetectorshape.speed));
++ event.callEvent();
++ if (this.isRemoved()) {
++ return null;
++ }
++
++ if (!event.isCancelled() && event.getTo() != null) {
++ worldserver = ((CraftWorld) event.getTo().getWorld()).getHandle();
++ position = CraftLocation.toVec3D(event.getTo());
++ yaw = event.getTo().getYaw();
++ pitch = event.getTo().getPitch();
++ velocity = org.bukkit.craftbukkit.util.CraftVector.toNMS(event.getAfter());
++ }
++ // Paper end - Call EntityPortalExitEvent
+ if (worldserver == this.level) {
+ // SPIGOT-6782: Just move the entity if a plugin changed the world to the one the entity is already in
+ this.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, shapedetectorshape.xRot);
+@@ -3310,8 +3332,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
+
+ 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 - EntityPortalExitEvent
++ entity.setDeltaMovement(velocity); // Paper - EntityPortalExitEvent
+ // CraftBukkit start - Don't spawn the new entity if the current entity isn't spawned
+ if (this.inWorld) {
+ worldserver.addDuringTeleport(entity);