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-10-25 13:52:04 +02:00
index 59b64ea82c84ff7d9b9123473b4466ec01918cd2..51f4d1e5c02c516b5c57095d35348ba53f5b3193 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-10-24 19:29:35 +02:00
@@ -3489,7 +3489,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-10-25 13:52:04 +02:00
index 61c37bf5f75207085f22093e48986dab8231e1c1..f9212fc2db00531da1618780e231e8ad21285907 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-10-24 00:08:29 +02:00
@@ -365,6 +365,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-10-24 00:08:29 +02:00
@@ -372,12 +373,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