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 72ca169e..0766e819 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java @@ -222,10 +222,15 @@ public class ServerConnector extends PacketHandler } user.getSentBossBars().clear(); - user.sendDimensionSwitch(); + 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 0e621c2e..d620fbf5 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.ClientSettings; 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<>(); @@ -210,17 +214,10 @@ public final class UserConnection implements ProxiedPlayer 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 288d6024..22f10452 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 @@ -33,6 +33,7 @@ import net.md_5.bungee.protocol.PacketWrapper; import net.md_5.bungee.protocol.packet.BossBar; import net.md_5.bungee.protocol.packet.KeepAlive; import net.md_5.bungee.protocol.packet.PlayerListItem; +import net.md_5.bungee.protocol.packet.Respawn; import net.md_5.bungee.protocol.packet.ScoreboardObjective; import net.md_5.bungee.protocol.packet.ScoreboardScore; import net.md_5.bungee.protocol.packet.ScoreboardDisplay; @@ -504,6 +505,12 @@ public class DownstreamBridge extends PacketHandler } } + @Override + public void handle(Respawn respawn) + { + con.setDimension( respawn.getDimension() ); + } + @Override public String toString() {