Skip to content

Fix custom protocol isolation and auto-version selection - #1528

Open
Pix3lPirat3 wants to merge 2 commits into
PrismarineJS:masterfrom
Pix3lPirat3:fix/custom-protocol-isolation
Open

Pix3lPirat3 wants to merge 2 commits into
PrismarineJS:masterfrom
Pix3lPirat3:fix/custom-protocol-isolation

Conversation

@Pix3lPirat3

@Pix3lPirat3 Pix3lPirat3 commented Sep 11, 2026 •

Copy link
Copy Markdown

Two independent, self-contained fixes (relative to node-minecraft-protocol-forge PR PrismarineJS/node-minecraft-protocol-forge#51):

1. Custom protocol isolation

Custom packet schemas are no longer merged into, or cached against, shared minecraft-data, so a client using custom packets can no longer corrupt vanilla clients or other custom clients in the same process. (src/transforms/serializer.js; tests in test/customProtocolTest.js)

2. Auto-version selection

autoVersion selected versions[0] from the protocol's candidate list, but a protocol number maps to many versions (a release plus its snapshots and patch releases), so it frequently chose the wrong version, could return a snapshot for a plain release, returned a bogus version for protocol 0/-1, and read versions[0] after emitting the error (crashing on the empty case).

Measured over ~118,000 live servers (valid status responses), the old selection was wrong on 5.4% of the servers whose version is unambiguous. Examples:

  • 1.7.10 (protocol 5) resolved to the snapshot 14w02c
  • 1.21 (767) resolved to 1.21.1, and 1.8.8 (47) to 1.8.9 (patch overshoot within a shared protocol)
  • protocol 0 with a non-version MOTD resolved to 13w41b

Selection now prefers the protocol candidate matching the server-reported name; else the newest release among the candidates (never a snapshot); else, for an unknown/invalid protocol, falls back to the name; else emits a clear error and returns. The logic is extracted into a unit-testable chooseVersion(minecraftData, name, protocol). On the same sample: correct on 100% of the unambiguous set, snapshot mis-picks drop from 2.7% to 0.3%, and only 4.9% of picks change. (src/client/autoVersion.js; tests in test/autoVersionSchemaTest.js)

Validation

Isolate custom packet schemas between clients without mutating shared protocol data. Validate auto-version candidates against their actual protocol number to correctly select Minecraft 1.7.10. Add regression tests for both fixes. (relative to node-minecraft-protocol-forge PR)

@rom1504 rom1504 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Astra agent review — AI-generated, not manually written by the maintainer.

The reviewed changes look ready from this focused review of 633aae1. All 36 added regression cases pass. I additionally exercised an actual local 1.7.10 NMP status/login exchange with version: false, which selected 1.7.10 and reached playerJoin. Forge #51's full suite also passes with this candidate dependency (103 tests), including independent registry mappings and repeated configuration cycles.

Validation limit: an additional interpreted-codec control is blocked by the pre-existing nbt.addTypesToInterperter call, which is absent from the installed prismarine-nbt export; this PR does not introduce that call. The production compiled path and the targeted tests passed. No vanilla/Forge Java server was run in this review.

Skills used: prismarine-protocol-data-review checked selected protocol data and custom-schema isolation through the consumer; prismarine-architecture-review checked that shared data stays unchanged while vanilla caching remains available; prismarine-review kept the existing interpreter limitation separate from regressions introduced here.

@Pix3lPirat3 Pix3lPirat3 changed the title Fix custom protocol isolation and 1.7.10 auto-version selection Fix custom protocol isolation and auto-version selection Sep 28, 2026
@Pix3lPirat3

Copy link
Copy Markdown
Author

Updated the auto-version half of this PR.

The earlier approach here filtered candidates by minecraftData(v).version.version === protocolVersion and took the first. On a broad sample of live servers that removed most valid candidates: for the large majority of entries a version's own canonical protocol does not equal the protocol key it is listed under, and newer versions have no loadable data bundle, so it regressed the common case and still did not fix the patch-version overshoot (e.g. 1.21 on 767 resolving to 1.21.1).

Replaced it with chooseVersion: prefer the protocol candidate matching the server-reported name; else the newest release among the candidates (never a snapshot); else fall back to the name for an unknown/invalid protocol; else a clear error. The custom protocol isolation fix is unchanged.

Validation: this repo's tests 38/38, and the node-minecraft-protocol-forge suite 105/105 (no regression on the forge/modded layer), with 100% correct selection on ~118,000 live servers.

This branch has not been deployed

No deployments
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