Release 0.12.0

This commit is contained in:
roblabla 2014-04-11 19:40:15 +02:00
parent 05d1b8e1ed
commit 23ecbd3675
2 changed files with 181 additions and 120 deletions

299
README.md
View File

@ -4,7 +4,7 @@ Parse and serialize minecraft packets, plus authentication and encryption.
## Features ## Features
* Supports Minecraft version 1.6.4 * Supports Minecraft version 1.7.2
* 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.
@ -43,7 +43,7 @@ var client = mc.createClient({
username: "email@example.com", username: "email@example.com",
password: "12345678", password: "12345678",
}); });
client.on(0x03, function(packet) { client.on('chat', function(packet) {
// Listen for chat messages and echo them back. // Listen for chat messages and echo them back.
var jsonMsg = JSON.parse(packet.message); var jsonMsg = JSON.parse(packet.message);
if (jsonMsg.translate == 'chat.type.announcement' || jsonMsg.translate == 'chat.type.text') { if (jsonMsg.translate == 'chat.type.announcement' || jsonMsg.translate == 'chat.type.text') {
@ -70,7 +70,7 @@ var server = mc.createServer({
port: 25565, // optional port: 25565, // optional
}); });
server.on('login', function(client) { server.on('login', function(client) {
client.write(0x01, { client.write('login', {
entityId: client.id, entityId: client.id,
levelType: 'default', levelType: 'default',
gameMode: 0, gameMode: 0,
@ -78,16 +78,15 @@ server.on('login', function(client) {
difficulty: 2, difficulty: 2,
maxPlayers: server.maxPlayers maxPlayers: server.maxPlayers
}); });
client.write(0x0d, { client.write('position', {
x: 0, x: 0,
y: 1.62, y: 1.62,
stance: 0,
z: 0, z: 0,
yaw: 0, yaw: 0,
pitch: 0, pitch: 0,
onGround: true onGround: true
}); });
var msg = { translate: 'chat.type.announcement', using [ var msg = { translate: 'chat.type.announcement', using: [
'Server', 'Server',
'Hello, ' + client.username 'Hello, ' + client.username
]}; ]};
@ -134,10 +133,66 @@ be exempt from online mode or offline mode (whatever mode the server is in).
Make sure the entries in this object are all lower case. Make sure the entries in this object are all lower case.
#### server.clients
Javascript object mapping a `Client` from a clientId.
### server.playerCount
The amount of players currently present on the server.
#### server.maxPlayers #### server.maxPlayers
The maximum amount of players allowed on the server.
#### server.motd
The motd that is sent to the player when he is pinging the server
#### server.favicon
A base64 data string representing the favicon that will appear next to the server
on the mojang client's multiplayer list.
### mc.createClient(option)
Returns a `Client` instance and perform login
### Client
#### client.state
The internal state that is used to figure out which protocol state we are in during
packet parsing. This is one of the protocol.states.
#### client.isServer
True if this is a connection going from the server to the client,
False if it is a connection from client to server.
#### client.socket
Returns the internal nodejs Socket used to communicate with this client.
#### client.uuid
A string representation of the client's UUID. Note that UUIDs are unique for
each players, while playerNames, as of 1.7.7, are not unique and can change.
### client.username
The user's username.
### client.session
The user's session, as returned by the Yggdrasil system.
### Not Immediately Obvious Data Type Formats ### Not Immediately Obvious Data Type Formats
Note : almost all data formats can be understood by looking at the packet
structure in lib/protocol.js
#### entityMetadata #### entityMetadata
Value looks like this: Value looks like this:
@ -153,26 +208,6 @@ Value looks like this:
Where the key is the numeric metadata key and the value is the value of the Where the key is the numeric metadata key and the value is the value of the
correct data type. correct data type.
#### propertyArray
Included inside *Entity Properties (0x2C)* packets.
```js
[
{ key: 'generic.maxHealth', value: 20, elementList: [] },
{ key: 'generic.movementSpeed', value: 0.25, elementList: [] }
]
```
Where elementList is an array with the following structure:
```js
[
{ uuid: [ 123, 456, 78, 90 ], amount: 0.5, operation: 1 },
...
]
```
## Testing ## Testing
* Ensure your system has the `java` executable in `PATH`. * Ensure your system has the `java` executable in `PATH`.
@ -183,104 +218,124 @@ Where elementList is an array with the following structure:
``` ```
packets packets
✓ 0x00 √ handshaking,ServerBound,0x00
✓ 0x01 √ status,ServerBound,0x00
✓ 0x02 √ status,ServerBound,0x01
✓ 0x03 √ status,ClientBound,0x00
✓ 0x04 √ status,ClientBound,0x01
✓ 0x05 √ login,ServerBound,0x00
✓ 0x06 √ login,ServerBound,0x01
✓ 0x07 √ login,ClientBound,0x00
✓ 0x08 √ login,ClientBound,0x01
✓ 0x09 √ login,ClientBound,0x02
✓ 0x0a √ play,ServerBound,0x00
✓ 0x0b √ play,ServerBound,0x01
✓ 0x0c √ play,ServerBound,0x02
✓ 0x0d √ play,ServerBound,0x03
✓ 0x0e √ play,ServerBound,0x04
✓ 0x0f √ play,ServerBound,0x05
✓ 0x10 √ play,ServerBound,0x06
✓ 0x11 √ play,ServerBound,0x07
✓ 0x12 √ play,ServerBound,0x08
✓ 0x13 √ play,ServerBound,0x09
✓ 0x14 √ play,ServerBound,0x0a
✓ 0x16 √ play,ServerBound,0x0b
✓ 0x17 √ play,ServerBound,0x0c
✓ 0x18 √ play,ServerBound,0x0d
✓ 0x19 √ play,ServerBound,0x0e
✓ 0x1a √ play,ServerBound,0x0f
✓ 0x1c √ play,ServerBound,0x10
✓ 0x1d √ play,ServerBound,0x11
✓ 0x1e √ play,ServerBound,0x12
✓ 0x1f √ play,ServerBound,0x13
✓ 0x20 √ play,ServerBound,0x14
✓ 0x21 √ play,ServerBound,0x15
✓ 0x22 √ play,ServerBound,0x16
✓ 0x23 √ play,ServerBound,0x17
✓ 0x26 √ play,ClientBound,0x00
✓ 0x27 √ play,ClientBound,0x01
✓ 0x28 √ play,ClientBound,0x02
✓ 0x29 √ play,ClientBound,0x03
✓ 0x2a √ play,ClientBound,0x04
✓ 0x2b √ play,ClientBound,0x05
✓ 0x33 √ play,ClientBound,0x06
✓ 0x34 √ play,ClientBound,0x07
✓ 0x35 √ play,ClientBound,0x08
✓ 0x36 √ play,ClientBound,0x09
✓ 0x37 √ play,ClientBound,0x0a
✓ 0x38 √ play,ClientBound,0x0b
✓ 0x3c √ play,ClientBound,0x0c
✓ 0x3d √ play,ClientBound,0x0d
✓ 0x3e √ play,ClientBound,0x0e
✓ 0x3f √ play,ClientBound,0x0f
✓ 0x46 √ play,ClientBound,0x10
✓ 0x47 √ play,ClientBound,0x11
✓ 0x64 √ play,ClientBound,0x12
✓ 0x65 √ play,ClientBound,0x13
✓ 0x66 √ play,ClientBound,0x14
✓ 0x67 √ play,ClientBound,0x15
✓ 0x68 √ play,ClientBound,0x16
✓ 0x69 √ play,ClientBound,0x17
✓ 0x6a √ play,ClientBound,0x18
✓ 0x6b √ play,ClientBound,0x19
✓ 0x6c √ play,ClientBound,0x1a
✓ 0x82 √ play,ClientBound,0x1b
✓ 0x83 √ play,ClientBound,0x1c
✓ 0x84 √ play,ClientBound,0x1d
✓ 0xc8 √ play,ClientBound,0x1e
✓ 0xc9 √ play,ClientBound,0x1f
✓ 0xca √ play,ClientBound,0x20
✓ 0xcb √ play,ClientBound,0x21
✓ 0xcc √ play,ClientBound,0x22
✓ 0xcd √ play,ClientBound,0x23
✓ 0xce √ play,ClientBound,0x24
✓ 0xcf √ play,ClientBound,0x25
✓ 0xd0 √ play,ClientBound,0x26
✓ 0xd1 √ play,ClientBound,0x27
✓ 0xfa √ play,ClientBound,0x28
✓ 0xfc √ play,ClientBound,0x29
✓ 0xfd √ play,ClientBound,0x2a
✓ 0xfe √ play,ClientBound,0x2b
✓ 0xff √ play,ClientBound,0x2c
√ play,ClientBound,0x2d
√ play,ClientBound,0x2e
√ play,ClientBound,0x2f
√ play,ClientBound,0x30
√ play,ClientBound,0x31
√ play,ClientBound,0x32
√ play,ClientBound,0x33
√ play,ClientBound,0x34
√ play,ClientBound,0x35
√ play,ClientBound,0x36
√ play,ClientBound,0x37
√ play,ClientBound,0x38
√ play,ClientBound,0x39
√ play,ClientBound,0x3a
√ play,ClientBound,0x3b
√ play,ClientBound,0x3c
√ play,ClientBound,0x3d
√ play,ClientBound,0x3e
√ play,ClientBound,0x3f
√ play,ClientBound,0x40
client client
✓ pings the server (6653ms) √ pings the server (32734ms)
✓ connects successfully - online mode (4041ms) √ connects successfully - online mode (23367ms)
✓ connects successfully - offline mode (2663ms) √ connects successfully - offline mode (10261ms)
✓ gets kicked when no credentials supplied in online mode (4678ms) √ gets kicked when no credentials supplied in online mode (18400ms)
✓ does not crash for 10000ms (12492ms) √ does not crash for 10000ms (24780ms)
...............
mc-server mc-server
✓ starts listening and shuts down cleanly (44ms) √ starts listening and shuts down cleanly (73ms)
✓ kicks clients that do not log in (149ms) √ kicks clients that do not log in (295ms)
✓ kicks clients that do not send keepalive packets (153ms) √ kicks clients that do not send keepalive packets (266ms)
✓ responds to ping requests √ responds to ping requests (168ms)
✓ clients can log in and chat (71ms) √ clients can log in and chat (158ms)
✓ kicks clients when invalid credentials (263ms) √ kicks clients when invalid credentials (680ms)
✓ gives correct reason for kicking clients when shutting down (40ms) √ gives correct reason for kicking clients when shutting down (123ms)
91 tests complete (50 seconds) 111 tests complete (3 minutes)
``` ```
# Debugging # Debugging
@ -292,6 +347,12 @@ NODE_DEBUG="minecraft-protocol" node [...]
``` ```
## History ## History
### 0.12.0
* Updated protocol version to support 1.7.2
* Overhaul the serializer backend to be more general-purpose and future-proof.
* Support listening packets by name (thanks [deathcap](https://github.com/deathcap))
* Support reading/writing a raw buffer to the socket.
### 0.11.6 ### 0.11.6

View File

@ -1,6 +1,6 @@
{ {
"name": "minecraft-protocol", "name": "minecraft-protocol",
"version": "0.11.6", "version": "0.12.0",
"description": "Parse and serialize minecraft packets, plus authentication and encryption.", "description": "Parse and serialize minecraft packets, plus authentication and encryption.",
"main": "index.js", "main": "index.js",
"repository": { "repository": {