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

Map Item Data

Play 0x33, server → client.

play · 0x33 · clientbound (server → client)

Updates a map item identified by itemDamage (the map id) with its scale, locked flag, icons such as player markers, and an optional rectangle of color data given by columns, rows, x, and y. The server sends it when a player holds a map or the map content changes. The client updates the map texture.

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

Fields

Field Type Notes
itemDamage VarInt Map ID; match the filled map item’s map_id component.
scale Byte Map scale, 0 to 4.
locked Boolean Whether the map is locked.
icons MapIcon[] or null Optional map markers; null omits the icon list.
columns UByte Image width; 0 omits the remaining image fields.
rows UByte Image height; present when columns is nonzero.
x UByte Left edge of the image region; present when columns is nonzero.
y UByte Top edge of the image region; present when columns is nonzero.
data Byte[] Length-prefixed palette indices, row by row; present when columns is nonzero.

Icon entries

When icons is an array, each entry has these fields:

Field Wire type Meaning
type VarInt Map decoration type ID; subscriptionType is accepted when writing.
x Byte Signed horizontal map coordinate.
z Byte Signed vertical map coordinate.
direction UByte Marker direction.
displayName Optional anonymous NBT Marker label; omit or use null when absent.

icons: null writes no icon list, while icons: [] writes an empty list. With columns: 0, omit rows, x, y, and data; this lets you update the icons without image pixels. With image data, data.length must equal columns * rows and each byte is a Minecraft map palette index. See Maps for RGB conversion and region bounds.

const mapId = 1;
await client.sendPacket("MapItemData", {
  itemDamage: mapId,
  scale: 0,
  locked: false,
  icons: [{ type: 0, x: 0, z: 0, direction: 0, displayName: null }],
  columns: 0,
});

Send it

import { helpers } from "mc-protocol";

const mapId = 1;
await client.sendPacket("SetPlayerInventory", {
  slotId: 0,
  contents: helpers.createMapSlot(mapId, { name: "Red map" }),
});
await client.sendPacket("MapItemData", helpers.createMapPacket(
  mapId,
  Array(128 * 128).fill("#ff0000"),
  { format: "rgb" },
));

The map ID must match the map_id component of the filled map slot. The helper converts RGB pixels to palette indices and fills the packet fields. For partial images, icon-only updates, and option details, see Maps.

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

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

Was this page helpful?