PaperMC/patches/server/0600-Add-back-EntityPortalExitEvent.patch

51 lines
3.3 KiB
Diff
Raw Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
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
2024-04-24 17:27:28 +02:00
index 66ddae628d8ccce62aa6937166d719911aef44a2..dd353bad7ddf7c1e4bbc37ed3724d73696f7b8a7 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
2024-04-24 17:27:28 +02:00
@@ -3307,6 +3307,28 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
} else {
// CraftBukkit start
worldserver = shapedetectorshape.world;
+ // Paper start - Call EntityPortalExitEvent
+ Vec3 position = shapedetectorshape.pos;
+ float yaw = shapedetectorshape.yRot;
2024-02-01 10:15:57 +01:00
+ float pitch = this.getXRot(); // Keep entity pitch as per moveTo line below
+ Vec3 velocity = shapedetectorshape.speed;
2024-02-01 10:15:57 +01:00
+ 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();
2024-02-01 10:15:57 +01:00
+ 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);
2024-04-24 17:27:28 +02:00
@@ -3326,8 +3348,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
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
2023-12-06 05:46:41 +01:00
// CraftBukkit start - Don't spawn the new entity if the current entity isn't spawned
if (this.inWorld) {
worldserver.addDuringTeleport(entity);