Commit graph

140 commits

Author SHA1 Message Date
Florian Wesch
170566d700 New way to handle conditional fields in packets
Some packets have conditional fields. The previous way to handle
those was to provide a single condition for each packet type
which determined if additional fields are appended to the packet.
Unfortunately this is not enough for some packets: They have
complex conditions that cannot be expressed this way.

This diff changes the way conditional fields are handled: For
each field in each packet there is a new optional 'condition'
function which will be called with the packet data. Only if
the 'condition' function returns true, the field is de/encoded.

This diff also adds new (previously missing) conditions.
2013-08-26 13:00:28 +02:00
roblabla
6a530522a6 Add an unlimited string length for server chat packet 2013-08-07 19:05:59 +02:00
Xabier de Zuazo
c0a66738a3 packet 0x2c: writing fixed, UUID format simplified 2013-07-12 13:19:34 +02:00
Xabier de Zuazo
c597436b70 packet 0x2c: properties updated to support 1.6.2 version (elementList added) 2013-07-11 12:08:46 +02:00
Xabier de Zuazo
6b09737dec Added packet 0x85 (Tile Editor Open) 2013-07-11 08:15:53 +02:00
Xabier de Zuazo
ae2046d991 packet 0xfe (ping): some fields renamed, put the correct protocol version in mc.ping() 2013-07-11 08:15:53 +02:00
Matt Bell
f3657f74e0 Bumped protocol version for 1.6.2 2013-07-10 21:33:17 -07:00
Xabier de Zuazo
767f64153b improved 0x64 packet support, code refactorized using an optional_fields hash 2013-07-08 10:07:07 +02:00
Xabier de Zuazo
c9a081fd6a client ping fixed 2013-07-07 20:25:59 +02:00
Xabier de Zuazo
e46fd6f1c7 packet 0x27: leash from int to ubyte 2013-07-07 19:15:39 +02:00
Xabier de Zuazo
058d6eb12e packet 0x64 (OpenWindow): support for the optional entityId field 2013-07-07 12:29:18 +02:00
Xabier de Zuazo
1ac3e12099 packet 0xfe (ping): updated to support 1.6.1 2013-07-07 11:04:15 +02:00
Xabier de Zuazo
9c3f671a22 packet 0x13: added jumpBoost field 2013-07-07 10:24:49 +02:00
Xabier de Zuazo
dcbaf3836e packet 0x27: leash from bool to int 2013-07-07 09:13:53 +02:00
Matt Bell
e46a98a5a5 Updated to protocol version 73 (1.6.1) 2013-07-07 09:05:05 +02:00
Xabier de Zuazo
2665649363 protocol version updated to support minecraft 1.5.2 2013-05-05 04:08:12 +02:00
Xabier de Zuazo
664c7e380a print sent and received packet contents in debug mode 2013-04-15 06:40:09 +02:00
Xabier de Zuazo
a48d6dcdd8 Merge pull request #55 from stith/patch-1
Connect to a server's SRV record if they specify one
2013-04-14 21:21:51 -07:00
Matt Stith
88255413ce Only look for SRV records if necessary
Vanilla client implementation only looks for SRV records when the server port isn't specified, so let's mirror that behavior.
2013-04-15 00:09:04 -03:00
Xabier de Zuazo
120da4a20f packet 0x66 (Click Window): shift field renamed to mode 2013-04-14 11:27:53 +02:00
Matt Stith
d0664f37b4 Connect to a server's SRV record if they specify one 2013-04-13 17:23:31 -03:00
Xabier de Zuazo
8760ff55bc in packet 0x66, "shift" must be of type byte instead of boolean 2013-04-13 16:41:53 +02:00
Robin Lambertz
6c945b6265 Fix packet 0xce, "create" should be a byte.
Renamed "create" to "action", and made it a byte. 
According to wiki.vg, 0 is create, 1 to remove, and 2 to update.
2013-04-08 15:35:35 +02:00
Xabier de Zuazo
34e06bdd48 added entity metadata debugging message 2013-04-06 21:48:39 +02:00
Xabier de Zuazo
086d47b725 errors printing in readEntityMetadata() improved 2013-04-06 19:48:22 +02:00
Xabier de Zuazo
353f156d1a fix buffer length checking bug in readSlot() 2013-04-06 19:34:10 +02:00
Xabier de Zuazo
e176938682 Protocol version updated to 1.5.1 2013-04-06 05:41:40 +02:00
Xabier de Zuazo
936ba5832d added debug output for read/written packet ids 2013-04-06 05:04:47 +02:00
Xabier de Zuazo
b699d5506a added debug() method for NODE_DEBUG=mc-proto 2013-04-06 05:02:36 +02:00
Xabier de Zuazo
0ff49078ff friendlyFire on 0xd1 package id changed from bool to byte type 2013-04-06 04:48:05 +02:00
Xabier de Zuazo
38f46998e3 Unrecognized packetId error printing id in hex 2013-04-06 04:45:32 +02:00
Matt Bell
2c00c9f8be Fixed bug where the wrong type was used when serializing entityMetadata 2013-03-18 14:13:03 -07:00
Matt Bell
367b8a96da Switched from constructors to functions in serialization code 2013-03-18 13:02:57 -07:00
Andrew Kelley
09a80dddd2 all tests passing with newest protocol 2013-03-13 23:27:15 -04:00
Matt Bell
4a366d75b5 Added stringArray datatype 2013-03-13 17:57:18 -07:00
Matt Bell
5f6abad700 Updated to protocol 60 (1.5.0) 2013-03-13 17:06:28 -07:00
Andrew Kelley
8e6d11b09e minor refactor 2013-02-10 21:05:42 -05:00
Andrew Kelley
adc47b0f62 fix incorrect playerCount in ping. closes #41 2013-02-10 17:51:47 -05:00
Andrew Kelley
93068b935d don't ever remove the 'error' handler from the socket.
fixes crashing with an unhandled error
2013-02-03 22:13:15 -05:00
Andrew Kelley
1a434b9743 client emits more predictable 'end' event 2013-02-03 15:36:55 -05:00
Andrew Kelley
bb76dc8b0a Revert "Removed socket delays to reduce latency"
This reverts commit 6442e8d6b0.

Reverting until we can figure out why this is causing test failures.
2013-02-03 15:36:17 -05:00
Andrew Kelley
b335f201a8 fix objectData writer 2013-02-03 14:32:14 -05:00
Matt Bell
6442e8d6b0 Removed socket delays to reduce latency 2013-02-01 17:33:03 -08:00
Robin Lambertz
fdc01db825 Pass the original error around, and emit an error event on the client 2013-01-29 17:39:33 +00:00
Robin Lambertz
d6b3a91751 client.end should have a string argument, not an Error object. 2013-01-29 11:05:10 +00:00
Robin Lambertz
997071ef41 Changed if(typeof var === undefined) to if(var). Made errors error objects. 2013-01-29 08:53:23 +00:00
Robin Lambertz
529355782e Added errors in case of wrong MetaData or wrong Chunk Data 2013-01-29 01:05:33 +00:00
Robin Lambertz
5b67cec4e0 ups. Fixed a syntax error. 2013-01-29 00:48:01 +00:00
Robin Lambertz
eaa895120a Original skeleton changes. 2013-01-29 00:44:00 +00:00
Andrew Kelley
79e61a4890 fix ping module to pass tests 2013-01-28 22:46:30 +00:00
Robin Lambertz
b5516a81b3 Fixes #20 for real this time... 2013-01-28 22:46:29 +00:00
Jan Buschtöns
e8e78e2942 Add latency measurement to lib/ping.js 2013-01-28 22:46:29 +00:00
Andrew Kelley
804397928c y values when only 1 byte are always unsigned 2013-01-22 09:01:29 -05:00
Andrew Kelley
75c52bdf00 0x0e: face is an unsigned byte 2013-01-19 17:45:42 -05:00
Andrew Kelley
dbb0a4ccbe add additional assertion 2013-01-12 05:17:17 -05:00
Andrew Kelley
5a85aa454f fix incorrectly swapped stance and y on 0x0d
add test that would have caught the bug
2013-01-10 20:34:56 -05:00
Andrew Kelley
0aa52864df simplify and fix entityMetadata parsing and serializing 2013-01-08 02:44:17 -05:00
Andrew Kelley
c03ac963d9 all writers finished and tested. closes #15 2013-01-08 01:53:30 -05:00
Andrew Kelley
817fb9b51e add writers for most data types 2013-01-08 00:50:43 -05:00
Andrew Kelley
10cb3e0100 test all packets 2013-01-07 23:36:14 -05:00
Andrew Kelley
5df31e4d88 refactor data types 2013-01-07 22:20:40 -05:00
Andrew Kelley
8a6d4bc725 add ushort writer 2013-01-07 22:14:14 -05:00
Andrew Kelley
a50bf7926b 0x38: remove chunkColumnCount. Use meta.length 2013-01-05 23:02:47 -05:00
Andrew Kelley
08f71f11dc add chunkCount to 0x38
changed some more things for more API consistency

 * 0x33: compressedData -> compressedChunkData
 * 0x38: meta.chunkX -> meta.x
 * 0x38: meta.chunkZ -> meta.z
 * 0x38: meta.primaryBitMap -> meta.bitMap
 * 0x38: add chunkCount
