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

Set Player Inventory

Play 0x6C, server → client.

play · 0x6C · clientbound (server → client)

Sets one slot of the player’s own inventory to contents. The server sends it when a single inventory slot changes while no container is open or the change is outside the open container.

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

Fields

Field Type Notes
slotId VarInt
contents Slot

Send it

import { helpers } from "mc-protocol";

// Server-side connection, after entering play state.
await client.sendPacket("SetPlayerInventory", {
  slotId: 0, // first hotbar slot
  contents: helpers.createSlot("diamond_sword", {
    name: { text: "Excalibur", color: "gold" },
    lore: ["Forged in TypeScript"],
    unbreakable: true,
    glint: true,
  }),
});

// Clear the slot again.
await client.sendPacket("SetPlayerInventory", { slotId: 0, contents: helpers.emptySlot() });

contents is a Slot. helpers.createSlot and helpers.emptySlot return the plain object; the writer derives the component counts. For a filled map, use createMapSlot. See Items and slots for every option.

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

Source: src/Core/Versions/776/Packets/play/clientbound/SetPlayerInventory.ts

Was this page helpful?