aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0043-Add-PlayerInitialSpawnEvent.patch
blob: 6870fc7d27204025d09221faf7836046dddef7d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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;