Pre-release protocol

From wiki.vg
Jump to navigation Jump to search

This page documents the changes from the last stable Minecraft release (currently 1.3.2) to the current pre-release (or weekly release).

New packets

-None-

Changed packets

Time Update (0x04)

Server to Client

Time is based on ticks, where 20 ticks happen every second. There are 24000 ticks in a day, making Minecraft days exactly 20 minutes long.

The time of day is based on the timestamp modulo 24000. 0 is sunrise, 6000 is noon, 12000 is sunset, and 18000 is midnight.

The default SMP server increments both by 20 every second.

The 'Time' is the Age of the world. It is not changing on server commands and will increased by 20 every second.

Packet ID Field Name Field Type Example Notes
0x04 Time long 45464654 The 'Age of the world', in ticks
Day Time long 21321 The world (or region) time, in ticks
Total Size: 17 Bytes

Spawn Named Entity (0x14)

See the change in metadata below. (Under Protocol History, 2012-08-24)

Spawn Dropped Item (0x15)

TODO

It includes a new byte array after the "Damage" field, and before the "X" field if certain conditions are met. If the array does not exist, then the length of the array is "-1".

Spawn Mob (0x18)

See the change in metadata below. (Under Protocol History, 2012-08-24)

Entity Metadata (0x28)

See the change in metadata below. (Under Protocol History, 2012-08-24)

Changed data types

Entity Metadata Format

Note that entity metadata is a totally distinct concept from block metadata.

The entity metadata format is quirky dictionary format, where the key and the value's type are packed in a single byte.

To parse, repeat the following procedure:

  1. Read an unsigned byte
  2. If this byte == 127, stop reading
  3. Decompose the byte.
    The bottom 5 bits (0x1F) serve as an identifier (key) for the data to follow.
    The top 3 bits (0xE0) serve as a type.
  4. Read and unpack based on the type (below)
Type Meaning
0 byte
1 short
2 int
3 float
4 string16
5 short, byte, short (slot type) - If first short is empty, no further data is sent.
6 int, int, int (x, y, z)

In Python-like code:

#socket is positioned at the beginning of the metadata array. Also note that the method unpack() doesn't exist in socket
metadata = {}
x = socket.unpack('byte')
while x != 127:
    index = x & 0x1F # Lower 5 bits
    ty    = x >> 5   # Upper 3 bits
    if ty == 0: val = socket.unpack('byte') 
    if ty == 1: val = socket.unpack('short') 
    if ty == 2: val = socket.unpack('int') 
    if ty == 3: val = socket.unpack('float') 
    if ty == 4: val = socket.unpack('string16')
    if ty == 5:
        val = {}
        val["id"] = socket.unpack('short')
        if val["id"] != -1:
            val["count"]  = socket.unpack('byte')
            val["damage"] = socket.unpack('short')
    if ty == 6:
        val = []
        for i in range(3):
            val.append(socket.unpack('int'))
    metadata[index] = (ty, val)
    x = socket.unpack('byte')
return metadata

Removed packets

-None-

Protocol History

2012-10-04

  • 12w40a
  • Protocol version is now 45
  • Packet 0x66 changed

2012-09-06

  • 12w36a
  • Protocol version is now 42

2012-08-24

  • 12w34b
  • Protocol version is now 41
  • Changed Entity Metadata Format

2012-08-09

  • 12w32a
  • Protocol version is now 40
  • Changed Time Update packet