mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-29 19:52:55 +01:00
0cdce89d59
If a playerdata doesn't contain a valid, loaded world, reset to the main world spawn point
50 lines
3.4 KiB
Diff
50 lines
3.4 KiB
Diff
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
|
|
index c8c145048ebe58e40818f998092c2912000f4c63..52022b9df1a66ec4dad9e315450cbe5806e70fa1 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -3344,6 +3344,28 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
|
} else {
|
|
// CraftBukkit start
|
|
worldserver = shapedetectorshape.world;
|
|
+ // Paper start - Call EntityPortalExitEvent
|
|
+ CraftEntity bukkitEntity = this.getBukkitEntity();
|
|
+ Vec3 position = shapedetectorshape.pos;
|
|
+ float yaw = shapedetectorshape.yRot;
|
|
+ float pitch = bukkitEntity.getLocation().getPitch(); // Keep entity pitch as per moveTo line below
|
|
+ Vec3 velocity = shapedetectorshape.speed;
|
|
+ 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 = new Vec3(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ());
|
|
+ yaw = event.getTo().getYaw();
|
|
+ pitch = event.getTo().getPitch();
|
|
+ velocity = org.bukkit.craftbukkit.util.CraftVector.toNMS(event.getAfter());
|
|
+ }
|
|
+ // Paper end
|
|
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);
|
|
@@ -3363,8 +3385,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
|
|
|
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 - use EntityPortalExitEvent values
|
|
+ entity.setDeltaMovement(velocity); // Paper - use EntityPortalExitEvent values
|
|
worldserver.addDuringTeleport(entity);
|
|
if (worldserver.getTypeKey() == LevelStem.END) { // CraftBukkit
|
|
ServerLevel.makeObsidianPlatform(worldserver, this); // CraftBukkit
|