Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-16 21:10:30 +01:00
Implement #149 to send just one respawn packet
Dieser Commit ist enthalten in:
Ursprung
62cd2c661a
Commit
39e48c9467
@ -304,25 +304,19 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
// Clear tab list to avoid duplicate entries
|
||||
player.getTabList().clearAll();
|
||||
|
||||
// In order to handle switching to another server, you will need to send three packets:
|
||||
// In order to handle switching to another server, you will need to send two packets:
|
||||
//
|
||||
// - The join game packet from the backend server
|
||||
// - A respawn packet with a different dimension
|
||||
// - Another respawn with the correct dimension
|
||||
//
|
||||
// The two respawns with different dimensions are required, otherwise the client gets
|
||||
// confused.
|
||||
// - The join game packet from the backend server, with a different dimension
|
||||
// - A respawn with the correct dimension
|
||||
//
|
||||
// Most notably, by having the client accept the join game packet, we can work around the need
|
||||
// to perform entity ID rewrites, eliminating potential issues from rewriting packets and
|
||||
// improving compatibility with mods.
|
||||
int realDim = joinGame.getDimension();
|
||||
joinGame.setDimension(getFakeTemporaryDimensionId(realDim));
|
||||
player.getConnection().delayedWrite(joinGame);
|
||||
int tempDim = joinGame.getDimension() == 0 ? -1 : 0;
|
||||
player.getConnection().delayedWrite(
|
||||
new Respawn(tempDim, joinGame.getDifficulty(), joinGame.getGamemode(),
|
||||
joinGame.getLevelType()));
|
||||
player.getConnection().delayedWrite(
|
||||
new Respawn(joinGame.getDimension(), joinGame.getDifficulty(), joinGame.getGamemode(),
|
||||
new Respawn(realDim, joinGame.getDifficulty(), joinGame.getGamemode(),
|
||||
joinGame.getLevelType()));
|
||||
}
|
||||
|
||||
@ -360,11 +354,14 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
destination.completeJoin();
|
||||
}
|
||||
|
||||
private static int getFakeTemporaryDimensionId(int dim) {
|
||||
return dim == 0 ? -1 : 0;
|
||||
}
|
||||
|
||||
public List<UUID> getServerBossBars() {
|
||||
return serverBossBars;
|
||||
}
|
||||
|
||||
|
||||
private boolean handleCommandTabComplete(TabCompleteRequest packet) {
|
||||
// In 1.13+, we need to do additional work for the richer suggestions available.
|
||||
String command = packet.getCommand().substring(1);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren