3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-10-05 09:20:07 +02:00

(Should) remove unneeded messages about incorrect chunk heights

Dieser Commit ist enthalten in:
Camotoy 2022-11-11 11:10:08 -05:00
Ursprung b1d832dded
Commit 7d84928627
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F
4 geänderte Dateien mit 14 neuen und 16 gelöschten Zeilen

Datei anzeigen

@ -99,16 +99,10 @@ 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);
session.setDimensionType(dimensions.get(newDimension));
ChunkUtils.loadDimension(session);
session.connect(); session.connect();
// It is now safe to send these packets // It is now safe to send these packets
session.getUpstream().sendPostStartGamePackets(); session.getUpstream().sendPostStartGamePackets();
} else if (!session.isSpawned()) {
// Called for online mode, being presented with a GUI before logging ing
session.setDimensionType(dimensions.get(newDimension));
ChunkUtils.loadDimension(session);
} }
AdventureSettingsPacket bedrockPacket = new AdventureSettingsPacket(); AdventureSettingsPacket bedrockPacket = new AdventureSettingsPacket();
@ -151,5 +145,7 @@ public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket
// If the player is spawning into the "fake" nether, send them some fog // If the player is spawning into the "fake" nether, send them some fog
session.sendFog("minecraft:fog_hell"); session.sendFog("minecraft:fog_hell");
} }
ChunkUtils.loadDimension(session);
} }
} }

Datei anzeigen

@ -36,6 +36,7 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.inventory.InventoryTranslator; import org.geysermc.geyser.translator.inventory.InventoryTranslator;
import org.geysermc.geyser.translator.protocol.PacketTranslator; import org.geysermc.geyser.translator.protocol.PacketTranslator;
import org.geysermc.geyser.translator.protocol.Translator; import org.geysermc.geyser.translator.protocol.Translator;
import org.geysermc.geyser.util.ChunkUtils;
import org.geysermc.geyser.util.DimensionUtils; import org.geysermc.geyser.util.DimensionUtils;
@Translator(packet = ClientboundRespawnPacket.class) @Translator(packet = ClientboundRespawnPacket.class)
@ -92,6 +93,8 @@ public class JavaRespawnTranslator extends PacketTranslator<ClientboundRespawnPa
} }
session.setWorldName(packet.getWorldName()); session.setWorldName(packet.getWorldName());
DimensionUtils.switchDimension(session, newDimension); DimensionUtils.switchDimension(session, newDimension);
ChunkUtils.loadDimension(session);
} }
} }
} }

Datei anzeigen

@ -222,7 +222,8 @@ public class ChunkUtils {
* This must be done after the player has switched dimensions so we know what their dimension is * This must be done after the player has switched dimensions so we know what their dimension is
*/ */
public static void loadDimension(GeyserSession session) { public static void loadDimension(GeyserSession session) {
JavaDimension dimension = session.getDimensionType(); JavaDimension dimension = session.getDimensions().get(session.getDimension());
session.setDimensionType(dimension);
int minY = dimension.minY(); int minY = dimension.minY();
int maxY = dimension.maxY(); int maxY = dimension.maxY();
@ -233,13 +234,7 @@ public class ChunkUtils {
throw new RuntimeException("Maximum Y must be a multiple of 16!"); throw new RuntimeException("Maximum Y must be a multiple of 16!");
} }
BedrockDimension bedrockDimension = switch (session.getDimension()) { BedrockDimension bedrockDimension = session.getChunkCache().getBedrockDimension();
case DimensionUtils.THE_END -> BedrockDimension.THE_END;
case DimensionUtils.NETHER -> DimensionUtils.isCustomBedrockNetherId() ? BedrockDimension.THE_END : BedrockDimension.THE_NETHER;
default -> BedrockDimension.OVERWORLD;
};
session.getChunkCache().setBedrockDimension(bedrockDimension);
// Yell in the console if the world height is too height in the current scenario // Yell in the console if the world height is too height in the current scenario
// The constraints change depending on if the player is in the overworld or not, and if experimental height is enabled // The constraints change depending on if the player is in the overworld or not, and if experimental height is enabled
// (Ignore this for the Nether. We can't change that at the moment without the workaround. :/ ) // (Ignore this for the Nether. We can't change that at the moment without the workaround. :/ )

Datei anzeigen

@ -32,6 +32,7 @@ import com.nukkitx.protocol.bedrock.packet.ChunkRadiusUpdatedPacket;
import com.nukkitx.protocol.bedrock.packet.MobEffectPacket; import com.nukkitx.protocol.bedrock.packet.MobEffectPacket;
import com.nukkitx.protocol.bedrock.packet.StopSoundPacket; import com.nukkitx.protocol.bedrock.packet.StopSoundPacket;
import org.geysermc.geyser.entity.type.Entity; import org.geysermc.geyser.entity.type.Entity;
import org.geysermc.geyser.level.BedrockDimension;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import java.util.Set; import java.util.Set;
@ -94,8 +95,11 @@ public class DimensionUtils {
changeDimensionPacket.setPosition(pos); changeDimensionPacket.setPosition(pos);
session.sendUpstreamPacket(changeDimensionPacket); session.sendUpstreamPacket(changeDimensionPacket);
session.setDimension(javaDimension); session.setDimension(javaDimension);
session.setDimensionType(session.getDimensions().get(javaDimension)); session.getChunkCache().setBedrockDimension(switch (javaDimension) {
ChunkUtils.loadDimension(session); 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);