|
38 | 38 | import com.github.steveice10.mc.protocol.data.UnexpectedEncryptionException;
|
39 | 39 | import com.github.steveice10.mc.protocol.data.game.entity.metadata.Pose;
|
40 | 40 | import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
| 41 | +import com.github.steveice10.mc.protocol.data.game.entity.player.HandPreference; |
41 | 42 | import com.github.steveice10.mc.protocol.data.game.recipe.Recipe;
|
| 43 | +import com.github.steveice10.mc.protocol.data.game.setting.ChatVisibility; |
| 44 | +import com.github.steveice10.mc.protocol.data.game.setting.SkinPart; |
42 | 45 | import com.github.steveice10.mc.protocol.data.game.statistic.CustomStatistic;
|
43 | 46 | import com.github.steveice10.mc.protocol.data.game.statistic.Statistic;
|
44 | 47 | import com.github.steveice10.mc.protocol.packet.handshake.serverbound.ClientIntentionPacket;
|
| 48 | +import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundClientInformationPacket; |
45 | 49 | import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerPosPacket;
|
46 | 50 | import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundPlayerAbilitiesPacket;
|
47 | 51 | import com.github.steveice10.mc.protocol.packet.login.serverbound.ServerboundCustomQueryPacket;
|
@@ -245,7 +249,9 @@ public class GeyserSession implements GeyserConnection, CommandSender {
|
245 | 249 |
|
246 | 250 | @Setter
|
247 | 251 | private Vector2i lastChunkPosition = null;
|
248 |
| - private int renderDistance; |
| 252 | + @Setter |
| 253 | + private int clientRenderDistance = -1; |
| 254 | + private int serverRenderDistance; |
249 | 255 |
|
250 | 256 | // Exposed for GeyserConnect usage
|
251 | 257 | protected boolean sentSpawnPacket;
|
@@ -1160,9 +1166,9 @@ public String getLocale() {
|
1160 | 1166 | return clientData.getLanguageCode();
|
1161 | 1167 | }
|
1162 | 1168 |
|
1163 |
| - public void setRenderDistance(int renderDistance) { |
| 1169 | + public void setServerRenderDistance(int renderDistance) { |
1164 | 1170 | renderDistance = GenericMath.ceil(++renderDistance * MathUtils.SQRT_OF_TWO); //square to circle
|
1165 |
| - this.renderDistance = renderDistance; |
| 1171 | + this.serverRenderDistance = renderDistance; |
1166 | 1172 |
|
1167 | 1173 | ChunkRadiusUpdatedPacket chunkRadiusUpdatedPacket = new ChunkRadiusUpdatedPacket();
|
1168 | 1174 | chunkRadiusUpdatedPacket.setRadius(renderDistance);
|
@@ -1420,6 +1426,27 @@ public void sendAdventureSettings() {
|
1420 | 1426 | sendUpstreamPacket(adventureSettingsPacket);
|
1421 | 1427 | }
|
1422 | 1428 |
|
| 1429 | + private int getRenderDistance() { |
| 1430 | + if (clientRenderDistance != -1) { |
| 1431 | + // The client has sent a render distance |
| 1432 | + return clientRenderDistance; |
| 1433 | + } |
| 1434 | + return serverRenderDistance; |
| 1435 | + } |
| 1436 | + |
| 1437 | + // We need to send our skin parts to the server otherwise java sees us with no hat, jacket etc |
| 1438 | + private static final List<SkinPart> SKIN_PARTS = Arrays.asList(SkinPart.values()); |
| 1439 | + |
| 1440 | + /** |
| 1441 | + * Send a packet to the server to indicate client render distance, locale, skin parts, and hand preference. |
| 1442 | + */ |
| 1443 | + public void sendJavaClientSettings() { |
| 1444 | + ServerboundClientInformationPacket clientSettingsPacket = new ServerboundClientInformationPacket(getLocale(), |
| 1445 | + getRenderDistance(), ChatVisibility.FULL, true, SKIN_PARTS, |
| 1446 | + HandPreference.RIGHT_HAND, false, true); |
| 1447 | + sendDownstreamPacket(clientSettingsPacket); |
| 1448 | + } |
| 1449 | + |
1423 | 1450 | /**
|
1424 | 1451 | * Used for updating statistic values since we only get changes from the server
|
1425 | 1452 | *
|
|
0 commit comments