fix(protocol): fix multi-version client protocol compatibility - #3072
Draft
Q2297045667 wants to merge 6 commits into
Draft
fix(protocol): fix multi-version client protocol compatibility#3072Q2297045667 wants to merge 6 commits into
Q2297045667 wants to merge 6 commits into
Conversation
With multi-version support, the encoding for Multi Block Update and Set Container Content packets is now differentiated by protocol version: - 1.13+: Chunk coordinates use i64, and records use VarLong. - 1.9-1.12: Use the short record format. - 1.8/1.7: Use legacy coordinate and block ID encoding. - Pre-1.9: Omit the offhand slot in the player inventory (window ID 0) to prevent out-of-bounds errors on older clients. Added corresponding unit tests to ensure data integrity during alternating encoding/decoding between legacy and modern versions.
Q2297045667
marked this pull request as draft
August 26, 2026 09:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Multi-version protocol compatibility fixes
Improved multi-version protocol compatibility and stability for legacy (1.7–1.12) Java clients.
Root Cause
1. Container Content Packet (
CSetContainerContent)IndexOutOfBoundsException: Index: 45, Size: 45while runningContainer.getSlot(45).version < 1.9 && window_id == 0 && slot_data.len() == 46, skip index 45 (the offhand slot) and write a slot count of 45. Behavior for 1.9+ is unchanged. Serialization is read-only, so the server-side offhand stack is never mutated across client-version switches.2. Multi Block Update Packet (
CMultiBlockUpdate)readerIndex ... exceeds writerIndex.(block id << 4) | metadata.Testing
cargo test -p pumpkin-protocol --lib→ 105 passed, 0 failed.cargo check --all-targets --all-features,cargo clippy --all-targets --all-features, andcargo fmt --all -- --checkall pass.cargo-machetereports no unused dependencies.Known remaining issues
SPacketSpawnMob/SPacketSpawnObjectstill send legacy 1.12 numeric entity IDs instead of 1.13 registry IDs (the ViaBackwardsmappings-1.13to1.12.nbthas noentitiessection), causingEntitySmallFireball cannot be cast to EntityLivingBaseon 1.13 clients.Related PRs