Fix custom_click_action payload (length-prefixed optional NBT) for 1.21.6+#1196
Fix custom_click_action payload (length-prefixed optional NBT) for 1.21.6+#1196atiweb wants to merge 2 commits into
Conversation
ServerboundCustomClickActionPacket's payload is
`ByteBufCodecs.optionalTagCodec(...).apply(ByteBufCodecs.lengthPrefixed(N))`: a
VarInt byte-length followed by an anonymous optional NBT tag (TAG_END = absent).
It was typed as `nbt?: anonymousNbt` (= option<anonymousNbt>), which emits a
spurious presence boolean and no length prefix, so the server rejects the packet
with an "invalid value" error. Type it as the new `nbtOptionalLengthPrefixed`
datatype instead.
Verified end to end: a real form submit with id "nlogin:login/yes" and payload
{ password: "hello world" } now serializes to the exact bytes the client expects.
Fixes PrismarineJS/node-minecraft-protocol#1484.
Requires PrismarineJS/node-minecraft-protocol#1495 (the datatype).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
You modified the custom click action packet only for 1.21.11. |
…ions custom_click_action exists since 1.21.6, not only 1.21.11, so the fix must cover every version that has the packet. Mirror the 1.21.11 change (register nbtOptionalLengthPrefixed as native + switch the packet payload to it) in 1.21.6, 1.21.8 and 1.21.9. 1.21.7 inherits 1.21.6 and 1.21.10 inherits 1.21.9 via dataPaths.json, so those are covered too.
|
Good catch, thanks — you're right. I've extended the fix to every version that has the packet: 1.21.6, 1.21.8 and 1.21.9 (1.21.7 inherits 1.21.6 and 1.21.10 inherits 1.21.9 via I verified each one against its official Mojang server jar — all encode the payload identically: ByteBufCodecs.optionalTagCodec(() -> new NbtAccounter(32768L, 16)).apply(ByteBufCodecs.lengthPrefixed(65536))So the packet has been length-prefixed since it was introduced in 1.21.6; minecraft-data just defined it as |
what about 1.21.7 and 1.21.10? |
|
Good question — and it made me re-check my earlier note, which had a mistake. 1.21.10: it's a supported version, but its 1.21.7: minecraft-data has no For reference: 1.21.6=771, 1.21.7/1.21.8=772, 1.21.9/1.21.10=773, 1.21.11=774 — so every protocol carrying |
Problem
ServerboundCustomClickActionPacket(the packet a client sends when a dialog button is clicked; dialogs were added in 1.21.6) has:So the payload is a VarInt byte-length followed by an anonymous optional NBT tag (an empty tag is a single
TAG_ENDbyte).It was typed as
nbt?: anonymousNbt(i.e.option<anonymousNbt>), which emits a spurious presence boolean and omits the length prefix. The server then reads that boolean (0x01) as aTAG_Byteand rejects the packet with an "invalid value" error (PrismarineJS/node-minecraft-protocol#1484).Fix
Type the payload as the new
nbtOptionalLengthPrefixeddatatype (added in PrismarineJS/node-minecraft-protocol#1495), and rename the fieldnbt→payloadto match the packet record.Validation
End-to-end with the new datatype, a real form submit —
id = "nlogin:login/yes",payload = { password: "hello world" }— serializes to:which matches the buffer reported as correct in #1484, and round-trips.
Depends on PrismarineJS/node-minecraft-protocol#1495.