Repository navigation
Commit 1f45761
authored
docs(mc-config): rule the three config fork families — clamps, sync payload, singleton ownership (#61)
Settles the three config families that forked across the suite with no ruling to point at, corrects the ModMenu lang-key erratum, and codifies three conventions that were already near-universal but written down nowhere. Unblocks the eight member sweeps.
Clamps: the entry point is `clamp()`, running after every path that populates the object — file load, ModMenu save, and sync payload decode. The helper set must log each correction, cover both integral and floating-point fields, and reject non-finite input; the naming family stays free and supersets are welcome, so the ruling does not churn hundreds of assignment sites across eight members. The substantive part is the non-finite requirement: `Math.clamp`, `Mth.clamp`, and a bare `value < min` test all pass `NaN` through, and Gson yields non-finite doubles from `NaN`/`Infinity` tokens and from legal-JSON overflows like `1e400`. Open-topped helpers need an explicit `isFinite` gate, since `+Infinity` satisfies every lower bound and then throws out of `toJson` on the next save.
Singleton: rules the guarantees rather than the holder class, which is free — a volatile field, a lazy double-checked `get()`, a whole-reference swap on reload, one snapshot per method, and no in-place mutation of the live instance. Six of eight members already conform; the two that do not need one method each rather than a rename across 452 call sites.
Sync payload: `ConfigSyncPayload`, id `<mod>:config_sync`, package `network/`, binding for new payloads. A shipped divergent id keeps it until a version bump, because renaming one is a wire break — a mismatched id falls through to vanilla's unknown-payload codec, which discards the bytes with no exception and no log, leaving the client quietly running its own local rules. Direction suffixes stay a per-mod decision; measured across the suite they are 33 of 53 payload classes in a clean split, and each member is internally consistent.
Erratum: the ModMenu example used a reversed `<mod>.config.<field>` key order that no member uses. The prefix is `config.<mod>.*`, which `design/DESIGN-SYSTEM.md` already assigns, so this aligns the hub rather than setting new policy. The key table also gains the sectioned and enum-option shapes, the latter mandated by `HUD-STANDARD.md` section 4.
Also codified: config-first `onInitialize` ordering, the `<Mod>Networking` registrar, and the `ClientPlayConnectionEvents.DISCONNECT` teardown seam — the last distinguished from its server-side namesake and from `SERVER_STOPPING`, which fires on leaving a singleplayer world and so looks correct locally while leaking against a dedicated server.
Several of the originating survey's claims did not survive reconnaissance against the member repos, and the rulings follow the code instead. There is no typed-vs-GSON wire fork: all seven members put a GSON string on the wire. The client-only-field projection is inverted from the survey — meridian, prosperity, and distillation exclude their client blocks; cultivation, tribulation, mercantile, and respite ship HUD keys over the wire. The singleton split is not 4/4: all eight use `private static volatile`, and two of the four called non-conforming already implement textbook double-checked locking. No version handshake exists anywhere, so payload-id renames are non-fatal rather than safe. The registrar convention is 5/8, not 7/8, and mercantile's `SERVER_STOPPING` calls are additive server-side cleanup rather than a substitute for its client disconnect seam.
Technical claims were verified against real sources rather than asserted: Gson 2.10.1 behavior for non-finite values on both the read and write paths, the clamp logic exercised across NaN and both infinities, Fabric API 4.3.0's silent-discard path for unregistered payload ids, the `DecoderException` disconnect, the 1 MiB S2C and 32767 C2S payload ceilings, and the size cap set from the measured serialization of the suite's largest config at 17,502 bytes pretty-printed and 12,253 compact.
Closes #561 parent 51a31b5 commit 1f45761
4 files changed
Lines changed: 341 additions & 49 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
| 73 | + | |
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| |||
0 commit comments