Skip to content

feat(mineflayer): forward map_chunk + update_light packets to renderer worker (PR #15 - Renderer)#549

Merged
zardoy merged 6 commits intozardoy:renderer-removefrom
sandexzx:wasm-mesher-raw-map-chunk
May 7, 2026
Merged

feat(mineflayer): forward map_chunk + update_light packets to renderer worker (PR #15 - Renderer)#549
zardoy merged 6 commits intozardoy:renderer-removefrom
sandexzx:wasm-mesher-raw-map-chunk

Conversation

@sandexzx
Copy link
Copy Markdown
Collaborator

@sandexzx sandexzx commented May 6, 2026

What this does

Wires the client into the new WASM parser on the renderer side. The entire client-side change is one new listener file plus one line of plugin registration — all parsing/conversion/caching complexity lives in the renderer.

Files

  • src/mineflayer/plugins/index.ts (+2): import + mapChunkListener() call.
  • src/mineflayer/plugins/mapChunkListener.ts (+273, new): three version-gated branches.

Version routing by bot._client.version / protocol

Protocol MC Subscribes Emits on appViewer.worldView
>= 757 1.18 – 1.21 raw.map_chunk, raw.update_light setRawMapChunk, setRawUpdateLight
756 1.17 map_chunk (parsed), raw.update_light setParsedMapChunkV17, setUpdateLightV17
735–754 1.16, 1.16.1, 1.16.2, 1.16.3, 1.16.4, 1.16.5 map_chunk (parsed), raw.update_light setParsedMapChunkV16, setUpdateLightV16

For protocols < 735 we don't attach — those versions are still served by the legacy convertChunkToWasm path through the standard prismarine-chunk flow.

Tests / smoke

  • Smoke against 1.21, 1.17, 1.16.5 — geometry, light and biomes render correctly.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3dddb143-79e8-4604-ba97-bfd9bad0c016

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@zardoy zardoy merged commit ce03875 into zardoy:renderer-remove May 7, 2026
2 of 3 checks passed
@zardoy
Copy link
Copy Markdown
Owner

zardoy commented May 7, 2026

tbh I think we could keep everything off the worldView here (IMO worldView has to be reworked) and use maybe backend methods instead?

IMO we should have leave all renderer communication with two-way methods eg renderer backend methods + reverse callbacks
or playerState state

@sandexzx
Copy link
Copy Markdown
Collaborator Author

sandexzx commented May 7, 2026

tbh I think we could keep everything off the worldView here (IMO worldView has to be reworked) and use maybe backend methods instead?

IMO we should have leave all renderer communication with two-way methods eg renderer backend methods + reverse callbacks or playerState state

Agreed.

But the full backendMethods + reverse-callbacks/playerState pattern is overkill here: the data flow is strictly one-way fire-and-forget (client → renderer worker, no response, no shared state). We only need the forward half.

Proposal:

  1. Single feedChunkPacket(payload) method in getBackendMethods, payload is a discriminated union over the 5 kinds (rawV18 / parsedV17 / lightV17 / parsedV16 / lightV16).
  2. Move the broadcast loop (worldrendererCommon.ts ~860–940) into that method.
  3. Drop the 5 entries from WorldViewEvents.
  4. In mapChunkListener.ts: appViewer.backend?.backendMethods?.feedChunkPacket?.(payload) — same optional-chaining already used in cameraRotationControls / playerState.

Bonus: workerProxy auto-detects Transferables, so Uint8Array.buffer goes zero-copy to the renderer worker (currently worldView does structured clone, ~10–30 KB per chunk).

@zardoy
Copy link
Copy Markdown
Owner

zardoy commented May 7, 2026

Sounds nice

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.

2 participants