GithubHelp home page GithubHelp logo

Comments (3)

Mac898 avatar Mac898 commented on July 23, 2024

This is also happening with me for a completely vanilla 1.20.1 client when loading an Anvil world.
I will try to do some investigating when I can, but I can re-confirm it occurs whenever the spawn position is set away from 0,0 for me.

Spawning the player in at more than +- 80-96 blocks in either direction seems to be when the issue occurs. This is exactly 5/6 chunks away.

As for the client log, that's quite interesting since there is a lot of:

[00:26:43] [Render thread/WARN]: Ignoring chunk since it's not in the view range: -6, -6
[00:26:43] [Render thread/WARN]: Ignoring chunk since it's not in the view range: -6, -7
[00:26:43] [Render thread/WARN]: Ignoring chunk since it's not in the view range: -7, -6
[00:26:43] [Render thread/WARN]: Ignoring chunk since it's not in the view range: -5, -6
[00:26:43] [Render thread/WARN]: Ignoring chunk since it's not in the view range: -6, -5
[00:26:43] [Render thread/WARN]: Ignoring chunk since it's not in the view range: -7, -7
[00:26:43] [Render thread/WARN]: Ignoring chunk since it's not in the view range: -5, -7
[00:26:43] [Render thread/WARN]: Ignoring chunk since it's not in the view range: -7, -5
[00:26:43] [Render thread/WARN]: Ignoring chunk since it's not in the view range: -6, -8
[00:26:43] [Render thread/WARN]: Ignoring chunk since it's not in the view range: -8, -6
[00:26:43] [Render thread/WARN]: Ignoring chunk since it's not in the view range: -4, -6
[00:26:43] [Render thread/WARN]: Ignoring chunk since it's not in the view range: -6, -4

Update:
I've got a packet capture setup, and I can see that the valence server tends to send a lot more chunk packets than the vanilla one:

| Level Chunk With Light     | 1024 (98.75%) | 64104 (80.57%) |

vs

| Level Chunk With Light         |  453 ( 7.80%) | 2386807 (95.27%) |

However, this is the same as in the cases where the world does load properly:

| Level Chunk With Light     | 1024 (98.75%) | 4622204 (99.67%) |

vs

| Level Chunk With Light         |  453 (19.56%) | 2385156 (96.66%) |

All the measurements were taken in the same world at positions -80, surface, 0 (working) and -96, surface, 0 (not working).
Here's a link to the raw logs incase that helps anyone: https://gist.github.com/Mac898/6284cd75ee4029c4b226d90af3697d74

I'm curious if it's the order of the chunks that are making the big difference considering that the number of chunks sent by valence in the working vs non-working configuration are the same.

The hypothesis I will be testing is that valence is over-filling a cache, causing the minecraft client to forget the chunks that are actually needed, therefore causing the world holes.

Update:
The high number of chunks was caused by me force-loading a lot of the chunks. Here's an example with only -4 to 4 forcibly loaded.
https://gist.github.com/Mac898/f240afd3c9af23c5f2ac8b8debd88c48

from valence.

Mac898 avatar Mac898 commented on July 23, 2024

I found out that the difference in ordering of the player position and default spawn position packets in relation to the chunks was due to me using a encrypted/authenticated server in one case, and not in the other.

I've got new logs which have much more detail:
https://gist.github.com/Mac898/700a91d6dec5b78e5571aa6f0dfd2a74

However, looking over the diff carefully I see one main difference: "Set Chunk Cache Center"
https://wiki.vg/Protocol#Set_Center_Chunk
It's sent immediately after the default spawn position by the vanilla server.

My guess: Since we haven't initialized the buffer here the client isn't expecting the correct chunks and it ends up failing in some way. So i'm going to try and send this packet as the next debugging step.

We also send "Set Chunk Cache Radius", which according to the wiki is only sent by the integrated server:
https://wiki.vg/Protocol#Set_Render_Distance
That's another thing to check.

from valence.

Mac898 avatar Mac898 commented on July 23, 2024

I'm not sure that this in the right place, but I have a working diff:

index 776ecbc..f86ade4 100644
--- a/crates/valence_server/src/client.rs
+++ b/crates/valence_server/src/client.rs
@@ -600,10 +600,21 @@ pub fn despawn_disconnected_clients(
 }

 fn update_chunk_load_dist(
-    mut clients: Query<(&mut Client, &ViewDistance, &OldViewDistance), Changed<ViewDistance>>,
+    mut clients: Query<
+        (&mut Client, &ViewDistance, &OldViewDistance, &Position),
+        Changed<ViewDistance>,
+    >,
 ) {
-    for (mut client, dist, old_dist) in &mut clients {
+    for (mut client, dist, old_dist, pos) in &mut clients {
         if client.is_added() {
+            // TODO: Locate to a better place.
+            // Set Chunk Cache Center On First Load.
+            let chunk_pos = ChunkPos::from(pos.0);
+            client.write_packet(&ChunkRenderDistanceCenterS2c {
+                chunk_x: VarInt(chunk_pos.x),
+                chunk_z: VarInt(chunk_pos.z),
+            });
+
             // Join game packet includes the view distance.
             continue;
         }

Seems to solve the issue in Vanilla, and with Sodium/Iris modded client.
Note although that lighting is still broken for me with Sodium/Iris installed.

I'll happily PR this, but maybe someone with more experience could direct me on the appropriate place to put this.

from valence.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.