diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java index b70e734fa5..13a99956b0 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java @@ -214,6 +214,8 @@ public void handle(Login login) throws Exception user.unsafe().sendPacket( new PluginMessage( "MC|Brand", DefinedPacket.toArray( brand ), handshakeHandler.isServerForge() ) ); brand.release(); } + + user.setDimension( login.getDimension() ); } else { @@ -231,12 +233,17 @@ public void handle(Login login) throws Exception // Send remove bossbar packet user.unsafe().sendPacket(new net.md_5.bungee.protocol.packet.BossBar(bossbar, 1)); user.getSentBossBars().clear(); - - user.sendDimensionSwitch(); - - user.setServerEntityId(login.getEntityId()); - user.unsafe().sendPacket(new Respawn(login.getDimension(), login.getDifficulty(), login.getGameMode(), login.getLevelType())); - + + user.setDimensionChange( true ); + if ( login.getDimension() == user.getDimension() ) + { + user.unsafe().sendPacket( new Respawn( ( login.getDimension() >= 0 ? -1 : 0 ), login.getDifficulty(), login.getGameMode(), login.getLevelType() ) ); + } + + user.setServerEntityId( login.getEntityId() ); + user.unsafe().sendPacket( new Respawn( login.getDimension(), login.getDifficulty(), login.getGameMode(), login.getLevelType() ) ); + user.setDimension( login.getDimension() ); + // Remove from old servers user.getServer().disconnect("Quitting"); } diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java index e0d1990941..099d74e295 100644 --- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java @@ -55,6 +55,7 @@ import net.md_5.bungee.protocol.packet.Kick; import net.md_5.bungee.protocol.packet.PlayerListHeaderFooter; import net.md_5.bungee.protocol.packet.PluginMessage; +import net.md_5.bungee.protocol.packet.Respawn; import net.md_5.bungee.protocol.packet.SetCompression; import net.md_5.bungee.tab.ServerUnique; import net.md_5.bungee.tab.TabList; @@ -80,6 +81,9 @@ public final class UserConnection implements ProxiedPlayer private ServerConnection server; @Getter @Setter + private int dimension; + @Getter + @Setter private boolean dimensionChange = true; @Getter private final Collection pendingConnects = new HashSet<>(); @@ -214,17 +218,10 @@ public void connect(ServerInfo target, Callback callback) connect( target, callback, false ); } - void sendDimensionSwitch() - { - dimensionChange = true; - unsafe().sendPacket( PacketConstants.DIM1_SWITCH ); - unsafe().sendPacket( PacketConstants.DIM2_SWITCH ); - } - public void connectNow(ServerInfo target) { - sendDimensionSwitch(); - connect( target ); + dimensionChange = true; + connect(target); } public ServerInfo updateAndGetNextServer(ServerInfo currentTarget) diff --git a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java index 0b029816c5..15185ba8a5 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java @@ -39,6 +39,7 @@ import net.md_5.bungee.protocol.packet.Kick; import net.md_5.bungee.protocol.packet.PlayerListItem; import net.md_5.bungee.protocol.packet.PluginMessage; +import net.md_5.bungee.protocol.packet.Respawn; import net.md_5.bungee.protocol.packet.ScoreboardDisplay; import net.md_5.bungee.protocol.packet.ScoreboardObjective; import net.md_5.bungee.protocol.packet.ScoreboardScore; @@ -480,6 +481,12 @@ public void handle(BossBar bossBar) } } + @Override + public void handle(Respawn respawn) + { + con.setDimension( respawn.getDimension() ); + } + @Override public String toString() {