basalt-mc-protocol 0.2.1

Minecraft packet definitions and version-aware packet registry
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
//! Play state — misc packets.
//!
//! Auto-generated by `cargo xt codegen` from minecraft-data.
//! Do not edit manually — changes will be overwritten.

use basalt_derive::{Decode, Encode, EncodedSize, packet};
use basalt_types::{NbtCompound, Position, Uuid, Vec2f};

// -- Serverbound packets --

/// Switch enum used by [`ServerboundPlayAdvancementTab`].
#[derive(Debug, Clone, Default, PartialEq, Encode, Decode, EncodedSize)]
pub enum ServerboundPlayAdvancementTabAction {
    #[variant(id = 0)]
    Variant0 { tab_id: String },
    #[variant(id = 1)]
    #[default]
    Variant1,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x30)]
pub struct ServerboundPlayAdvancementTab {
    pub action: ServerboundPlayAdvancementTabAction,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x0e)]
pub struct ServerboundPlayConfigurationAcknowledged;

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x14)]
pub struct ServerboundPlayCustomPayload {
    pub channel: String,
    #[field(rest)]
    pub data: Vec<u8>,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x15)]
pub struct ServerboundPlayDebugSampleSubscription {
    #[field(varint)]
    pub r#type: i32,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x2d)]
pub struct ServerboundPlayDisplayedRecipe {
    #[field(varint)]
    pub recipe_id: i32,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x16)]
pub struct ServerboundPlayEditBook {
    #[field(varint)]
    pub hand: i32,
    #[field(length = "varint")]
    pub pages: Vec<String>,
    #[field(optional)]
    pub title: Option<String>,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x1a)]
pub struct ServerboundPlayKeepAlive {
    pub keep_alive_id: i64,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x24)]
pub struct ServerboundPlayPingRequest {
    pub id: i64,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x2b)]
pub struct ServerboundPlayPong {
    pub id: i32,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x2c)]
pub struct ServerboundPlayRecipeBook {
    #[field(varint)]
    pub book_id: i32,
    pub book_open: bool,
    pub filter_active: bool,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x2f)]
pub struct ServerboundPlayResourcePackReceive {
    pub uuid: Uuid,
    #[field(varint)]
    pub result: i32,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x0b)]
pub struct ServerboundPlayTickEnd;

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x34)]
pub struct ServerboundPlayUpdateCommandBlock {
    pub location: Position,
    pub command: String,
    #[field(varint)]
    pub mode: i32,
    pub flags: u8,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x35)]
pub struct ServerboundPlayUpdateCommandBlockMinecart {
    #[field(varint)]
    pub entity_id: i32,
    pub command: String,
    pub track_output: bool,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x37)]
pub struct ServerboundPlayUpdateJigsawBlock {
    pub location: Position,
    pub name: String,
    pub target: String,
    pub pool: String,
    pub final_state: String,
    pub joint_type: String,
    #[field(varint)]
    pub selection_priority: i32,
    #[field(varint)]
    pub placement_priority: i32,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x38)]
pub struct ServerboundPlayUpdateStructureBlock {
    pub location: Position,
    #[field(varint)]
    pub action: i32,
    #[field(varint)]
    pub mode: i32,
    pub name: String,
    pub offset_x: i8,
    pub offset_y: i8,
    pub offset_z: i8,
    pub size_x: i8,
    pub size_y: i8,
    pub size_z: i8,
    #[field(varint)]
    pub mirror: i32,
    #[field(varint)]
    pub rotation: i32,
    pub metadata: String,
    pub integrity: f32,
    #[field(varint)]
    pub seed: i32,
    pub flags: u8,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x3d)]
pub struct ServerboundPlayUseItem {
    #[field(varint)]
    pub hand: i32,
    #[field(varint)]
    pub sequence: i32,
    pub rotation: Vec2f,
}

// -- Clientbound packets --

/// Inline data structure used by [`ClientboundPlayAdvancements`].
#[derive(Debug, Clone, Default, PartialEq, Encode, Decode, EncodedSize)]
pub struct ClientboundPlayAdvancementsAdvancementmappingValue {
    #[field(optional)]
    pub parent_id: Option<String>,
    #[field(optional)]
    pub display_data: Option<Vec<u8>>,
    #[field(length = "varint")]
    pub requirements: Vec<Vec<u8>>,
    pub sends_telemtry_data: bool,
}

