mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2025-05-18 09:10:26 -04:00
modify some packet variable name
fix chat problem with multi-byte characters
This commit is contained in:
parent
4e48226c8c
commit
aa0402979e
1 changed files with 11 additions and 8 deletions
19
lib/protocol.js
Normal file → Executable file
19
lib/protocol.js
Normal file → Executable file
|
@ -470,7 +470,7 @@ var packets = {
|
||||||
],
|
],
|
||||||
0x02: [
|
0x02: [
|
||||||
{ name: "target", type: "int" },
|
{ name: "target", type: "int" },
|
||||||
{ name: "leftClick", type: "byte" }
|
{ name: "mouse", type: "byte" }
|
||||||
],
|
],
|
||||||
0x03: [
|
0x03: [
|
||||||
{ name: "onGround", type: "bool" }
|
{ name: "onGround", type: "bool" }
|
||||||
|
@ -1352,19 +1352,22 @@ function writeSlot(value, buffer, offset) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function sizeOfString(value) {
|
function sizeOfString(value) {
|
||||||
assert.ok(value.length < STRING_MAX_LENGTH, "string greater than max length");
|
var length = Buffer.byteLength(value, 'utf8');
|
||||||
return sizeOfVarInt(value.length) + value.length;
|
assert.ok(length < STRING_MAX_LENGTH, "string greater than max length");
|
||||||
|
return sizeOfVarInt(length) + length;
|
||||||
}
|
}
|
||||||
|
|
||||||
function sizeOfUString(value) {
|
function sizeOfUString(value) {
|
||||||
assert.ok(value.length < SRV_STRING_MAX_LENGTH, "string greater than max length");
|
var length = Buffer.byteLength(value, 'utf8');
|
||||||
return sizeOfVarInt(value.length) + value.length;
|
assert.ok(length < SRV_STRING_MAX_LENGTH, "string greater than max length");
|
||||||
|
return sizeOfVarInt(length) + length;
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeString(value, buffer, offset) {
|
function writeString(value, buffer, offset) {
|
||||||
offset = writeVarInt(value.length, buffer, offset);
|
var length = Buffer.byteLength(value, 'utf8');
|
||||||
buffer.write(value, offset, value.length, 'utf8');
|
offset = writeVarInt(length, buffer, offset);
|
||||||
return offset + value.length;
|
buffer.write(value, offset, length, 'utf8');
|
||||||
|
return offset + length;
|
||||||
}
|
}
|
||||||
|
|
||||||
function sizeOfAscii(value) {
|
function sizeOfAscii(value) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue