How to Write a Client

From wiki.vg
Revision as of 10:08, 4 February 2011 by Thejoshwolfe (talk | contribs) (Added sections with TODO's)
Jump to navigation Jump to search

This tutorial is being created to document what it takes to write a stand-alone client. The tutorial is incomplete but will be updated whenever more information is discovered.

Before You Get Started

  • Make sure you don't want to join or fork an existing project instead.
  • Ponder how much work it will be.
  • Download the latest official minecraft server and run it with authentication turned off. Bind it to localhost if you want.

Parsing the messages

Main article: Protocol

Sorry, but you have to be able to parse all the messages. Write all the message parsing code. If you don't, your client will effectively crash if the server sends you any message you can't parse.

Login

Connect to the server at localhost, port 25565.

Main article: Protocol FAQ

Paraphrase (with no authentication): send a 0x02, get a 0x02, send a 0x01, get a 0x01. Then you get a 0x0D, and that's when the game really begins.

To test if this worked, connect to your localhost server with the notchian client and see if you can see your custom client appear and float in the air.

Getting the map chunks

You have to convince the server that you deserve to know about all the map chunks that are around you.

  • Every 200 milliseconds, send one of 0x0A - 0x0D.

To test if this worked, count the number of 0x33 map chunks you get that are full-sized chunks (16,128,16). You should get hundreds.

If you're not doing it right, you might only see bits and pieces of the map loading really far away, or possibly just one chunk load where you're standing.

Moving around

TODO: can you just fly around? is there a max speed? can you teleport?

Digging

TODO: is digging speed limited on the server side?

Placing/using stuff

TODO: can you place blocks from behind walls?

Crafting

TODO

Attacking mobs/players

TODO

Chat

TODO