node-minecraft-protocol/README.md

64 lines
1.8 KiB
Markdown
Raw Normal View History

2012-12-24 13:55:46 -05:00
# minecraft protocol
2013-01-01 21:02:07 -05:00
Parse and serialize minecraft packets, plus authentication and encryption.
2013-01-01 16:01:43 -05:00
## Features
2013-01-01 21:02:07 -05:00
* Parses all packets and emits `packet` events with packet fields as JavaScript
2013-01-01 16:01:43 -05:00
objects.
* Send a packet by supplying fields as a JavaScript object.
2013-01-01 21:02:07 -05:00
* Supports authenticating and logging in.
2013-01-02 02:22:00 -05:00
- Supports encryption
2013-01-01 21:02:07 -05:00
- Supports online mode
2013-01-02 02:22:00 -05:00
- Supports offline mode
* Respond to keep-alive packets.
* Test coverage
- encryption
- authentication/online mode
- offline mode
- initialization packets
2013-01-01 16:01:43 -05:00
* Optimized for rapidly staying up to date with Minecraft protocol updates.
## Minecraft Compatibility
2013-01-03 19:47:17 -05:00
Supports Minecraft version 1.4.7pre
2013-01-01 16:01:43 -05:00
## Usage
### Echo example
Listen for chat messages and echo them back.
```js
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
2013-01-02 06:35:10 -05:00
password: "12345678", // online-mode=true servers
});
client.on('packet-3', function(packet) {
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`.
2013-01-02 01:47:18 -05:00
* 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`
2013-01-02 01:47:18 -05:00
## 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.
2. Update the "Minecraft Compatibility" section above in this README.
3. Run the test suite to make sure everything still works. See "Testing" above.