Skip to content
mc-protocol
Esc
↑↓navigate↵open⌘Jpreview
On this page

Use Item On

Play 0x42, client → server.

play · 0x42 · serverbound (client → server)

Sent when the player right-clicks a block. location, direction, and cursor coordinates describe the hit, insideBlock and worldBorderHit are hit flags, and hand is the hand used. sequence is echoed in BlockChangedAck. The server places blocks, opens containers, or uses the item on the block.

Sent by the client, read by the server. Listen for it with client.on("UseItemOn", (data) => …) on the receiving side.

Fields

Field Type Notes
hand VarInt
location Position also position
direction VarInt also face
cursorX Float also cursorPositionX
cursorY Float also cursorPositionY
cursorZ Float also cursorPositionZ
insideBlock Boolean
worldBorderHit Boolean
sequence VarInt

Send it

await client.sendPacket("UseItemOn", {
  hand: /* VarInt */,
  location: /* Position */,
  direction: /* VarInt */,
  cursorX: /* Float */,
  cursorY: /* Float */,
  cursorZ: /* Float */,
  insideBlock: /* Boolean */,
  worldBorderHit: /* Boolean */,
  sequence: /* VarInt */,
});

Field aliases listed under Notes are accepted as alternative keys when writing.

Source: src/Core/Versions/776/Packets/play/serverbound/UseItemOn.ts

Was this page helpful?