inventory: claim clicked slots by hash on 1.21.5+ - #4027
Open
u9g wants to merge 1 commit into
Open
Conversation
u9g
force-pushed
the
hashed-slot-clicks
branch
from
September 4, 2026 18:17
906bab6 to
852eacc
Compare
window_click has carried HashedSlot claims since 1.21.5: item id, count and a CRC32C per component rather than the components themselves. clickWindow kept sending Item.toNotch output, so the hash field was never populated and the server resynced every slot holding an item with components after each click. Those resyncs are ordinary set_slot packets, indistinguishable from an acknowledgement the plugin is waiting for (see the book plugin in #4026). Item.toHashedNotch (PrismarineJS/prismarine-item#184) computes the hashes the server expects; use it for changedSlots and the cursor when the protocol has a HashedSlot type.
u9g
force-pushed
the
hashed-slot-clicks
branch
from
September 4, 2026 21:11
852eacc to
63bada4
Compare
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.
Depends on PrismarineJS/prismarine-item#184 (
Item.toHashedNotch); CI will fail until that is released andprismarine-itemis bumped.Problem
Since 1.21.5,
window_click'schangedSlotsandcursorItemareHashedSlots — item id, count and a CRC32C per component — not full items.clickWindowstill passesItem.toNotchoutput, so thehashfield is never set and the server resyncs every slot holding an item with components after every click (set_slot/set_cursor_item). Those resyncs look exactly like the acknowledgement packets plugins wait for; #4026 shows the resulting race inwriteBook/signBook.Change
clickWindowand_syncWindowuseItem.toHashedNotchfor slot and cursor claims when the protocol definesHashedSlot. Nothing else changes: a component prismarine-item can't hash is sent with hash 0, which keeps today's behaviour (a resync) for that slot only.The switch is keyed on
bot.registry.protocol.types.HashedSlotrather than asupportFeaturebecause minecraft-data has no feature for this; happy to add one there if preferred.Verification
/give-ing items with each supported component on vanilla 1.21.5, 1.21.11 and 26.1 and moving them between slots produced no server resync (packet trace), i.e. the hashes were accepted. Those accepted values are frozen as unit vectors in the prismarine-item PR.