From 4e48226c8c76025546d1a54b08554ce550ead21b Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 23 Jan 2014 21:36:25 -0500 Subject: [PATCH 1/2] rename github.com/superjoe30 to github.com/andrewrk --- README.md | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4f91bf2..4211b32 100644 --- a/README.md +++ b/README.md @@ -25,9 +25,9 @@ Parse and serialize minecraft packets, plus authentication and encryption. ## Projects Using node-minecraft-protocol - * [mineflayer](https://github.com/superjoe30/mineflayer/) - create minecraft + * [mineflayer](https://github.com/andrewrk/mineflayer/) - create minecraft bots with a stable, high level API. - * [mcserve](https://github.com/superjoe30/mcserve) - runs and monitors your + * [mcserve](https://github.com/andrewrk/mcserve) - runs and monitors your minecraft server, provides real-time web interface, allow your users to create bots. @@ -320,7 +320,7 @@ NODE_DEBUG="minecraft-protocol" node [...] ### 0.11.0 * support minecraft protocol 1.6.1 / protocol version 73 (thanks [Matt Bell](https://github.com/mappum)) - * *note:* chat packets have a new format (see [the examples](https://github.com/superjoe30/node-minecraft-protocol/tree/master/examples) for how to upgrade). + * *note:* chat packets have a new format (see [the examples](https://github.com/andrewrk/node-minecraft-protocol/tree/master/examples) for how to upgrade). ### 0.10.1 diff --git a/package.json b/package.json index 6ca81a0..2fb5443 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "index.js", "repository": { "type": "git", - "url": "git://github.com/superjoe30/node-minecraft-protocol.git" + "url": "git://github.com/andrewrk/node-minecraft-protocol.git" }, "scripts": { "test": "mocha --reporter spec" From aa0402979eca7ca6cdd6bedd2cef9400b55a235d Mon Sep 17 00:00:00 2001 From: DannyAAM Date: Sat, 22 Feb 2014 18:38:39 +0800 Subject: [PATCH 2/2] modify some packet variable name fix chat problem with multi-byte characters --- lib/protocol.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) mode change 100644 => 100755 lib/protocol.js diff --git a/lib/protocol.js b/lib/protocol.js old mode 100644 new mode 100755 index 357aaa6..4dd0d14 --- a/lib/protocol.js +++ b/lib/protocol.js @@ -470,7 +470,7 @@ var packets = { ], 0x02: [ { name: "target", type: "int" }, - { name: "leftClick", type: "byte" } + { name: "mouse", type: "byte" } ], 0x03: [ { name: "onGround", type: "bool" } @@ -1352,19 +1352,22 @@ function writeSlot(value, buffer, offset) { } function sizeOfString(value) { - assert.ok(value.length < STRING_MAX_LENGTH, "string greater than max length"); - return sizeOfVarInt(value.length) + value.length; + var length = Buffer.byteLength(value, 'utf8'); + assert.ok(length < STRING_MAX_LENGTH, "string greater than max length"); + return sizeOfVarInt(length) + length; } function sizeOfUString(value) { - assert.ok(value.length < SRV_STRING_MAX_LENGTH, "string greater than max length"); - return sizeOfVarInt(value.length) + value.length; + var length = Buffer.byteLength(value, 'utf8'); + assert.ok(length < SRV_STRING_MAX_LENGTH, "string greater than max length"); + return sizeOfVarInt(length) + length; } function writeString(value, buffer, offset) { - offset = writeVarInt(value.length, buffer, offset); - buffer.write(value, offset, value.length, 'utf8'); - return offset + value.length; + var length = Buffer.byteLength(value, 'utf8'); + offset = writeVarInt(length, buffer, offset); + buffer.write(value, offset, length, 'utf8'); + return offset + length; } function sizeOfAscii(value) {