Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Shanwer committed Jul 29, 2024
2 parents 78aa9af + 45f96a0 commit 010108a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,25 @@
package org.geysermc.geyser.translator.protocol.java;

import net.kyori.adventure.key.Key;
import org.geysermc.erosion.Constants;
import org.geysermc.geyser.level.JavaDimension;
import org.geysermc.geyser.util.MinecraftKey;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.PlayerSpawnInfo;
import org.geysermc.mcprotocollib.protocol.packet.common.serverbound.ServerboundCustomPayloadPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.GameRuleData;
import org.cloudburstmc.protocol.bedrock.data.LevelEvent;
import org.cloudburstmc.protocol.bedrock.packet.GameRulesChangedPacket;
import org.cloudburstmc.protocol.bedrock.packet.LevelEventPacket;
import org.cloudburstmc.protocol.bedrock.packet.SetPlayerGameTypePacket;
import org.geysermc.erosion.Constants;
import org.geysermc.floodgate.pluginmessage.PluginMessageChannels;
import org.geysermc.geyser.api.network.AuthType;
import org.geysermc.geyser.entity.type.player.SessionPlayerEntity;
import org.geysermc.geyser.erosion.GeyserboundHandshakePacketHandler;
import org.geysermc.geyser.level.JavaDimension;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.protocol.PacketTranslator;
import org.geysermc.geyser.translator.protocol.Translator;
import org.geysermc.geyser.util.ChunkUtils;
import org.geysermc.geyser.util.DimensionUtils;
import org.geysermc.geyser.util.EntityUtils;
import org.geysermc.geyser.util.MinecraftKey;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.PlayerSpawnInfo;
import org.geysermc.mcprotocollib.protocol.packet.common.serverbound.ServerboundCustomPayloadPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundLoginPacket;

import java.nio.charset.StandardCharsets;
import java.util.Arrays;
Expand Down Expand Up @@ -83,6 +80,13 @@ public void translate(GeyserSession session, ClientboundLoginPacket packet) {
// Remove extra hearts, hunger, etc.
entity.resetAttributes();
entity.resetMetadata();
} else if (session.getUpstream().isInitialized()) {
if (newDimension.bedrockId() == 0) {
// A dimension switch will not happen, so make sure we initialized the dimension choice.
// Otherwise, the dimension switch will fill these values in.
session.setDimensionType(newDimension);
DimensionUtils.setBedrockDimension(session, newDimension.bedrockId());
}
}

session.setWorldName(spawnInfo.getWorldName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

package org.geysermc.geyser.util;

import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.math.vector.Vector3i;
import org.cloudburstmc.protocol.bedrock.data.LevelEvent;
Expand Down Expand Up @@ -61,7 +62,7 @@ public static void switchDimension(GeyserSession session, JavaDimension javaDime
}

public static void switchDimension(GeyserSession session, JavaDimension javaDimension, int bedrockDimension) {
JavaDimension previousDimension = session.getDimensionType(); // previous java dimension
@Nullable JavaDimension previousDimension = session.getDimensionType(); // previous java dimension; can be null if an online player with no saved auth token logs in.

Entity player = session.getPlayerEntity();

Expand Down Expand Up @@ -109,7 +110,7 @@ public static void switchDimension(GeyserSession session, JavaDimension javaDime
if (isCustomBedrockNetherId()) {
if (javaDimension.isNetherLike()) {
session.camera().sendFog(BEDROCK_FOG_HELL);
} else if (previousDimension.isNetherLike()) {
} else if (previousDimension != null && previousDimension.isNetherLike()) {
session.camera().removeFog(BEDROCK_FOG_HELL);
}
}
Expand Down

0 comments on commit 010108a

Please sign in to comment.