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
2023-05-12 13:10:08 +02:00
index 1d621ee5a93251c962956b4a46d937352c92f0ee..571cb21812b9927246950992505c1db730a5b868 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
2023-05-12 13:10:08 +02:00
@@ -3633,7 +3633,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
2023-01-09 03:46:54 +01:00
this.signedMessageDecoder = session.createMessageDecoder(this.player.getUUID());
this.chatMessageChain.append((executor) -> {
this.player.setChatSession(session);
- this.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.INITIALIZE_CHAT), List.of(this.player)));
+ this.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.INITIALIZE_CHAT), List.of(this.player)), this.player); // Paper
return CompletableFuture.completedFuture((Object) null);
});
}
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
2023-05-12 13:10:08 +02:00
index 0011e18963b12512464be10798006c641595988d..5c21de0d48fba88c3164b72e0eb624706b683fab 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
2023-05-12 13:10:08 +02:00
@@ -310,7 +310,7 @@ public abstract class PlayerList {
2023-03-14 22:29:14 +01:00
player.sendServerStatus(serverping);
}
2023-01-09 03:46:54 +01:00
- player.connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(this.players));
2023-03-14 22:29:14 +01:00
+ // player.connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(this.players)); // Paper
2023-01-09 03:46:54 +01:00
this.players.add(player);
this.playersByName.put(player.getScoreboardName().toLowerCase(java.util.Locale.ROOT), player); // Spigot
this.playersByUUID.put(player.getUUID(), player);
2023-05-12 13:10:08 +02:00
@@ -346,6 +346,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));
+ final List<ServerPlayer> onlinePlayers = Lists.newArrayListWithExpectedSize(this.players.size() - 1); // Paper - use single player info update packet
for (int i = 0; i < this.players.size(); ++i) {
ServerPlayer entityplayer1 = (ServerPlayer) this.players.get(i);
2023-05-12 13:10:08 +02:00
@@ -353,12 +354,17 @@ public abstract class PlayerList {
2023-01-09 03:46:54 +01:00
entityplayer1.connection.send(packet);
}
- if (!bukkitPlayer.canSee(entityplayer1.getBukkitEntity())) {
+ if (entityplayer1 == player || !bukkitPlayer.canSee(entityplayer1.getBukkitEntity())) { // Paper - don't include joining player
continue;
}
- player.connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(entityplayer1)));
+ onlinePlayers.add(entityplayer1); // Paper - use single player info update packet
}
+ // Paper start - use single player info update packet
+ if (!onlinePlayers.isEmpty()) {
+ player.connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(onlinePlayers));
+ }
+ // Paper end
player.sentListPacket = true;
player.supressTrackerForLogin = false; // Paper
((ServerLevel)player.level).getChunkSource().chunkMap.addEntity(player); // Paper - track entity now