Entity Metadata

Entity metadata is a format introduced in Beta 1.2 for sending entity state over the network. This page will document the possible metadata values of mobs and how metadata is encoded in Beta 1.7.3. For the packet used to send the metadata, see Entity Metadata and Spawn Mob Entity.

  1. Format
  2. Data Types
  3. Entities
    1. Flags
  4. Relevant Classes
  5. Further Reading

Format

To read entity metadata, follow these steps in a loop until a value of 127/0x7F is read

  1. Get the data type via the top 3 bytes value >> 5
  2. Get the metadata ID via the bottom 5 bits, equal to value & 0x1F

Data Types

These data types function the same as they’re described on the data types page, except for a few special types.

ID Type Note
0 Byte A signed 8-Bit value
1 Short A signed 16-Bit value
2 Integer A signed 32-Bit value
3 Float A signed 32-Bit IEEE 754 floating-point number
4 String Uses the modified UCS-2 string format
5 Item Short (item/block ID), byte (quantity), short (metadata)
6 Coordinates Three integers for X, Y, and Z

Entities

These are the values that’re sent with each entity. To get a full listing of all entities and their relevant IDs, check the mob entities page.

Name Metadata
Any
ID Type Name
0 Byte Flags
Player
ID Type Name
16 Byte Unused
Pig
ID Type Name
16 Byte Saddled?
Creeper
ID Type Name
16 Byte Fuse1
17 Byte Charged?
Sheep
ID Type Name
16 Byte Sheared? / Color2
Slime
ID Type Name
16 Byte Size
Ghast
ID Type Name
16 Byte Attacking?
Wolf
ID Type Name
16 Byte Sitting?
17 String Owner
18 Integer Health

1 1 for blowing up, -1 otherwise

2 0x10 bit indicates shearedness, values 0x0-0xF indicate the color. All wool colors are listed on the blocks page.

Flags

All entities extending the Entity class must support this bit field at metadata ID 0. In later versions, this is also used for sprinting and eating/drinking. To get the flag at an ID, you can use value & mask != 0.

ID Bit Mask Name
0 0x01 Burning
1 0x02 Sneaking
2 0x04 Riding

Relevant Classes

Name (MCP) Name (Mojang) Notes
DataWatcher SynchedEntityData Watches metadata values for changes and sends packets.
WatchableObject SynchedEntityData.DataItem Represents a metadata value that can be changed.
Packet40EntityMetadata SetEntityDataPacket The packet that notifies the client of metadata changes in a mob.

Further Reading