Skip to content

pc: fix intangible_projectile NBT and 26.1 item stack templates - #1267

Open
u9g wants to merge 3 commits into
masterfrom
fix-item-stack-template
Open

pc: fix intangible_projectile NBT and 26.1 item stack templates#1267
u9g wants to merge 3 commits into
masterfrom
fix-item-stack-template

Conversation

@u9g

@u9g u9g commented Aug 30, 2026

Copy link
Copy Markdown
Member

Two protocol fixes found by PrismarineJS/prismarine-item#184's live vanilla tests.

intangible_projectile is NBT, not void (1.21.5–26.1)

The component has no dedicated network codec, so vanilla syncs it through its NBT codec — an empty compound (0a 00) on the wire. 1.20.5–1.21.4 correctly had anonymousNbt and 1.21.5 onward regressed to void, leaving two bytes unread in any slot carrying the component (protodef PartialReadError on set_slot). unbreakable and glider stay void: they have real unit stream codecs and decode cleanly today.

26.1 sends non-empty stacks as item stack templates (item id first)

26.1 changed the non-optional stack codec to item id, count, components; the optional count-first Slot form (set_slot, window_items, cursor, equipment, merchant offers, entity metadata) is unchanged. Before this fix, nested stacks decode with itemId/itemCount swapped — giving bundle[bundle_contents=[{id:stone,count:3},{id:dirt}]] parsed as item 3 ×1 and item 1 ×28.

This adds an ItemStackTemplate type and uses it where vanilla uses the template codec (cross-checked against MCProtocolLib's readItemStackTemplate call sites):

  • use_remainder, charged_projectiles, bundle_contents components
  • container component — now a prefixed-optional template per entry, preserving empty slots
  • the item particle
  • the item_stack slot display
  • the advancement display icon

Verification

Each site was checked against real vanilla servers (1.21.5, 1.21.6, 1.21.8, 1.21.9, 1.21.11, 26.1) by giving items carrying each component, granting an advancement and spawning item particles, then confirming the decoded ids and counts match what was given, with zero parse errors. On 26.1: stone(1)×3 + dirt(28)×1 bundle, shulker container decoding [null, diamond(899)×5], advancement icons and minecraft:item particle all correct. prismarine-item#184's 78 live window_click hash tests still pass against 1.21.5/1.21.11 with these files, now with no PartialReadErrors.

protocol.json files are regenerated from the edited proto.ymls via npm run build; tools/js tests pass (the only local failure is the 40s suite-duration gate, from running Minecraft servers concurrently on the same machine).

intangible_projectile has no dedicated network codec, so vanilla syncs
it as NBT (an empty compound); 1.20.5-1.21.4 had it right and 1.21.5
onward regressed to void, leaving two bytes unread in any slot carrying
it.

26.1 sends non-empty stacks (item stack templates) with the item id
before the count, while the optional count-first Slot form is
unchanged. Add an ItemStackTemplate type and use it at the sites
vanilla serializes with the template codec: the use_remainder,
charged_projectiles, bundle_contents and container components (the
latter as a prefixed optional now, preserving empty slots), the item
particle, the item_stack slot display and the advancement icon.

Verified against vanilla 1.21.5-26.1 servers by giving items carrying
each component, granting an advancement and spawning item particles,
and checking the decoded ids, counts and hashes against what was
given (PrismarineJS/prismarine-item#184's live tests).
@rom1504

rom1504 commented Aug 30, 2026

Copy link
Copy Markdown
Member

Did you check against the decompiled code ?

EntityDataSerializers.ITEM_STACK still uses ItemStack.OPTIONAL_STREAM_CODEC
(count-first optional) in 26.1; only the template call sites changed.
@u9g

u9g commented Aug 30, 2026

Copy link
Copy Markdown
Member Author

Did you check against the decompiled code ?

I just checked, yes.

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.

2 participants