Skip to content

fix(chunks): wait for complete Bedrock data before sending - #422

Merged
RaphiMC merged 9 commits into
mainfrom
codex/wait-for-complete-bedrock-chunks
Sep 25, 2026
Merged

RaphiMC merged 9 commits into
mainfrom
codex/wait-for-complete-bedrock-chunks

Conversation

@AlexProgrammerDE

@AlexProgrammerDE AlexProgrammerDE commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Wait until all required Bedrock subchunks have arrived before queuing or sending a Java chunk.
  • Request subchunks from the current player chunk outward in bounded batches, and send completed Java chunks nearest first.
  • Remove the partial chunk resend timer from feat(light): light chunks independently of neighbors #419, since incomplete chunks are no longer sent.
  • Keep chunk lighting independent of neighboring chunks once the chunk data is complete.

The prior request path drained an unordered set and sent the entire view distance's subchunk requests in one tick. That allowed distant columns to finish and consume the Java chunk send budget before nearby terrain. The ordering change addresses the far-first sweep seen in the join video while keeping the full-chunk readiness rule.

Validation

  • ./gradlew build (passes; this project has no test sources for the Gradle test task)
  • git diff --check (passes)

A live Bedrock server join is still needed to verify terrain appearance and loading-screen timing.

The independent lighting change allowed Java chunk packets to contain empty placeholders for Bedrock subchunks that had not arrived yet. Wait for every required section before queuing a send so the terrain loading screen cannot advance on partial chunk data. Remove the partial resend timer, which is no longer needed.
Subchunk requests were drained from a hash set in arbitrary order and all view-distance requests were sent in one tick. Request a bounded batch from the player outward, then send fully loaded chunks nearest first so distant replies cannot take the initial send budget ahead of nearby terrain.
Avoid sorting the entire outstanding request set on every chunk tracker tick. Keep a companion set for deduplication and rebuild the heap when the player chunk center changes so nearby requests remain first.
A fixed 256-request tick limit can delay otherwise ready columns across ticks. Send multiple bounded request packets while a short time budget remains, leaving the Java chunk send budget unchanged.
Restore the earlier request flow so a tick drains the queue in bounded packets. Keep the separate time budget for Java chunk conversion and sending.
Remove the per-packet 256-offset grouping so a tick issues one request containing every queued subchunk. Preserve distance ordering and the separate Java chunk send time budget.
Bound request preparation by elapsed time and share the tick deadline with Java chunk sends. Split requests at the Bedrock decoder limit of 8192 offsets per packet so large views do not disconnect the client.
Use smaller Bedrock request packets while retaining the elapsed-time limit for request work in each tick.
@AlexProgrammerDE
AlexProgrammerDE marked this pull request as ready for review September 23, 2026 18:38
Merge the current main branch and resolve the chunk tracker overlap with its new Checkstyle formatting. Keep complete subchunk readiness and nearby request ordering intact.

@Exterminate5573 Exterminate5573 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me

@RaphiMC
RaphiMC merged commit 3756cc0 into main Sep 25, 2026
2 checks passed
@RaphiMC
RaphiMC deleted the codex/wait-for-complete-bedrock-chunks branch September 25, 2026 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants