Classic server protocol

Documentation on the server protocol used by the Minecraft Classic Creative server.

Heartbeats
To be able to connect to a server in Minecraft Classic from the Server List, a server must broadcast to minecraft.net a so-called "heartbeat" every few minutes.

The stock server broadcasts this heartbeat every 45 seconds.

A "heartbeat" takes the form of an HTTP request to http://www.minecraft.net/heartbeat.jsp. After sending a heartbeat, the URL for the server is returned.

It can be a GET or POST request. A table of the required parameters is below: The simplest way to send a heartbeat is to open a TCP socket to port 80 on www.minecraft.net, and send the following (with the values changed, obviously):

GET /heartbeat.jsp?port=25565&max=32&name=My%20Server&public=True&version=7&salt=wo6kVAHjxoJcInKx&users=0, plus a CRLF(Carriage-return and Line feed).

Make sure any strings, like name, are escaped.

If everything goes well, in the response body you'll receive a URL to the server. Otherwise you'll get a nice HTML error message. There aren't an HTML headers to parse, as the HTTP version is not specified so HTTP/0.9 is used, which does not have headers.

User Authentication
The "key" provided when a user joins the server can be compared to the MD5 checksum of the server's "salt" plus the username to verify that the user is logged in to minecraft.net with that username. This is useful for establishing enough trust of the name provided to ban or op the player by name.

if( player.key == md5( server.salt + player.name ) ) { // player is logged in via minecraft.net } else { // player is forging the username }

Note: This means that you should make sure your "salt" is kept a secret and shared only with heartbeat.jsp. If your server's "salt" is visible anywhere to users, it is trivial for users to produce valid-looking "key"s without being logged in to minecraft.net.

Skins
Skins for a player are downloaded by the client from http://minecraft.net/skin/skinname.png, where skinname is the name of the player. This means that the name for a player can be faked to give a desired skin.

Packet Protocol
Every packet starts with a byte representing the Packet ID.

Fixed Point
Player position is represented via X, Y, and Z fixed-point coordinates. The fractional portion is 5 bits, so dividing the short integers received in position update packets by 32, you will have floating point coordinates for the player. This position corresponds to the center of the client viewport.

Standing On Things
The bottom of the player's feet is located 1.59375 (fixed-point: 51) units below the center of the viewport, so to position the player on top of a particular block you could send a teleport (0x08) packet specifying a Y value based on the block position as: (Y x 32 + 51) Now of 1.6, Classic server protocols are removed.