Skip to content

pc: fix custom_click_action NBT to use a VarInt length prefix - #1230

Open
AnonymoDGH wants to merge 1 commit into
PrismarineJS:masterfrom
AnonymoDGH:fix/custom-click-action-nbt-length
Open

pc: fix custom_click_action NBT to use a VarInt length prefix#1230
AnonymoDGH wants to merge 1 commit into
PrismarineJS:masterfrom
AnonymoDGH:fix/custom-click-action-nbt-length

Conversation

@AnonymoDGH

Copy link
Copy Markdown
Contributor

Fixes #1222

Problem

packet_common_custom_click_action declared its NBT field as:

packet_common_custom_click_action:
    id: string
    nbt?: anonymousNbt

which encodes it as an optional value with a boolean prefix. The actual wire format used by the vanilla client (and expected by BungeeCord) is:

resource location + VarInt payload length + unnamed NBT payload

BungeeCord reads it via readLengthPrefixed(...) (CustomClickAction.java), i.e. a VarInt length followed by the NBT bytes — there is no optional sentinel. With the old schema the client wrote 01 0A 0B ... (BungeeCord read 01 as the payload length and the NBT decoder failed with Exception reading tag), and writing the NBT without any prefix (0A 0B ...) is also invalid.

Fix

Changed the field to a VarInt-length-prefixed buffer in every affected version — the exact representation verified in the issue to produce byte-identical output to the vanilla client:

packet_common_custom_click_action:
    id: string
    nbt: ["buffer", { "countType": "varint" }]

Applied to data/pc/1.21.6, 1.21.8, 1.21.9, 1.21.11 and latest (all of which carried the same incorrect definition), and regenerated the corresponding protocol.json files (1.21.6, 1.21.8, 1.21.9, 1.21.11, 26.1) with npm run build.

Verified

  • Cross-checked against BungeeCord's CustomClickAction (readLengthPrefixed/writeLengthPrefixed → VarInt length + NBT, always present).
  • protocolSync test passes: all proto.yml files are valid and in sync with their protocol.json.
  • The regenerated protocol.json diffs contain only the nbt field change.

@AnonymoDGH

Copy link
Copy Markdown
Contributor Author

Note on CI: the build check (bedrock-ci.yml) fails with Cannot find package '@napi-rs/snappy-wasm32-wasi' while loading the separate bedrock-protocol repo's own modules. This is an environmental dependency issue in that repo's test setup and is unrelated to this change, which only touches data/pc/* (PC protocol data) that bedrock-protocol tests don't consume. The authoritative validation for this change — build (24) (ci.yml → tools/js protocolSync + schema tests) — passes.

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.

PC 1.21.8: custom_click_action NBT is missing its VarInt length prefix

1 participant