From 8204b7592bbbc5ddacd078a892393b358c81d5a3 Mon Sep 17 00:00:00 2001 From: Adalberto Garcia Garces Date: Mon, 15 Jun 2026 16:02:59 -0300 Subject: [PATCH 1/2] Fix custom_click_action payload encoding for 1.21.6+ 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), 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 --- data/pc/1.21.11/protocol.json | 8 +++----- data/pc/latest/proto.yml | 3 ++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/data/pc/1.21.11/protocol.json b/data/pc/1.21.11/protocol.json index 999308042..13c903c31 100644 --- a/data/pc/1.21.11/protocol.json +++ b/data/pc/1.21.11/protocol.json @@ -32,6 +32,7 @@ "registryEntryHolder": "native", "registryEntryHolderSet": "native", "lpVec3": "native", + "nbtOptionalLengthPrefixed": "native", "ByteArray": [ "buffer", { @@ -4927,11 +4928,8 @@ "type": "string" }, { - "name": "nbt", - "type": [ - "option", - "anonymousNbt" - ] + "name": "payload", + "type": "nbtOptionalLengthPrefixed" } ] ] diff --git a/data/pc/latest/proto.yml b/data/pc/latest/proto.yml index 3853be73a..1bb996473 100644 --- a/data/pc/latest/proto.yml +++ b/data/pc/latest/proto.yml @@ -34,6 +34,7 @@ registryEntryHolder: native registryEntryHolderSet: native lpVec3: native + nbtOptionalLengthPrefixed: native ByteArray: ["buffer", { "countType": "varint" }] string: ["pstring", { "countType": "varint" }] vec2f: @@ -1637,7 +1638,7 @@ # MC: ServerboundCustomClickActionPacket packet_common_custom_click_action: id: string - nbt?: anonymousNbt + payload: nbtOptionalLengthPrefixed ^handshaking.toClient.types: packet: From c938191ba974fc86bfd3b55b5e50601248611814 Mon Sep 17 00:00:00 2001 From: Adalberto Garcia Garces Date: Wed, 17 Jun 2026 19:05:19 -0300 Subject: [PATCH 2/2] Apply custom_click_action length-prefixed-NBT fix to all 1.21.6+ versions 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. --- data/pc/1.21.6/proto.yml | 3 ++- data/pc/1.21.6/protocol.json | 8 +++----- data/pc/1.21.8/proto.yml | 3 ++- data/pc/1.21.8/protocol.json | 8 +++----- data/pc/1.21.9/proto.yml | 3 ++- data/pc/1.21.9/protocol.json | 8 +++----- 6 files changed, 15 insertions(+), 18 deletions(-) diff --git a/data/pc/1.21.6/proto.yml b/data/pc/1.21.6/proto.yml index 36d6cc051..73424080b 100644 --- a/data/pc/1.21.6/proto.yml +++ b/data/pc/1.21.6/proto.yml @@ -33,6 +33,7 @@ anonOptionalNbt: native registryEntryHolder: native registryEntryHolderSet: native + nbtOptionalLengthPrefixed: native ByteArray: ["buffer", { "countType": "varint" }] string: ["pstring", { "countType": "varint" }] vec2f: @@ -1330,7 +1331,7 @@ # MC: ServerboundCustomClickActionPacket packet_common_custom_click_action: id: string - nbt?: anonymousNbt + payload: nbtOptionalLengthPrefixed ^handshaking.toClient.types: packet: diff --git a/data/pc/1.21.6/protocol.json b/data/pc/1.21.6/protocol.json index 4397a4ea3..a36a0ee02 100644 --- a/data/pc/1.21.6/protocol.json +++ b/data/pc/1.21.6/protocol.json @@ -31,6 +31,7 @@ "anonOptionalNbt": "native", "registryEntryHolder": "native", "registryEntryHolderSet": "native", + "nbtOptionalLengthPrefixed": "native", "ByteArray": [ "buffer", { @@ -3618,11 +3619,8 @@ "type": "string" }, { - "name": "nbt", - "type": [ - "option", - "anonymousNbt" - ] + "name": "payload", + "type": "nbtOptionalLengthPrefixed" } ] ] diff --git a/data/pc/1.21.8/proto.yml b/data/pc/1.21.8/proto.yml index ff000ed06..e138056e9 100644 --- a/data/pc/1.21.8/proto.yml +++ b/data/pc/1.21.8/proto.yml @@ -33,6 +33,7 @@ anonOptionalNbt: native registryEntryHolder: native registryEntryHolderSet: native + nbtOptionalLengthPrefixed: native ByteArray: ["buffer", { "countType": "varint" }] string: ["pstring", { "countType": "varint" }] vec2f: @@ -1330,7 +1331,7 @@ # MC: ServerboundCustomClickActionPacket packet_common_custom_click_action: id: string - nbt?: anonymousNbt + payload: nbtOptionalLengthPrefixed ^handshaking.toClient.types: packet: diff --git a/data/pc/1.21.8/protocol.json b/data/pc/1.21.8/protocol.json index 86899ca20..e9f3077aa 100644 --- a/data/pc/1.21.8/protocol.json +++ b/data/pc/1.21.8/protocol.json @@ -31,6 +31,7 @@ "anonOptionalNbt": "native", "registryEntryHolder": "native", "registryEntryHolderSet": "native", + "nbtOptionalLengthPrefixed": "native", "ByteArray": [ "buffer", { @@ -3615,11 +3616,8 @@ "type": "string" }, { - "name": "nbt", - "type": [ - "option", - "anonymousNbt" - ] + "name": "payload", + "type": "nbtOptionalLengthPrefixed" } ] ] diff --git a/data/pc/1.21.9/proto.yml b/data/pc/1.21.9/proto.yml index ad0c57a54..18656ec2e 100644 --- a/data/pc/1.21.9/proto.yml +++ b/data/pc/1.21.9/proto.yml @@ -33,6 +33,7 @@ anonOptionalNbt: native registryEntryHolder: native registryEntryHolderSet: native + nbtOptionalLengthPrefixed: native lpVec3: native ByteArray: ["buffer", { "countType": "varint" }] string: ["pstring", { "countType": "varint" }] @@ -1560,7 +1561,7 @@ # MC: ServerboundCustomClickActionPacket packet_common_custom_click_action: id: string - nbt?: anonymousNbt + payload: nbtOptionalLengthPrefixed ^handshaking.toClient.types: packet: diff --git a/data/pc/1.21.9/protocol.json b/data/pc/1.21.9/protocol.json index d8f565bab..540de2f44 100644 --- a/data/pc/1.21.9/protocol.json +++ b/data/pc/1.21.9/protocol.json @@ -31,6 +31,7 @@ "anonOptionalNbt": "native", "registryEntryHolder": "native", "registryEntryHolderSet": "native", + "nbtOptionalLengthPrefixed": "native", "lpVec3": "native", "ByteArray": [ "buffer", @@ -4637,11 +4638,8 @@ "type": "string" }, { - "name": "nbt", - "type": [ - "option", - "anonymousNbt" - ] + "name": "payload", + "type": "nbtOptionalLengthPrefixed" } ] ]