From 31aa9966233fc47f9b69db51fcc036ad8f1d93e6 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Sat, 10 Jul 2021 23:36:25 -0400 Subject: [PATCH] Minor server-switching code cleanup --- .../client/ClientPlaySessionHandler.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java index 0fd71c706..364ac5056 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java @@ -358,24 +358,27 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler { final MinecraftConnection serverMc = destination.ensureConnected(); if (!spawned) { - // Nothing special to do with regards to spawning the player + // The player wasn't spawned in yet, so we don't need to do anything special. Just send + // JoinGame. spawned = true; - - destination.setActiveDimensionRegistry(joinGame.getDimensionRegistry()); // 1.16 player.getConnection().delayedWrite(joinGame); // Required for Legacy Forge player.getPhase().onFirstJoin(player); } else { // Clear tab list to avoid duplicate entries player.getTabList().clearAll(); + + // The player is switching from a server already, so we need to tell the client to change + // entity IDs and send new dimension information. if (player.getConnection().getType() == ConnectionTypes.LEGACY_FORGE) { this.doSafeClientServerSwitch(joinGame); } else { this.doFastClientServerSwitch(joinGame); } - destination.setActiveDimensionRegistry(joinGame.getDimensionRegistry()); // 1.16 } + destination.setActiveDimensionRegistry(joinGame.getDimensionRegistry()); // 1.16 + // Remove previous boss bars. These don't get cleared when sending JoinGame, thus the need to // track them. for (UUID serverBossBar : serverBossBars) { @@ -400,9 +403,8 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler { // Clear any title from the previous server. if (player.getProtocolVersion().compareTo(MINECRAFT_1_8) >= 0) { - player.getConnection() - .delayedWrite(GenericTitlePacket.constructTitlePacket( - GenericTitlePacket.ActionType.RESET, player.getProtocolVersion())); + player.getConnection().delayedWrite(GenericTitlePacket.constructTitlePacket( + GenericTitlePacket.ActionType.RESET, player.getProtocolVersion())); } // Flush everything