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-09-07 21:49:28 +02:00
index a2a7d499a68841ecd76ba029298094993a82bf39..a6f58438badb0bdeab67706f4a8e519b202623fe 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-08-31 20:29:50 +02:00
@@ -3436,7 +3436,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-09-15 21:39:53 +02:00
index 38b9ab369e25e4b718418375f76e782283b48411..bd67245393f512264db774e0b855db0ce925a3f4 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