13
0
geforkt von Mirrors/Paper

Only call EntityPortalExitEvent if entity is actually in a portal

Dieser Commit ist enthalten in:
Jake Potrebic 2024-09-22 14:35:04 -07:00
Ursprung 802cb228d7
Commit f137f3cf13

Datei anzeigen

@ -23,23 +23,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
to = teleEvent.getTo(); to = teleEvent.getTo();
- teleportTarget = new DimensionTransition(((CraftWorld) to.getWorld()).getHandle(), CraftLocation.toVec3D(to), teleportTarget.speed(), to.getYaw(), to.getPitch(), teleportTarget.missingRespawnBlock(), teleportTarget.postDimensionTransition(), teleportTarget.cause()); - teleportTarget = new DimensionTransition(((CraftWorld) to.getWorld()).getHandle(), CraftLocation.toVec3D(to), teleportTarget.speed(), to.getYaw(), to.getPitch(), teleportTarget.missingRespawnBlock(), teleportTarget.postDimensionTransition(), teleportTarget.cause());
+ // Paper start - Call EntityPortalExitEvent + // Paper start - Call EntityPortalExitEvent
+ CraftEntity bukkitEntity = this.getBukkitEntity(); + if (this.portalProcess != null) { // if in a portal
+ Vec3 velocity = teleportTarget.speed(); + CraftEntity bukkitEntity = this.getBukkitEntity();
+ org.bukkit.event.entity.EntityPortalExitEvent event = new org.bukkit.event.entity.EntityPortalExitEvent( + Vec3 velocity = teleportTarget.speed();
+ bukkitEntity, + org.bukkit.event.entity.EntityPortalExitEvent event = new org.bukkit.event.entity.EntityPortalExitEvent(
+ bukkitEntity.getLocation(), to.clone(), + bukkitEntity,
+ bukkitEntity.getVelocity(), org.bukkit.craftbukkit.util.CraftVector.toBukkit(velocity) + bukkitEntity.getLocation(), to.clone(),
+ ); + bukkitEntity.getVelocity(), org.bukkit.craftbukkit.util.CraftVector.toBukkit(velocity)
+ event.callEvent(); + );
+ event.callEvent();
+
+ if (!event.isCancelled() && event.getTo() != null) {
+ to = event.getTo().clone();
+ velocity = org.bukkit.craftbukkit.util.CraftVector.toNMS(event.getAfter());
+ }
+ teleportTarget = new DimensionTransition(((CraftWorld) to.getWorld()).getHandle(), CraftLocation.toVec3D(to), velocity, to.getYaw(), to.getPitch(), teleportTarget.missingRespawnBlock(), teleportTarget.postDimensionTransition(), teleportTarget.cause());
+ }
+ if (this.isRemoved()) { + if (this.isRemoved()) {
+ return null; + return null;
+ } + }
+
+ if (!event.isCancelled() && event.getTo() != null) {
+ to = event.getTo().clone();
+ velocity = org.bukkit.craftbukkit.util.CraftVector.toNMS(event.getAfter());
+ }
+ teleportTarget = new DimensionTransition(((CraftWorld) to.getWorld()).getHandle(), CraftLocation.toVec3D(to), velocity, to.getYaw(), to.getPitch(), teleportTarget.missingRespawnBlock(), teleportTarget.postDimensionTransition(), teleportTarget.cause());
+ // Paper end - Call EntityPortalExitEvent + // Paper end - Call EntityPortalExitEvent
// CraftBukkit end // CraftBukkit end
ServerLevel worldserver1 = teleportTarget.newLevel(); ServerLevel worldserver1 = teleportTarget.newLevel();