Parse and serialize minecraft packets, plus authentication and encryption.
Find a file
2013-01-02 11:02:35 -05:00
examples all tests passing. closes #3 2013-01-02 03:30:33 -05:00
test all tests passing. closes #3 2013-01-02 03:30:33 -05:00
.gitignore getting encryption request 2012-12-31 20:33:35 -05:00
index.js emit packets in their own channel as well 2013-01-02 05:25:53 -05:00
package.json Release 0.0.2 2013-01-02 11:02:35 -05:00
packets.json all tests passing. closes #3 2013-01-02 03:30:33 -05:00
README.md update README 2013-01-02 06:35:10 -05:00

minecraft protocol

Parse and serialize minecraft packets, plus authentication and encryption.

Features

  • Parses all packets and emits packet events with packet fields as JavaScript objects.
  • Send a packet by supplying fields as a JavaScript object.
  • Supports authenticating and logging in.
    • Supports encryption
    • Supports online mode
    • Supports offline mode
  • Respond to keep-alive packets.
  • Test coverage
    • encryption
    • authentication/online mode
    • offline mode
    • initialization packets
  • Optimized for rapidly staying up to date with Minecraft protocol updates.

Minecraft Compatibility

Supports Minecraft version 1.4.6

Usage

Echo example

Listen for chat messages and echo them back.

var mc = require('minecraft-protocol');
var client = mc.createClient({
  host: "localhost", // optional
  port: 25565,       // optional
  username: "player",
  email: "email@example.com", // email and password are required only for
  password: "12345678",       // online-mode=true servers
});
client.on('packet', function(packet) {
  if (packet.id !== 0x03) return;
  if (packet.message.indexOf(client.session.username) !== -1) return;
  client.writePacket(0x03, {
    message: packet.message,
  });
});

Testing

  • Ensure your system has the java executable in PATH.
  • Download the appropriate version of minecraft_server.jar.
  • MC_SERVER_JAR=path/to/minecraft_server.jar MC_USERNAME=username MC_EMAIL=email@example.com MC_PASSWORD=password npm test

Updating to a newer protocol version

In most cases you should only have to do the following:

  1. In packets.json:
  • Update protocolVersion to the correct number.
  • Edit the data structure to reflect the new packet layout.
  1. Update the "Minecraft Compatibility" section above in this README.
  2. Run the test suite to make sure everything still works. See "Testing" above.