mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-29 06:03:33 -04:00
Merge upstream, fix mistakes in examples
This commit is contained in:
commit
2f90252eaa
@ -25,9 +25,9 @@ Parse and serialize minecraft packets, plus authentication and encryption.
|
|||||||
|
|
||||||
## Projects Using node-minecraft-protocol
|
## 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.
|
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
|
minecraft server, provides real-time web interface, allow your users to
|
||||||
create bots.
|
create bots.
|
||||||
|
|
||||||
@ -320,7 +320,7 @@ NODE_DEBUG="minecraft-protocol" node [...]
|
|||||||
### 0.11.0
|
### 0.11.0
|
||||||
|
|
||||||
* support minecraft protocol 1.6.1 / protocol version 73 (thanks [Matt Bell](https://github.com/mappum))
|
* 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
|
### 0.10.1
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ client.on('connect', function() {
|
|||||||
client.on('state', function(newState) {
|
client.on('state', function(newState) {
|
||||||
if (newState === states.PLAY) {
|
if (newState === states.PLAY) {
|
||||||
chats.forEach(function(chat) {
|
chats.forEach(function(chat) {
|
||||||
client.write('chat_message', {message: chat});
|
client.write('chat', {message: chat});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -21,7 +21,7 @@ server.on('login', function(client) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// send init data so client will start rendering world
|
// send init data so client will start rendering world
|
||||||
client.write('join_game', {
|
client.write('login', {
|
||||||
entityId: client.id,
|
entityId: client.id,
|
||||||
levelType: 'default',
|
levelType: 'default',
|
||||||
gameMode: 1,
|
gameMode: 1,
|
||||||
@ -29,7 +29,7 @@ server.on('login', function(client) {
|
|||||||
difficulty: 2,
|
difficulty: 2,
|
||||||
maxPlayers: server.maxPlayers
|
maxPlayers: server.maxPlayers
|
||||||
});
|
});
|
||||||
client.write('player_position', {
|
client.write('position', {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 256,
|
y: 256,
|
||||||
z: 0,
|
z: 0,
|
||||||
|
@ -475,7 +475,7 @@ var packets = {
|
|||||||
]},
|
]},
|
||||||
use_entity: {id: 0x02, fields: [
|
use_entity: {id: 0x02, fields: [
|
||||||
{ name: "target", type: "int" },
|
{ name: "target", type: "int" },
|
||||||
{ name: "leftClick", type: "byte" }
|
{ name: "mouse", type: "byte" }
|
||||||
]},
|
]},
|
||||||
flying: {id: 0x03, fields: [
|
flying: {id: 0x03, fields: [
|
||||||
{ name: "onGround", type: "bool" }
|
{ name: "onGround", type: "bool" }
|
||||||
@ -1393,19 +1393,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) {
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git://github.com/superjoe30/node-minecraft-protocol.git"
|
"url": "git://github.com/andrewrk/node-minecraft-protocol.git"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "mocha --reporter spec"
|
"test": "mocha --reporter spec"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user