X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=doc%2Fprotocol;h=3347158e516ff7b567dbd101e65535d7213f3378;hb=d30497e8e16c8470ce2f9f0b245befd196ea4660;hp=723f3cfbd38586283fb24ca310f5858e60593bd4;hpb=104592aabdc70b21065c35fe4d092fc6cdaa1f49;p=blank.git diff --git a/doc/protocol b/doc/protocol index 723f3cf..3347158 100644 --- a/doc/protocol +++ b/doc/protocol @@ -1,3 +1,32 @@ +Structure +========= + +Offset Size Type Description + 0 4 data protocol tag, must be 0xFB1AB1AF + 4 2 uint sequence number + 6 2 uint sequence ack + 8 4 data bitfield with previous acks +12 1 uint type code for the payload +13 3 none padding, reserved for future use +16 0-484 data payload, contents and length vary, + mostly depending on the type code + +all multibyte values are in LE +the current code does no conversion, so only works on machines +with native LE (or BE if the server and all clients are on that, +but that's by accident and will break if conversion code is ever +added) + +Common Types +------------ + +Name Size Type +vec3 12 3x 32bit float +vec3i 12 3x 32bit signed int +quat 16 4x 32bit float +entity state 64 vec3i, vec3, vec3, quat, vec3 + + Packets ======= @@ -10,6 +39,7 @@ a while. Code: 0 Payload: none +Length: 0 Login @@ -21,5 +51,148 @@ been reached. Code: 1 Payload: - player name, max 32 byte UTF-8 string, - shorter names should be zero terminated + 0 player name, max 32 byte UTF-8 string, + shorter names should be zero terminated +Length: 0-32 + + +Join +---- + +Sent by the server either as a response to a successful login or when +it's changing worlds. + +Code: 2 +Payload: + 0 entity ID of the player, 32bit unsigned int + 4 entity state of the player + 68 name of the world the server's currently running + max 32 byte UTF-8 string +Length: 68-100 + + +Part +---- + +Sent by the server either as a respons to a failed login or when the +client was kicked. +Optionally sent by the client on disconnect. + +Code: 3 +Payload: none +Length: 0 + + +Player Update +------------- + +Sent by clients to notify the server of their changes to the player. + +Code: 4 +Payload: + 0 player's entity state as predicted by the client + 64 movement input, 3x 16bit signed int, each component mapped from [-1,1] to [-32767,32767] + 70 pitch input, 16bit signed int, mapped from [-PI/2,PI/2] to [-32767,32767] + 72 yaw input, 16bit signed int, mapped from [-PI,PI] to [-32767,32767] + 74 active actions, 8bit bit field, first three bits are primary, secondary, and tertiary + 75 selected inventory slot, 8bit unsigned int +Length: 76 + + +Spawn Entity +------------ + +Sent by the server to notify the client of an entity entering spawn range. + +Code: 5 +Payload: + 0 entity ID, 32bit unsigned int + 4 entity's skeleton ID, 32bit unsigned int + 8 entity state + 72 bounding box of the entity, 6x 32bit float + 96 flags, 32bit bitfield with boolean values + 1: world collision + 100 entity name, max 32 byte UTF-8 string +Length: 100 - 132 + + +Despawn Entity +-------------- + +Sent by the server to notify the client of an entity leaving spawn range. + +Code: 6 +Payload: + 0 entity ID, 32bit unsigned int +Length: 4 + + +Entity Update +------------- + +Sent by the server to notify the client of updated entity properties. +Contained entities must be ordered by ascending entity ID. + +Code: 7 +Payload: + 0 number of entities, 32bit int, 1-7 + 4 entity ID, 32bit unsigned int + 8 entity state + 72 next entity... +Length: 4 + multiple of 68, max 480 + + +Player Correction +----------------- + +Sent by the server to tell a client that its prediction is way off. + +Code: 8 +Payload: + 0 sequence number of the offending packet, 16bit unsigned int + 2 entity state of the player's entity on the server +Length: 66 + + +Chunk Begin +----------- + +Sent by the server to inform the client of an upcoming chunk transmission. + +Code: 9 +Payload: + 0 transmission ID, used for reference with Chunk Data packets, 32bit unsigned int + 4 flags, 32bit bitfield with boolean values + 1: compressed + 8 chunk coordinates, vec3i + 20 data size, 32bit unsigned int +Length: 24 + + +Chunk Data +---------- + +Raw chunk data sent by the server, optionally compressed with zlib. + +Code: 10 +Payload: + 0 transmission ID, references the Chunk Begin packet this data belongs to, 32bit unsigned int + 4 block offset, offset of this block inside the whole data, 32bit unsigned int + 8 block size, size of the data block, 32bit unsigned int + 12 data, raw data +Length: 12-484 + + +Block Update +------------ + +Sent by the server whenever one or more block in a chunk have changed. + +Code: 11 +Payload: + 0 chunk coordinates, vec3i + 12 number of blocks, 32bit unsigned int, 1-78 + 16 first block index, 16bit unsigned int + 18 first block data, 32bit + 22 second block index... +Length: 16 + multiple of 6, max 484