mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-27 13:14:41 -04:00
README: version 1.6.1 support, examples updated
This commit is contained in:
parent
8e02b4f0b0
commit
c7c4365f38
21
README.md
21
README.md
@ -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) });
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user