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

Add Entity

Play 0x01, server → client.

play · 0x01 · clientbound (server → client)

Spawns a new entity (mob, item, projectile, player, and so on) on the client with its entityId, objectUUID, entity type, position, rotation, and initial velocity. The server sends it whenever an entity enters the player’s tracked range. The client creates the entity and expects later packets such as metadata and movement to reference the same entityId.

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

Fields

Field Type Notes
entityId VarInt
objectUUID UUID also entityUuid
type VarInt also subscriptionType
x Double
y Double
z Double
velocity LpVec3
pitch Byte
yaw Byte
headPitch Byte
objectData VarInt

Send it

const entityId = 100;
await client.sendPacket("AddEntity", {
  entityId,
  objectUUID: crypto.randomUUID().replaceAll("-", ""), // 32 hex chars, no dashes
  type: entityTypeId, // index of the entity type in the 26.2 minecraft:entity_type registry
  x: 0.5,
  y: 65,
  z: 0.5,
  velocity: [0, 0, 0],
  pitch: 0,
  yaw: 0, // angle in 1/256 of a turn
  headPitch: 0,
  objectData: 0,
});

Spawns any entity, including players (the UUID must then match a PlayerInfoUpdate entry). type is the numeric entity type ID from the vanilla registries report; there is no name lookup helper yet. velocity is [x, y, z] in blocks per tick. objectData carries extra data for some types, for example the block state for falling blocks. Follow up with SetEntityData for metadata and RemoveEntities to despawn.

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

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

Was this page helpful?