@@ -341,7 +341,6 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
341
341
342
342
@ Setter
343
343
private Vector2i lastChunkPosition = null ;
344
- @ Setter
345
344
private int clientRenderDistance = -1 ;
346
345
private int serverRenderDistance = -1 ;
347
346
@@ -1453,11 +1452,31 @@ public void sendCommand(String command) {
1453
1452
sendDownstreamGamePacket (new ServerboundChatCommandSignedPacket (command , Instant .now ().toEpochMilli (), 0L , Collections .emptyList (), 0 , new BitSet ()));
1454
1453
}
1455
1454
1455
+ public void setClientRenderDistance (int clientRenderDistance ) {
1456
+ boolean oldSquareToCircle = this .clientRenderDistance < this .serverRenderDistance ;
1457
+ this .clientRenderDistance = clientRenderDistance ;
1458
+ boolean newSquareToCircle = this .clientRenderDistance < this .serverRenderDistance ;
1459
+
1460
+ if (this .serverRenderDistance != -1 && oldSquareToCircle != newSquareToCircle ) {
1461
+ recalculateBedrockRenderDistance ();
1462
+ }
1463
+ }
1464
+
1456
1465
public void setServerRenderDistance (int renderDistance ) {
1457
1466
// Ensure render distance is not above 96 as sending a larger value at any point crashes mobile clients and 96 is the max of any bedrock platform
1458
1467
renderDistance = Math .min (renderDistance , 96 );
1459
1468
this .serverRenderDistance = renderDistance ;
1460
1469
1470
+ recalculateBedrockRenderDistance ();
1471
+ }
1472
+
1473
+ /**
1474
+ * Ensures that the ChunkRadiusUpdatedPacket uses the correct render distance for whatever the client distance is set as.
1475
+ * If the server render distance is larger than the client's, then account for this and add some extra padding.
1476
+ * We don't want to apply this for every render distance, if at all possible, because
1477
+ */
1478
+ private void recalculateBedrockRenderDistance () {
1479
+ int renderDistance = ChunkUtils .squareToCircle (this .serverRenderDistance );
1461
1480
ChunkRadiusUpdatedPacket chunkRadiusUpdatedPacket = new ChunkRadiusUpdatedPacket ();
1462
1481
chunkRadiusUpdatedPacket .setRadius (renderDistance );
1463
1482
upstream .sendPacket (chunkRadiusUpdatedPacket );
0 commit comments