3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-03 14:50:19 +01:00

Fix wrong render distance calculation

Dieser Commit ist enthalten in:
Valaphee 2022-12-15 11:56:52 +01:00
Ursprung e5867a2d0a
Commit 298d59405a
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 0F2ECD7ABFC35745
3 geänderte Dateien mit 3 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -1378,7 +1378,6 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
} }
public void setServerRenderDistance(int renderDistance) { public void setServerRenderDistance(int renderDistance) {
renderDistance = GenericMath.ceil(++renderDistance * MathUtils.SQRT_OF_TWO); //square to circle
this.serverRenderDistance = renderDistance; this.serverRenderDistance = renderDistance;
ChunkRadiusUpdatedPacket chunkRadiusUpdatedPacket = new ChunkRadiusUpdatedPacket(); ChunkRadiusUpdatedPacket chunkRadiusUpdatedPacket = new ChunkRadiusUpdatedPacket();

Datei anzeigen

@ -85,7 +85,7 @@ public class JavaPlayerPositionTranslator extends PacketTranslator<ClientboundPl
acceptTeleport(session, packet.getX(), packet.getY(), packet.getZ(), packet.getYaw(), packet.getPitch(), packet.getTeleportId()); acceptTeleport(session, packet.getX(), packet.getY(), packet.getZ(), packet.getYaw(), packet.getPitch(), packet.getTeleportId());
if (session.getServerRenderDistance() > 47 && !session.isEmulatePost1_13Logic()) { if (session.getServerRenderDistance() > 32 && !session.isEmulatePost1_13Logic()) {
// See DimensionUtils for an explanation // See DimensionUtils for an explanation
ChunkRadiusUpdatedPacket chunkRadiusUpdatedPacket = new ChunkRadiusUpdatedPacket(); ChunkRadiusUpdatedPacket chunkRadiusUpdatedPacket = new ChunkRadiusUpdatedPacket();
chunkRadiusUpdatedPacket.setRadius(session.getServerRenderDistance()); chunkRadiusUpdatedPacket.setRadius(session.getServerRenderDistance());

Datei anzeigen

@ -75,18 +75,17 @@ public class DimensionUtils {
session.getPistonCache().clear(); session.getPistonCache().clear();
session.getSkullCache().clear(); session.getSkullCache().clear();
if (session.getServerRenderDistance() > 47 && !session.isEmulatePost1_13Logic()) { if (session.getServerRenderDistance() > 32 && !session.isEmulatePost1_13Logic()) {
// The server-sided view distance wasn't a thing until Minecraft Java 1.14 // The server-sided view distance wasn't a thing until Minecraft Java 1.14
// So ViaVersion compensates by sending a "view distance" of 64 // So ViaVersion compensates by sending a "view distance" of 64
// That's fine, except when the actual view distance sent from the server is five chunks // That's fine, except when the actual view distance sent from the server is five chunks
// The client locks up when switching dimensions, expecting more chunks than it's getting // The client locks up when switching dimensions, expecting more chunks than it's getting
// To solve this, we cap at 32 unless we know that the render distance actually exceeds 32 // To solve this, we cap at 32 unless we know that the render distance actually exceeds 32
// 47 is the Bedrock equivalent of 32
// Also, as of 1.19: PS4 crashes with a ChunkRadiusUpdatedPacket too large // Also, as of 1.19: PS4 crashes with a ChunkRadiusUpdatedPacket too large
session.getGeyser().getLogger().debug("Applying dimension switching workaround for Bedrock render distance of " session.getGeyser().getLogger().debug("Applying dimension switching workaround for Bedrock render distance of "
+ session.getServerRenderDistance()); + session.getServerRenderDistance());
ChunkRadiusUpdatedPacket chunkRadiusUpdatedPacket = new ChunkRadiusUpdatedPacket(); ChunkRadiusUpdatedPacket chunkRadiusUpdatedPacket = new ChunkRadiusUpdatedPacket();
chunkRadiusUpdatedPacket.setRadius(47); chunkRadiusUpdatedPacket.setRadius(32);
session.sendUpstreamPacket(chunkRadiusUpdatedPacket); session.sendUpstreamPacket(chunkRadiusUpdatedPacket);
// Will be re-adjusted on spawn // Will be re-adjusted on spawn
} }