Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-04 23:30:17 +01:00
Fix dimension switching; add static references to new Java dimensions
Dieser Commit ist enthalten in:
Ursprung
e4d990329d
Commit
71aada1df3
@ -70,7 +70,7 @@ public class JavaRespawnTranslator extends PacketTranslator<ServerRespawnPacket>
|
||||
DimensionUtils.switchDimension(session, packet.getDimension());
|
||||
} else {
|
||||
if (session.isManyDimPackets()) { //reloading world
|
||||
String fakeDim = entity.getDimension().equals("minecraft:overworld") ? "minecraft:nether" : "minecraft:overworld";
|
||||
String fakeDim = entity.getDimension().equals(DimensionUtils.OVERWORLD) ? DimensionUtils.NETHER : DimensionUtils.OVERWORLD;
|
||||
DimensionUtils.switchDimension(session, fakeDim);
|
||||
DimensionUtils.switchDimension(session, packet.getDimension());
|
||||
} else {
|
||||
|
@ -36,10 +36,15 @@ public class DimensionUtils {
|
||||
// Changes if the above-bedrock Nether building workaround is applied
|
||||
private static int BEDROCK_NETHER_ID = 1;
|
||||
|
||||
// Static references to all vanilla dimensions
|
||||
public static final String OVERWORLD = "minecraft:overworld";
|
||||
public static final String NETHER = "minecraft:the_nether";
|
||||
public static final String THE_END = "minecraft:the_end";
|
||||
|
||||
public static void switchDimension(GeyserSession session, String javaDimension) {
|
||||
int bedrockDimension = javaToBedrock(javaDimension);
|
||||
Entity player = session.getPlayerEntity();
|
||||
if (bedrockToJava(bedrockDimension) == player.getDimension())
|
||||
if (javaDimension.equals(player.getDimension()))
|
||||
return;
|
||||
|
||||
session.getEntityCache().removeAllEntities();
|
||||
@ -55,7 +60,7 @@ public class DimensionUtils {
|
||||
changeDimensionPacket.setRespawn(true);
|
||||
changeDimensionPacket.setPosition(pos.toFloat());
|
||||
session.sendUpstreamPacket(changeDimensionPacket);
|
||||
player.setDimension(bedrockToJava(bedrockDimension));
|
||||
player.setDimension(javaDimension);
|
||||
player.setPosition(pos.toFloat());
|
||||
session.setSpawned(false);
|
||||
session.setLastChunkPosition(null);
|
||||
@ -85,26 +90,15 @@ public class DimensionUtils {
|
||||
*/
|
||||
public static int javaToBedrock(String javaDimension) {
|
||||
switch (javaDimension) {
|
||||
case "minecraft:nether":
|
||||
case NETHER:
|
||||
return BEDROCK_NETHER_ID;
|
||||
case "minecraft:the_end":
|
||||
case THE_END:
|
||||
return 2;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static String bedrockToJava(int bedrockDimension) {
|
||||
switch (bedrockDimension) {
|
||||
case 1:
|
||||
return "minecraft:nether";
|
||||
case 2:
|
||||
return "minecraft:the_end";
|
||||
default:
|
||||
return "minecraft:overworld";
|
||||
}
|
||||
}
|
||||
|
||||
public static void changeBedrockNetherId() {
|
||||
// Change dimension ID to the End to allow for building above Bedrock
|
||||
BEDROCK_NETHER_ID = 2;
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren