]> git.localhorst.tv Git - blank.git/blob - doc/protocol
607bbb164fdcb588719f69f09fcd522311a51a4a
[blank.git] / doc / protocol
1 Structure
2 =========
3
4 Offset  Size   Type  Description
5  0      4      data  protocol tag, must be 0xFB1AB1AF
6  4      2      uint  sequence number
7  6      2      uint  sequence ack
8  8      4      data  bitfield with previous acks
9 12      1      uint  type code for the payload
10 13      3      none  padding, reserved for future use
11 16      0-484  data  payload, contents and length vary,
12                      mostly depending on the type code
13
14 all multibyte values are in LE
15 the current code does no conversion, so only works on machines
16 with native LE (or BE if the server and all clients are on that,
17 but that's by accident and will break if conversion code is ever
18 added)
19
20 Common Types
21 ------------
22
23 Name          Size  Type
24 vec3          12    3x 32bit float
25 vec3i         12    3x 32bit signed int
26 quat          16    4x 32bit float
27 entity state  64    vec3i, vec3, vec3, quat, vec3
28
29
30 Packets
31 =======
32
33 Ping
34 ----
35
36 To tell the other side we're still alive.
37 Both server and client will send this if they haven't sent something in
38 a while.
39
40 Code: 0
41 Payload: none
42 Length: 0
43
44
45 Login
46 -----
47
48 Sent from client to serveri as a request to join. The server may
49 respond negatively if the player name is already taken or some cap has
50 been reached.
51
52 Code: 1
53 Payload:
54         0 player name, max 32 byte UTF-8 string,
55           shorter names should be zero terminated
56 Length: 0-32
57
58
59 Join
60 ----
61
62 Sent by the server either as a response to a successful login or when
63 it's changing worlds.
64
65 Code: 2
66 Payload:
67          0 entity ID of the player, 32bit unsigned int
68          4 entity state of the player
69         68 name of the world the server's currently running
70            max 32 byte UTF-8 string
71 Length: 68-100
72
73
74 Part
75 ----
76
77 Sent by the server either as a respons to a failed login or when the
78 client was kicked.
79 Optionally sent by the client on disconnect.
80
81 Code: 3
82 Payload: none
83 Length: 0
84
85
86 Player Update
87 -------------
88
89 Sent by clients to notify the server of their changes to the player.
90
91 Code: 4
92 Payload:
93          0 entity state of the player as seen by the client
94 Length: 64
95
96
97 Spawn Entity
98 ------------
99
100 Sent by the server to notify the client of an entity entering spawn range.
101
102 Code: 5
103 Payload:
104           0 entity ID, 32bit unsigned int
105           4 entity's skeleton ID, 32bit unsigned int
106           8 entity state
107          72 bounding box of the entity, 6x 32bit float
108          96 flags, 32bit bitfield with boolean values
109             1: world collision
110         100 entity name, max 32 byte UTF-8 string
111 Length: 132
112
113
114 Despawn Entity
115 --------------
116
117 Sent by the server to notify the client of an entity leaving spawn range.
118
119 Code: 6
120 Payload:
121         0 entity ID, 32bit unsigned int
122 Length: 4
123
124
125 Entity Update
126 -------------
127
128 Sent by the server to notify the client of updated entity properties.
129 Contained entities must be ordered by ascending entity ID.
130
131 Code: 7
132 Payload:
133          0 number of entities, 32bit int, 1-7
134          4 entity ID, 32bit unsigned int
135          8 entity state
136         72 next entity...
137 Length: 4 + multiple of 68, max 452
138
139
140 Player Correction
141 -----------------
142
143 Sent by the server to tell a client that its prediction is way off.
144
145 Code: 8
146 Payload:
147          0 sequence number of the offending packet, 16bit unsigned int
148          2 entity state of the player's entity on the server
149 Length: 66
150
151
152 Chunk Begin
153 -----------
154
155 Sent by the server to inform the client of an upcoming chunk transmission.
156
157 Code: 9
158 Payload:
159          0 transmission ID, used for reference with Chunk Data packets, 32bit unsigned int
160          4 flags, 32bit bitfield with boolean values
161            1: compressed
162          8 chunk coordinates, vec3i
163         20 data size, 32bit unsigned int
164 Length: 24
165
166
167 Chunk Data
168 ----------
169
170 Raw chunk data sent by the server, optionally compressed with zlib.
171
172 Code: 10
173 Payload:
174          0 transmission ID, references the Chunk Begin packet this data belongs to, 32bit unsigned int
175          4 block offset, offset of this block inside the whole data, 32bit unsigned int
176          8 block size, size of the data block, 32bit unsigned int
177         12 data, raw data
178 Length: 12-484