Paper/Spigot-Server-Patches/0043-Add-PlayerInitialSpawnEvent.patch
Mariell Hoversholm 2db85c553f
fix: origin world can be unknown while knowing location
We will now store the world ID. It may not be used if the entity is
loaded before the world in question is, but it might be used later on,
should the entity come after the world.

Signed-off-by: Mariell Hoversholm <proximyst@proximyst.com>
2021-06-12 23:30:56 +01:00

49 lines
2.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Steve Anton <anxuiz.nx@gmail.com>
Date: Thu, 3 Mar 2016 00:09:38 -0600
Subject: [PATCH] Add PlayerInitialSpawnEvent
For modifying a player's initial spawn location as they join the server
This is a duplicate API from spigot, so use our duplicate subclass and
improve setPosition to use raw
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 6ebd4ec781aa215c2b941261250c15c87c223cab..46c516b9ff089a3c885d635244942fd5a6ecf132 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -213,7 +213,7 @@ public abstract class PlayerList {
// Spigot start - spawn location event
Player bukkitPlayer = entityplayer.getBukkitEntity();
- org.spigotmc.event.player.PlayerSpawnLocationEvent ev = new org.spigotmc.event.player.PlayerSpawnLocationEvent(bukkitPlayer, bukkitPlayer.getLocation());
+ org.spigotmc.event.player.PlayerSpawnLocationEvent ev = new com.destroystokyo.paper.event.player.PlayerInitialSpawnEvent(bukkitPlayer, bukkitPlayer.getLocation()); // Paper use our duplicate event
cserver.getPluginManager().callEvent(ev);
Location loc = ev.getSpawnLocation();
@@ -221,7 +221,10 @@ public abstract class PlayerList {
entityplayer.spawnIn(worldserver1);
entityplayer.playerInteractManager.a((WorldServer) entityplayer.world);
- entityplayer.setLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
+ // Paper start - set raw so we aren't fully joined to the world (not added to chunk or world)
+ entityplayer.setPositionRaw(loc.getX(), loc.getY(), loc.getZ());
+ entityplayer.setYawPitch(loc.getYaw(), loc.getPitch());
+ // Paper end
// Spigot end
// CraftBukkit - Moved message to after join
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 72c7602c0a97c8fb2699c556a5ed758aebfb0957..8c8f1f0f368d41c746c4ccb02dc95482f3336df3 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -399,7 +399,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, ne
return d1 * d1 + d2 * d2 + d3 * d3 < d0 * d0;
}
- protected void setYawPitch(float f, float f1) {
+ public void setYawPitch(float f, float f1) { // Paper - protected -> public
// CraftBukkit start - yaw was sometimes set to NaN, so we need to set it back to 0
if (Float.isNaN(f)) {
f = 0;