Fix more issues of chunks not appearing

This commit is contained in:
Camotoy 2023-02-23 13:11:18 -05:00
parent e42c2d8ed5
commit e50226132f
No known key found for this signature in database
GPG Key ID: 7EEFB66FE798081F
2 changed files with 7 additions and 6 deletions

View File

@ -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;

View File

@ -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);