2013-01-05 16:51:42 -05:00
Andrew Kelley
5f769caebc minor API update
* move constants.STRING_MAX_LENGTH -> protocol.STRING_MAX_LENGTH
 * expose protocol.version
 * expose protocol.minecraftVersion
 * expose protocol.sessionVerson
 * expose protocol.parsePacket
 * expose protocol.createPacketBuffer
2013-01-05 05:17:27 -05:00
Andrew Kelley
2e75851fd6 test passing: clients can log in and chat 2013-01-04 22:47:54 -05:00
Andrew Kelley
5e0ae2713a Client also emits 'packet' events for every packet 2013-01-04 21:57:17 -05:00
Andrew Kelley
150c89cc6d passing test: pinging a real minecraft server 2013-01-04 21:42:31 -05:00
Andrew Kelley
38194ee9b4 add test, ping, and 2 API changes
* passing test: responds to ping requests
 * `mc.ping` - ping a server for info
 * `createServer`: `options.timeout` -> `options.checkTimeoutInterval`
 * `Client` emits `connect` event
2013-01-04 21:33:19 -05:00
Andrew Kelley
1661ef3b4b API updates
* test passing: kicks clients that do not log in
 * index exports `Client` and `Server`
 * `createServer`: `options.keepAliveInterval` -> `options.kickTimeout`
 * `Client` event `end` includes `reason` argument
   - `LoginTimeout`
   - `KeepAliveTimeout`
   - `ServerShutdown`
 * `createClient`: Set `options.keepAlive` to `false` to disable sending
   keep alive packets
 * `Client`: `options.isServer` defaults to `false`.
2013-01-04 20:55:53 -05:00
Andrew Kelley
c9ed8a2792 server API update
* add passing test for "starts listening"
 * server.socket -> server.socketServer
 * add client.id which can be used as entity id
 * add server.clients which is {clientId: client}
 * update server examples
 * server emits 'close' event, not 'end' event
 * add server.close()
2013-01-04 20:22:19 -05:00
Andrew Kelley
8096a08afd avoid dependency on iconv. makes it easier to use on windows. see #12 2013-01-04 19:04:06 -05:00
Andrew Kelley
3a8bfaf8e3 refactor + createServer support 2013-01-04 01:45:57 -05:00
Andrew Kelley
d38dad2d56 move packets to protocol, refactor 2013-01-03 23:14:19 -05:00
Andrew Kelley
c405ac21f8 refactor into nice npm module. closes #7 2013-01-01 23:39:31 -05:00
Andrew Kelley
1979ef3848 all clent to server packets have supported data type writers 2013-01-01 20:58:47 -05:00
Andrew Kelley
0d3d9d63a3 all packets parsed. closes #8 2013-01-01 20:29:03 -05:00
Andrew Kelley
7aeea8a320 more packets and parsers 2013-01-01 19:05:20 -05:00
Andrew Kelley
f1da7b152b more packets supported 2013-01-01 16:42:13 -05:00
Andrew Kelley
7b92a88872 more packets parsed 2013-01-01 15:27:24 -05:00
Andrew Kelley
e42f89a6ac fix slot parsing 2013-01-01 14:54:25 -05:00
Andrew Kelley
4523996067 more packets parsed 2013-01-01 07:01:14 -05:00
Andrew Kelley
3804c5cea6 refactor and fix map chunk bulk parsing 2013-01-01 06:12:48 -05:00
Andrew Kelley
c51cb26769 parser recognizes map chunk bulk 2013-01-01 05:48:18 -05:00
Andrew Kelley
d501a5a7eb recognize Set Window Items packet 2013-01-01 05:10:24 -05:00
Andrew Kelley
33bf57b6c2 more recognized packets and data types 2013-01-01 05:02:24 -05:00
Andrew Kelley
fd43515c42 successfully log in to minecraft server
next step is to add more supported packets
2013-01-01 04:14:38 -05:00
Andrew Kelley
3bc30a97b5 AES encryption/decryption working.
now getting kicked for not verifying username
2013-01-01 01:49:38 -05:00
Andrew Kelley
321a97acb4 successfully getting the encryption key response 2012-12-31 23:53:36 -05:00
Andrew Kelley
043cbd5882 getting encryption request 2012-12-31 20:33:35 -05:00