From e50226132febee19831e95c06b1ab99538ecb625 Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Thu, 23 Feb 2023 13:11:18 -0500 Subject: [PATCH] Fix more issues of chunks not appearing --- .../java/org/geysermc/geyser/session/GeyserSession.java | 8 +++----- .../main/java/org/geysermc/geyser/util/ChunkUtils.java | 5 ++++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java b/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java index bc49e8945..11467253e 100644 --- a/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java +++ b/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java @@ -180,7 +180,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource { private final AdvancementsCache advancementsCache; private final BookEditCache bookEditCache; - private @org.checkerframework.checker.nullness.qual.NonNull final ChunkCache chunkCache; + private final ChunkCache chunkCache; private final EntityCache entityCache; private final EntityEffectCache effectCache; private final FormCache formCache; @@ -1410,10 +1410,6 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource { } public void setServerRenderDistance(int renderDistance) { - // +1 is for Fabric and Spigot - // Without the client misses loading some chunks per https://github.com/GeyserMC/Geyser/issues/3490 - // Fog still appears essentially normally - renderDistance = renderDistance + 1; this.serverRenderDistance = renderDistance; ChunkRadiusUpdatedPacket chunkRadiusUpdatedPacket = new ChunkRadiusUpdatedPacket(); @@ -1425,11 +1421,13 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource { return this.upstream.getAddress(); } + @Override public boolean sendForm(@NonNull Form form) { formCache.showForm(form); return true; } + @Override public boolean sendForm(@NonNull FormBuilder formBuilder) { formCache.showForm(formBuilder.build()); return true; diff --git a/core/src/main/java/org/geysermc/geyser/util/ChunkUtils.java b/core/src/main/java/org/geysermc/geyser/util/ChunkUtils.java index 501087f78..aacf4f4d9 100644 --- a/core/src/main/java/org/geysermc/geyser/util/ChunkUtils.java +++ b/core/src/main/java/org/geysermc/geyser/util/ChunkUtils.java @@ -25,6 +25,7 @@ package org.geysermc.geyser.util; +import com.nukkitx.math.GenericMath; import com.nukkitx.math.vector.Vector2i; import com.nukkitx.math.vector.Vector3i; import com.nukkitx.protocol.bedrock.packet.LevelChunkPacket; @@ -91,7 +92,9 @@ public class ChunkUtils { if (chunkPos == null || !chunkPos.equals(newChunkPos)) { NetworkChunkPublisherUpdatePacket chunkPublisherUpdatePacket = new NetworkChunkPublisherUpdatePacket(); chunkPublisherUpdatePacket.setPosition(position); - chunkPublisherUpdatePacket.setRadius(session.getServerRenderDistance() << 4); + // Mitigates chunks not loading on 1.17.1 Paper and 1.19.3 Fabric. As of Bedrock 1.19.60. + // https://github.com/GeyserMC/Geyser/issues/3490 + chunkPublisherUpdatePacket.setRadius(GenericMath.ceil((session.getServerRenderDistance() + 1) * MathUtils.SQRT_OF_TWO) << 4); session.sendUpstreamPacket(chunkPublisherUpdatePacket); session.setLastChunkPosition(newChunkPos);