README: version 1.6.1 support, examples updated

This commit is contained in:
Xabier de Zuazo 2013-07-09 08:13:17 +02:00
parent 8e02b4f0b0
commit c7c4365f38

View File

@ -4,7 +4,7 @@ Parse and serialize minecraft packets, plus authentication and encryption.
## Features ## Features
* Supports Minecraft version 1.5 * Supports Minecraft version 1.6.1
* Parses all packets and emits events with packet fields as JavaScript * Parses all packets and emits events with packet fields as JavaScript
objects. objects.
* Send a packet by supplying fields as a JavaScript object. * Send a packet by supplying fields as a JavaScript object.
@ -45,10 +45,15 @@ var client = mc.createClient({
}); });
client.on(0x03, function(packet) { client.on(0x03, function(packet) {
// Listen for chat messages and echo them back. // Listen for chat messages and echo them back.
if (packet.message.indexOf(client.session.username) !== -1) return; var jsonMsg = JSON.parse(packet.message);
client.write(0x03, { if (jsonMsg.translate == 'chat.type.announcement' || jsonMsg.translate == 'chat.type.text') {
message: packet.message, var username = jsonMsg.using[0];
}); var msg = jsonMsg.using[1];
if (username === client.username) return;
client.write(0x03, {
message: msg
});
}
}); });
``` ```
@ -82,7 +87,11 @@ server.on('login', function(client) {
pitch: 0, pitch: 0,
onGround: true onGround: true
}); });
client.write(0x03, { message: 'Hello, ' + client.username }); var msg = { translate: 'chat.type.announcement', using [
'Server',
'Hello, ' + client.username
];
client.write(0x03, { message: JSON.stringify(msg) });
}); });
``` ```