From 0e72de1c18966b6dfe46c1965f1121571b34e61b Mon Sep 17 00:00:00 2001 From: Aikar Date: Sun, 19 Apr 2020 06:37:10 -0400 Subject: [PATCH] Fix Player Tracking issue during join process. Because we moved entity registration to occur before the PlayerJoinEvent occurs, We started tracking the entity too early before it was registered to the client. So delay tracking until after list packets have been sent. --- ...g-Broken-behavior-of-PlayerJoinEvent.patch | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/Spigot-Server-Patches/0486-Fix-Longstanding-Broken-behavior-of-PlayerJoinEvent.patch b/Spigot-Server-Patches/0486-Fix-Longstanding-Broken-behavior-of-PlayerJoinEvent.patch index 6bf575ea25..11acf57abf 100644 --- a/Spigot-Server-Patches/0486-Fix-Longstanding-Broken-behavior-of-PlayerJoinEvent.patch +++ b/Spigot-Server-Patches/0486-Fix-Longstanding-Broken-behavior-of-PlayerJoinEvent.patch @@ -1,4 +1,4 @@ -From 72ebe0e580f444f77811a5526d36343b3173a962 Mon Sep 17 00:00:00 2001 +From 63418c01ebd90b30014d7c173d2d0af444e832b7 Mon Sep 17 00:00:00 2001 From: Aikar Date: Sun, 19 Apr 2020 00:05:46 -0400 Subject: [PATCH] Fix Longstanding Broken behavior of PlayerJoinEvent @@ -27,8 +27,20 @@ This was very non deterministic. This change will ensure every plugin receives a deterministic result, and should no longer require 1 tick delays anymore. +diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java +index e19342eb89..cc588d6f35 100644 +--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java ++++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java +@@ -1565,6 +1565,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { + .printStackTrace(); + return; + } ++ if (entity instanceof EntityPlayer && !((EntityPlayer) entity).sentListPacket) return; // Delay adding to tracker until after list packets + // Paper end + if (!(entity instanceof EntityComplexPart)) { + if (!(entity instanceof EntityLightning)) { diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java -index 7403be0b2..e737381b3 100644 +index 7403be0b25..c2850d50d6 100644 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -175,6 +175,11 @@ public abstract class PlayerList { @@ -43,27 +55,15 @@ index 7403be0b2..e737381b3 100644 // CraftBukkit start PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(cserver.getPlayer(entityplayer), joinMessage); cserver.getPluginManager().callEvent(playerJoinEvent); -@@ -206,7 +211,7 @@ public abstract class PlayerList { - continue; - } - -- entityplayer.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[] { entityplayer1})); -+ entityplayer.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{entityplayer1})); +@@ -209,6 +214,7 @@ public abstract class PlayerList { + entityplayer.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[] { entityplayer1})); } entityplayer.sentListPacket = true; ++ ((WorldServer)entityplayer.world).getChunkProvider().playerChunkMap.addEntity(entityplayer); // Paper - track entity now // CraftBukkit end -@@ -215,8 +220,8 @@ public abstract class PlayerList { - // CraftBukkit start - Only add if the player wasn't moved in the event - if (entityplayer.world == worldserver && !worldserver.getPlayers().contains(entityplayer)) { -- worldserver.addPlayerJoin(entityplayer); -- this.server.getBossBattleCustomData().a(entityplayer); -+ //worldserver.addPlayerJoin(entityplayer); // Paper - moved up -+ //this.server.getBossBattleCustomData().a(entityplayer); // Paper - moved up - if mapping changes, update above - } - - worldserver = server.getWorldServer(entityplayer.dimension); // CraftBukkit - Update in case join event changed it -@@ -234,6 +239,11 @@ public abstract class PlayerList { + entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityplayer.getId(), entityplayer.datawatcher, true)); // CraftBukkit - BungeeCord#2321, send complete data to self on spawn +@@ -234,6 +240,11 @@ public abstract class PlayerList { playerconnection.sendPacket(new PacketPlayOutEntityEffect(entityplayer.getId(), mobeffect)); } @@ -75,7 +75,7 @@ index 7403be0b2..e737381b3 100644 if (nbttagcompound != null && nbttagcompound.hasKeyOfType("RootVehicle", 10)) { NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("RootVehicle"); // CraftBukkit start -@@ -275,6 +285,10 @@ public abstract class PlayerList { +@@ -275,6 +286,10 @@ public abstract class PlayerList { } }