Closed Skidamek closed 1 week ago
Thanks for the support! I will check this commit out and get back to you.
In regards to your problem with reloading the ClientChunkCache
, this is how I fixed it. In 1.20.2, Mojang introduced a new system for sending chunks (1.20.2 -> Protocol). I don't know how it worked before, but this new system introduced a file called ChunkTrackingView
which decided which chunks the client should receive, discard, and keep. I modified this file here to wrap those calculations so chunks from the other side of the world would be sent and not discarded when the player crossed the bounds.
To handle player movement and keeping the client from reloading all the chunks in the world, I basically lied to the client about it's position. While the server actually "teleports" the player to the other side of the world when they move across it (see here) the same isn't so for the client. When the client moves across the bounds, the server just tells the client their coordinates are still increasing. If the client is at the edge of chunk -16 and is moving into chunk 15 from the other side of the world, while the server moves the player to chunk 15, it tells the player's client to move to chunk -17. This is how the client can move seamlessly without chunk reloading, etc, and also how I can support vanilla clients. If you watch your debug screen, you will see that the more times you fly around the world, the higher your coordinates go. This is all handled in my PacketTransformer which determines what coordinates should go in the packets based on the client's actual relative position. These fields store and retrieve the relative position of the client so the coordinates sent in the C->S packets are accurate to the client's position.
CoordinateTransformers and WorldTransformer (which uses CoordinateTransformers
), are the core files which make this mod work. CoordinateTransformers
provides wrapping operations such as wrapChunkToLimit
and unwrapChunkFromLimit
and WorldTransformer
provides an x
and z
CoordinateTransformer
and wrapping adapters for different types of objects, such as a ChunkPos
, BlockPos
and Vec3
. (CoordinateTransformers
aren't optimized yet, but I don't want them to accidentally be the source of bugs from those optimizations.)
Yeah it's really impressive what you have achieved, plus that's all compatible with vanilla client is crazy and love it, I would be happy to contribute more.
Also are you after some math/computer engineering university? Maybe it's not some most insane level of science but still brilliant, I couldn't get that far with this concept.
Also are you after some math/computer engineering university? Maybe it's not some most insane level of science but still brilliant, I couldn't get that far with this concept.
I'm not currently in university, but I did take computer science classes. Most of the work behind this concept comes from reading tons and tons of code. I'd say 80% of my time on this mod was spent reading the code. It takes a lot of time to discover the best place to put transformations that won't be overly tedious to implement or maintain.
Boats are now working correctly, before you would get stuck. (Minecarts are still broken on border edges for some reason)
btw thanks a lot for working on this! i had the same idea year ago and couldn't figure out how to move player across chunks without reloading chunk cache on client. This is genius, least i can do is to contribute.