3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-04 23:30:17 +01:00

Fix crashes when joining a server in the Nether

Dieser Commit ist enthalten in:
Camotoy 2022-11-12 10:28:53 -05:00
Ursprung 7d84928627
Commit 886d7e5b4b
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F
3 geänderte Dateien mit 21 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -1420,7 +1420,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
startGamePacket.setRotation(Vector2f.from(1, 1));
startGamePacket.setSeed(-1L);
startGamePacket.setDimensionId(DimensionUtils.javaToBedrock(dimension));
startGamePacket.setDimensionId(DimensionUtils.javaToBedrock(chunkCache.getBedrockDimension()));
startGamePacket.setGeneratorId(1);
startGamePacket.setLevelGameType(GameType.SURVIVAL);
startGamePacket.setDifficulty(1);

Datei anzeigen

@ -99,6 +99,7 @@ public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket
if (needsSpawnPacket) {
// The player has yet to spawn so let's do that using some of the information in this Java packet
session.setDimension(newDimension);
DimensionUtils.setBedrockDimension(session, newDimension);
session.connect();
// It is now safe to send these packets

Datei anzeigen

@ -95,11 +95,7 @@ public class DimensionUtils {
changeDimensionPacket.setPosition(pos);
session.sendUpstreamPacket(changeDimensionPacket);
session.setDimension(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;
});
setBedrockDimension(session, javaDimension);
player.setPosition(pos);
session.setSpawned(false);
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
*