/// Inline data structure used by [`ClientboundPlayAdvancements`].
#[derive(Debug, Clone, Default, PartialEq, Encode, Decode, EncodedSize)]
pub struct ClientboundPlayAdvancementsAdvancementmapping {
    pub key: String,
    pub value: ClientboundPlayAdvancementsAdvancementmappingValue,
}

/// Inline data structure used by [`ClientboundPlayAdvancements`].
#[derive(Debug, Clone, Default, PartialEq, Encode, Decode, EncodedSize)]
pub struct ClientboundPlayAdvancementsProgressmappingValue {
    pub criterion_identifier: String,
    #[field(optional)]
    pub criterion_progress: Option<i64>,
}

/// Inline data structure used by [`ClientboundPlayAdvancements`].
#[derive(Debug, Clone, Default, PartialEq, Encode, Decode, EncodedSize)]
pub struct ClientboundPlayAdvancementsProgressmapping {
    pub key: String,
    #[field(length = "varint")]
    pub value: Vec<ClientboundPlayAdvancementsProgressmappingValue>,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x7b)]
pub struct ClientboundPlayAdvancements {
    pub reset: bool,
    #[field(length = "varint")]
    pub advancement_mapping: Vec<ClientboundPlayAdvancementsAdvancementmapping>,
    #[field(length = "varint")]
    pub identifiers: Vec<String>,
    #[field(length = "varint")]
    pub progress_mapping: Vec<ClientboundPlayAdvancementsProgressmapping>,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x19)]
pub struct ClientboundPlayCustomPayload {
    pub channel: String,
    #[field(rest)]
    pub data: Vec<u8>,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x1b)]
pub struct ClientboundPlayDebugSample {
    #[field(length = "varint")]
    pub sample: Vec<i64>,
    #[field(varint)]
    pub r#type: i32,
}

/// Inline data structure used by [`ClientboundPlayDeclareRecipes`].
#[derive(Debug, Clone, Default, PartialEq, Encode, Decode, EncodedSize)]
pub struct ClientboundPlayDeclareRecipesRecipes {
    pub name: String,
    #[field(length = "varint", element = "varint")]
    pub items: Vec<i32>,
}

/// Inline data structure used by [`ClientboundPlayDeclareRecipes`].
#[derive(Debug, Clone, Default, PartialEq, Encode, Decode, EncodedSize)]
pub struct ClientboundPlayDeclareRecipesStonecutterrecipes {
    pub input: Vec<u8>,
    pub slot_display: crate::packets::play::types::SlotDisplay,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x7e)]
pub struct ClientboundPlayDeclareRecipes {
    #[field(length = "varint")]
    pub recipes: Vec<ClientboundPlayDeclareRecipesRecipes>,
    #[field(length = "varint")]
    pub stone_cutter_recipes: Vec<ClientboundPlayDeclareRecipesStonecutterrecipes>,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x27)]
pub struct ClientboundPlayKeepAlive {
    pub keep_alive_id: i64,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x1d)]
pub struct ClientboundPlayKickDisconnect {
    pub reason: NbtCompound,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x37)]
pub struct ClientboundPlayPing {
    pub id: i32,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x38)]
pub struct ClientboundPlayPingResponse {
    pub id: i64,
}

/// Inline data structure used by [`ClientboundPlayRecipeBookAdd`].
#[derive(Debug, Clone, Default, PartialEq, Encode, Decode, EncodedSize)]
pub struct ClientboundPlayRecipeBookAddEntriesRecipe {
    #[field(varint)]
    pub display_id: i32,
    pub display: crate::packets::play::types::RecipeDisplay,
    #[field(varint)]
    pub group: i32,
    #[field(varint)]
    pub category: i32,
    #[field(optional)]
    pub crafting_requirements: Option<Vec<u8>>,
}

/// Inline data structure used by [`ClientboundPlayRecipeBookAdd`].
#[derive(Debug, Clone, Default, PartialEq, Encode, Decode, EncodedSize)]
pub struct ClientboundPlayRecipeBookAddEntries {
    pub recipe: ClientboundPlayRecipeBookAddEntriesRecipe,
    pub flags: u8,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x44)]
pub struct ClientboundPlayRecipeBookAdd {
    #[field(length = "varint")]
    pub entries: Vec<ClientboundPlayRecipeBookAddEntries>,
    pub replace: bool,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x45)]
pub struct ClientboundPlayRecipeBookRemove {
    #[field(length = "varint", element = "varint")]
    pub recipe_ids: Vec<i32>,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x46)]
pub struct ClientboundPlayRecipeBookSettings {
    pub crafting_gui_open: bool,
    pub crafting_filtering_craftable: bool,
    pub smelting_gui_open: bool,
    pub smelting_filtering_craftable: bool,
    pub blast_gui_open: bool,
    pub blast_filtering_craftable: bool,
    pub smoker_gui_open: bool,
    pub smoker_filtering_craftable: bool,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x4f)]
pub struct ClientboundPlaySelectAdvancementTab {
    #[field(optional)]
    pub id: Option<String>,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x50)]
pub struct ClientboundPlayServerData {
    pub motd: NbtCompound,
    #[field(optional)]
    pub icon_bytes: Option<Vec<u8>>,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x78)]
pub struct ClientboundPlaySetTickingState {
    pub tick_rate: f32,
    pub is_frozen: bool,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x6f)]
pub struct ClientboundPlaySoundEffect {
    pub sound: Vec<u8>,
    #[field(varint)]
    pub sound_category: i32,
    pub x: i32,
    pub y: i32,
    pub z: i32,
    pub volume: f32,
    pub pitch: f32,
    pub seed: i64,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x70)]
pub struct ClientboundPlayStartConfiguration;

/// Inline data structure used by [`ClientboundPlayStatistics`].
#[derive(Debug, Clone, Default, PartialEq, Encode, Decode, EncodedSize)]
pub struct ClientboundPlayStatisticsEntries {
    #[field(varint)]
    pub category_id: i32,
    #[field(varint)]
    pub statistic_id: i32,
    #[field(varint)]
    pub value: i32,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x04)]
pub struct ClientboundPlayStatistics {
    #[field(length = "varint")]
    pub entries: Vec<ClientboundPlayStatisticsEntries>,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x79)]
pub struct ClientboundPlayStepTick {
    #[field(varint)]
    pub tick_steps: i32,
}

/// Switch enum used by [`ClientboundPlayStopSound`].
#[derive(Debug, Clone, PartialEq, Encode, Decode, EncodedSize)]
pub enum ClientboundPlayStopSoundFlags {
    #[variant(id = 1)]
    Variant1 {
        #[field(varint)]
        source: i32,
    },
    #[variant(id = 2)]
    Variant2 { sound: String },
    #[variant(id = 3)]
    Variant3 {
        #[field(varint)]
        source: i32,
        sound: String,
    },
}

impl Default for ClientboundPlayStopSoundFlags {
    fn default() -> Self {
        Self::Variant1 {
            source: Default::default(),
        }
    }
}
#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x71)]
pub struct ClientboundPlayStopSound {
    pub flags: ClientboundPlayStopSoundFlags,
}

/// Inline data structure used by [`ClientboundPlayTags`].
#[derive(Debug, Clone, Default, PartialEq, Encode, Decode, EncodedSize)]
pub struct ClientboundPlayTagsTagsTags {
    pub tag_name: String,
    #[field(length = "varint", element = "varint")]
    pub entries: Vec<i32>,
}

/// Inline data structure used by [`ClientboundPlayTags`].
#[derive(Debug, Clone, Default, PartialEq, Encode, Decode, EncodedSize)]
pub struct ClientboundPlayTagsTags {
    pub tag_type: String,
    #[field(length = "varint")]
    pub tags: Vec<ClientboundPlayTagsTagsTags>,
}

#[derive(Debug, Clone, Default, PartialEq)]
#[packet(id = 0x7f)]
pub struct ClientboundPlayTags {
    #[field(length = "varint")]
    pub tags: Vec<ClientboundPlayTagsTags>,
}