2023-01-09 03:46:54 +01:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Sun, 8 Jan 2023 17:38:28 -0800
Subject: [PATCH] Use single player info update packet on join
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
2024-04-25 00:36:49 +02:00
index 6e6024d9c397894903130a4b91a621ae1844a4b5..c3beef7d81e43466d99dbc6a42150a4ae9fa7f54 100644
2023-01-09 03:46:54 +01:00
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
2024-04-25 00:36:49 +02:00
@@ -3429,7 +3429,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
2023-01-09 03:46:54 +01:00
this.signedMessageDecoder = session.createMessageDecoder(this.player.getUUID());
2023-12-06 17:21:56 +01:00
this.chatMessageChain.append(() -> {
2023-01-09 03:46:54 +01:00
this.player.setChatSession(session);
- this.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.INITIALIZE_CHAT), List.of(this.player)));
2024-01-16 12:41:40 +01:00
+ this.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.INITIALIZE_CHAT), List.of(this.player)), this.player); // Paper - Use single player info update packet on join
2023-01-09 03:46:54 +01:00
});
}
2023-12-06 17:21:56 +01:00
2023-01-09 03:46:54 +01:00
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
2024-04-25 00:36:49 +02:00
index b2634bdedfe8359da602cf600a2bdddbd762e7c2..eef1fb3265a088a2f6718631c1728f3e32014c14 100644
2023-01-09 03:46:54 +01:00
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
2024-04-25 00:36:49 +02:00
@@ -361,6 +361,7 @@ public abstract class PlayerList {
2023-01-09 03:46:54 +01:00
// CraftBukkit start - sendAll above replaced with this loop
ClientboundPlayerInfoUpdatePacket packet = ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(player));
2024-01-16 12:41:40 +01:00
+ final List<ServerPlayer> onlinePlayers = Lists.newArrayListWithExpectedSize(this.players.size() - 1); // Paper - Use single player info update packet on join
2023-01-09 03:46:54 +01:00
for (int i = 0; i < this.players.size(); ++i) {
ServerPlayer entityplayer1 = (ServerPlayer) this.players.get(i);
2024-04-25 00:36:49 +02:00
@@ -368,12 +369,17 @@ public abstract class PlayerList {
2023-01-09 03:46:54 +01:00
entityplayer1.connection.send(packet);
}
- if (!bukkitPlayer.canSee(entityplayer1.getBukkitEntity())) {
2024-01-16 12:41:40 +01:00
+ if (entityplayer1 == player || !bukkitPlayer.canSee(entityplayer1.getBukkitEntity())) { // Paper - Use single player info update packet on join; Don't include joining player
2023-01-09 03:46:54 +01:00
continue;
}
- player.connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(entityplayer1)));
2024-01-16 19:27:39 +01:00
+ onlinePlayers.add(entityplayer1); // Paper - Use single player info update packet on join
2023-01-09 03:46:54 +01:00
}
2024-01-16 12:41:40 +01:00
+ // Paper start - Use single player info update packet on join
2023-01-09 03:46:54 +01:00
+ if (!onlinePlayers.isEmpty()) {
+ player.connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(onlinePlayers));
+ }
2024-01-16 12:41:40 +01:00
+ // Paper end - Use single player info update packet on join
2023-01-09 03:46:54 +01:00
player.sentListPacket = true;
2024-01-21 12:11:43 +01:00
player.supressTrackerForLogin = false; // Paper - Fire PlayerJoinEvent when Player is actually ready
((ServerLevel)player.level()).getChunkSource().chunkMap.addEntity(player); // Paper - Fire PlayerJoinEvent when Player is actually ready; track entity now