Minecraft Wiki
Advertisement
Quatroking butthurt much?
 Quatroking butthurt much?
Quatroking butthurt much?
Quatroking butthurt much?
Quatroking butthurt much?
Quatroking butthurt much?
Quatroking butthurt much?

Packet Protocol

Every packet starts with a byte representing the Packet ID.

Protocol Data Types

Type Size [bytes] Description
Byte 1 Single byte integer (0 to 255)
SByte 1 Single byte signed integer (-128 to 127)
Short 2 Signed integer, network order (-32768 to 32767)
String 64 US-ASCII/ISO646-US encoded string padded with spaces (0x20)
Byte array 1024 Binary data padded with null bytes (0x00)

Client → Server packets

Packet ID Purpose Field Description Field Type Notes
0x00 Player Identification Packet ID Byte Sent by a player joining a server with relevant information. Current protocol version is 0x07.
Protocol version Byte
Username String
Verification key String
Unused Byte
0x05 Set Block Packet ID Byte Sent when a user changes a block. The mode field indicates whether a block was created (0x01) or destroyed (0x00).

Block type is always the type player is holding, (even when deleting).

Client assumes that this command packet always succeeds, and so draws the new block immediately. To disallow block creation, server must send back Set Block packet with the old block type.

The XYZ coordinates of the block are just integers representing the coordinate of the block. (As opposed to player coordinates where the lower 5 bits are fractional coordinates)

X Short
Y Short
Z Short
Mode Byte
Block type Byte
0x08 Position and Orientation Packet ID Byte Sent frequently (even while not moving) by the player with the player's current location and orientation. Player ID is always 255, referring to itself. Player coordinates are fixed-point values with the lowest 5 bits representing the fractional position (i.e. divide by 32 to get actual position in terms of block coordinates). The angle parameters are scaled such that a value of 256 would correspond to 360 degrees.
Player ID Byte
X Short
Y Short
Z Short
Heading Byte
Pitch Byte
0x0d Message Packet ID Byte Contain chat messages sent by player.
Unused Byte (0xFF)
Message String

Server → Client packets

Packet ID Purpose Field Description Field Type Notes
0x00 Server Identification Packet ID Byte Response to a joining player. The user type indicates whether a player is an op (0x64) or not (0x00) Current protocol version is 0x07.
Protocol version Byte
Server name String
Server MOTD String
User type Byte
0x01 Ping Packet ID Byte Sent to clients periodically. The only way a client can disconnect at the moment is to force it closed, which does not let the server know. The ping packet is used to determine if the connection is still open.
0x02 Level Initialize Packet ID Byte Notifies player of incoming level data.
0x03 Level Data Chunk Packet ID Byte Contains a chunk of gzipped map (not level.dat file). After decompression the map consists of a int(4 bytes) containing number of blocks + raw map array. (chunk is up to 1024 bytes, padded with 0x00s if less).
Chunk Length Short
Chunk Data Byte Array
Percent Complete Byte
0x04 Level Finalize Packet ID Byte Sent after level data is complete and gives map dimensions. The y coordinate is how tall the map is.
X Size Short
Y Size Short
Z Size Short
0x06 Set Block Packet ID Byte Sent to indicate a block change by physics or by players. In the case of a player change, the server will also echo the block change back to the player who initiated it.
X Short
Y Short
Z Short
Block Type Byte
0x07 Spawn Player Packet ID Byte Sent to indicate where a new player is spawning in the world. Position and orientation are encoded the same as for packet 0x08 below.
Player ID Byte
Player Name String
X Short
Y Short
Z Short
Heading Byte
Pitch Byte
0x08 Player Teleport / Position and Position and Orientation Update Packet ID Byte Sent with changes in player position and rotation. Teleports player it's sent to if player ID = 0xFF (For sending initial position in map, and /tp)
Player ID Byte
X Short
Y Short
Z Short
Heading Byte
Pitch Byte
0x09 Position and Orientation Update Packet ID Byte Sent with changes in player position and rotation.

Not fully understood, or required for server operation.

Player ID Byte
X SByte
Y SByte
Z SByte
Heading Byte
Pitch Byte
0x0a Position Update Packet ID Byte Sent with changes in player position.

Not required for server operation.

Player ID Byte
Change in X SByte
Change in Y SByte
Change in Z SByte
0x0b Orientation Update Packet ID Byte Sent with changes in player rotation.

Not required for server operation.

Player ID Byte
Heading Byte
Pitch Byte
0x0c Despawn Player Packet ID Byte Sent when player disconnects.
Player ID Byte
0x0d Message Packet ID Byte Messages sent by chat or from the console.
Player ID Byte
Message String
0x0e Disconnect player Packet ID Byte Sent to a player when they're disconnected from the server.
  1. "Cheat detected: Distance" - happens not only when setting tile too far away from the player (how far is maximum distance and how it is measured?), but also when player moves and then immediately builds.
  2. "Cheat detected: Tile type"
Disconnect reason String
0x0f Update user type Packet ID Byte Sent when a player is opped/deopped
User type Byte

Color Codes

Messages sent from the server to the client can contain color codes, which allow coloring of text for various purposes. An ampersand followed by a hex digit in the message tells the client to switch colors while displaying text. Colour coding at the start of the message will only work if the player ID byte is less than 127. If it's 127 or higher, the game automatically adds &e before the message, making it yellow. However, colour codes after the first character still work. If you use an ID below 127, it doesn't add a colour code, so the ones you use will work.

Colors

Hex digit to color mapping

Sample Code Common Name Foreground Color Background Color
R G B R G B
&0 Black 0 0 0 0 0 0
&1 Dark Blue 0 0 191 0 0 47
&2 Dark Green 0 191 0 0 47 0
&3 Dark Teal 0 191 191 0 47 47
&4 Dark Red 191 0 0 47 0 0
&5 Purple 191 0 191 47 0 47
&6 Dark Yellow 191 191 0 47 47 0
&7 Gray 191 191 191 47 47 47
&8 Dark Gray 40 40 40 16 16 16
&9 Blue 64 64 255 16 16 63
&a Bright Green 64 255 64 16 63 16
&b Teal 64 255 255 16 63 63
&c Red 255 64 64 63 16 16
&d Pink 255 64 255 63 16 63
&e Yellow 255 255 64 63 63 16
&f White 255 255 255 63 63 63

Mobs

See also: Mobs

In multiplayer creative mode, all mobs are treated the same by the client. To create non-player mobs, simply send updates for them as you would a normal player. The client finds a mob's skin by its name, downloading from http://minecraft.net/skin/name.png and defaulting to the generic mob if it doesn't exist. To give your monsters a special skin, you would need to register and pay for an account with the monster's name.

You can also send fake names for actual players in order to force them to have a certain skin.

Resources

Programs

URL Program OS Notes
http://www.delorie.com/djgpp/ Djgpp, GCC for windows Windows
http://www.cygwin.com/ Cygwin the Linux-on-Windows (Unix Environment) Windows Good for Windows users.
http://www.microsoft.com/express/ Microsoft Visual Studio Express Windows Free version of Visual Studio, an IDE and compiler for C/++, C# and Visual Basic.
http://java.sun.com/javase/downloads/index.jsp Java Development Kit download Cross-platform Essential if you want to compile Java code
Advertisement