Skip to content

inventory: claim clicked slots by hash on 1.21.5+ - #4027

Open
u9g wants to merge 1 commit into
masterfrom
hashed-slot-clicks
Open

inventory: claim clicked slots by hash on 1.21.5+#4027
u9g wants to merge 1 commit into
masterfrom
hashed-slot-clicks

Conversation

@u9g

@u9g u9g commented Aug 29, 2026

Copy link
Copy Markdown
Member

Depends on PrismarineJS/prismarine-item#184 (Item.toHashedNotch); CI will fail until that is released and prismarine-item is bumped.

Problem

Since 1.21.5, window_click's changedSlots and cursorItem are HashedSlots — item id, count and a CRC32C per component — not full items. clickWindow still passes Item.toNotch output, so the hash field 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 in writeBook/signBook.

Change

clickWindow and _syncWindow use Item.toHashedNotch for slot and cursor claims when the protocol defines HashedSlot. 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.HashedSlot rather than a supportFeature because minecraft-data has no feature for this; happy to add one there if preferred.

Verification

  • Per-component: /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.
  • Regression: the full external test suite passes on 1.21.5, 1.21.11 and 26.1 with this change (74 passing, 0 failing, no retries on each).

@u9g
u9g force-pushed the hashed-slot-clicks branch from 906bab6 to 852eacc Compare September 4, 2026 18:17
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
u9g force-pushed the hashed-slot-clicks branch from 852eacc to 63bada4 Compare September 4, 2026 21:11
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.

1 participant