Fix custom protocol isolation and auto-version selection - #1528
Pix3lPirat3 wants to merge 2 commits into
Conversation
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
left a comment
There was a problem hiding this comment.
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.
|
Updated the auto-version half of this PR. The earlier approach here filtered candidates by Replaced it with 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. |
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 intest/customProtocolTest.js)2. Auto-version selection
autoVersionselectedversions[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 readversions[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 snapshot14w02c1.21(767) resolved to1.21.1, and1.8.8(47) to1.8.9(patch overshoot within a shared protocol)0with a non-version MOTD resolved to13w41bSelection 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 intest/autoVersionSchemaTest.js)Validation
autoVersionSchemaTest.js+customProtocolTest.js-> 38 passing.