Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-26 16:12:46 +01:00
Fix crashes when joining a server in the Nether
Dieser Commit ist enthalten in:
Ursprung
7d84928627
Commit
886d7e5b4b
@ -1420,7 +1420,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
|||||||
startGamePacket.setRotation(Vector2f.from(1, 1));
|
startGamePacket.setRotation(Vector2f.from(1, 1));
|
||||||
|
|
||||||
startGamePacket.setSeed(-1L);
|
startGamePacket.setSeed(-1L);
|
||||||
startGamePacket.setDimensionId(DimensionUtils.javaToBedrock(dimension));
|
startGamePacket.setDimensionId(DimensionUtils.javaToBedrock(chunkCache.getBedrockDimension()));
|
||||||
startGamePacket.setGeneratorId(1);
|
startGamePacket.setGeneratorId(1);
|
||||||
startGamePacket.setLevelGameType(GameType.SURVIVAL);
|
startGamePacket.setLevelGameType(GameType.SURVIVAL);
|
||||||
startGamePacket.setDifficulty(1);
|
startGamePacket.setDifficulty(1);
|
||||||
|
@ -99,6 +99,7 @@ public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket
|
|||||||
if (needsSpawnPacket) {
|
if (needsSpawnPacket) {
|
||||||
// The player has yet to spawn so let's do that using some of the information in this Java packet
|
// The player has yet to spawn so let's do that using some of the information in this Java packet
|
||||||
session.setDimension(newDimension);
|
session.setDimension(newDimension);
|
||||||
|
DimensionUtils.setBedrockDimension(session, newDimension);
|
||||||
session.connect();
|
session.connect();
|
||||||
|
|
||||||
// It is now safe to send these packets
|
// It is now safe to send these packets
|
||||||
|
@ -95,11 +95,7 @@ public class DimensionUtils {
|
|||||||
changeDimensionPacket.setPosition(pos);
|
changeDimensionPacket.setPosition(pos);
|
||||||
session.sendUpstreamPacket(changeDimensionPacket);
|
session.sendUpstreamPacket(changeDimensionPacket);
|
||||||
session.setDimension(javaDimension);
|
session.setDimension(javaDimension);
|
||||||
session.getChunkCache().setBedrockDimension(switch (javaDimension) {
|
setBedrockDimension(session, javaDimension);
|
||||||
case DimensionUtils.THE_END -> BedrockDimension.THE_END;
|
|
||||||
case DimensionUtils.NETHER -> DimensionUtils.isCustomBedrockNetherId() ? BedrockDimension.THE_END : BedrockDimension.THE_NETHER;
|
|
||||||
default -> BedrockDimension.OVERWORLD;
|
|
||||||
});
|
|
||||||
player.setPosition(pos);
|
player.setPosition(pos);
|
||||||
session.setSpawned(false);
|
session.setSpawned(false);
|
||||||
session.setLastChunkPosition(null);
|
session.setLastChunkPosition(null);
|
||||||
@ -137,6 +133,24 @@ public class DimensionUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setBedrockDimension(GeyserSession session, String javaDimension) {
|
||||||
|
session.getChunkCache().setBedrockDimension(switch (javaDimension) {
|
||||||
|
case DimensionUtils.THE_END -> BedrockDimension.THE_END;
|
||||||
|
case DimensionUtils.NETHER -> DimensionUtils.isCustomBedrockNetherId() ? BedrockDimension.THE_END : BedrockDimension.THE_NETHER;
|
||||||
|
default -> BedrockDimension.OVERWORLD;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int javaToBedrock(BedrockDimension dimension) {
|
||||||
|
if (dimension == BedrockDimension.THE_NETHER) {
|
||||||
|
return BEDROCK_NETHER_ID;
|
||||||
|
} else if (dimension == BedrockDimension.THE_END) {
|
||||||
|
return 2;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map the Java edition dimension IDs to Bedrock edition
|
* Map the Java edition dimension IDs to Bedrock edition
|
||||||
*
|
*
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren