pc: fix intangible_projectile NBT and 26.1 item stack templates - #1267
Open
u9g wants to merge 3 commits into
Open
pc: fix intangible_projectile NBT and 26.1 item stack templates#1267u9g wants to merge 3 commits into
u9g wants to merge 3 commits into
Conversation
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).
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.
Member
Author
I just checked, yes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 hadanonymousNbtand 1.21.5 onward regressed tovoid, leaving two bytes unread in any slot carrying the component (protodef PartialReadError onset_slot).unbreakableandgliderstayvoid: 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
Slotform (set_slot,window_items, cursor, equipment, merchant offers, entity metadata) is unchanged. Before this fix, nested stacks decode withitemId/itemCountswapped — givingbundle[bundle_contents=[{id:stone,count:3},{id:dirt}]]parsed as item 3 ×1 and item 1 ×28.This adds an
ItemStackTemplatetype and uses it where vanilla uses the template codec (cross-checked against MCProtocolLib'sreadItemStackTemplatecall sites):use_remainder,charged_projectiles,bundle_contentscomponentscontainercomponent — now a prefixed-optional template per entry, preserving empty slotsitemparticleitem_stackslot displayVerification
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
containerdecoding[null, diamond(899)×5], advancement icons andminecraft:itemparticle 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.jsonfiles are regenerated from the editedproto.ymls vianpm run build;tools/jstests pass (the only local failure is the 40s suite-duration gate, from running Minecraft servers concurrently on the same machine).