Skip to main content

basalt_mc_protocol/packets/play/
chat.rs

1//! Play state — chat packets.
2//!
3//! Auto-generated by `cargo xt codegen` from minecraft-data.
4//! Do not edit manually — changes will be overwritten.
5
6use basalt_derive::{Decode, Encode, EncodedSize, packet};
7use basalt_types::{NbtCompound, Uuid};
8
9// -- Serverbound packets --
10
11#[derive(Debug, Clone, Default, PartialEq)]
12#[packet(id = 0x05)]
13pub struct ServerboundPlayChatCommand {
14    pub command: String,
15}
16
17/// Inline data structure used by [`ServerboundPlayChatCommandSigned`].
18#[derive(Debug, Clone, Default, PartialEq, Encode, Decode, EncodedSize)]
19pub struct ServerboundPlayChatCommandSignedArgumentsignatures {
20    pub argument_name: String,
21    #[field(length = "varint")]
22    pub signature: Vec<u8>,
23}
24
25#[derive(Debug, Clone, Default, PartialEq)]
26#[packet(id = 0x06)]
27pub struct ServerboundPlayChatCommandSigned {
28    pub command: String,
29    pub timestamp: i64,
30    pub salt: i64,
31    #[field(length = "varint")]
32    pub argument_signatures: Vec<ServerboundPlayChatCommandSignedArgumentsignatures>,
33    #[field(varint)]
34    pub message_count: i32,
35    #[field(length = "varint")]
36    pub acknowledged: Vec<u8>,
37}
38
39#[derive(Debug, Clone, Default, PartialEq)]
40#[packet(id = 0x07)]
41pub struct ServerboundPlayChatMessage {
42    pub message: String,
43    pub timestamp: i64,
44    pub salt: i64,
45    #[field(optional)]
46    pub signature: Option<Vec<u8>>,
47    #[field(varint)]
48    pub offset: i32,
49    #[field(length = "varint")]
50    pub acknowledged: Vec<u8>,
51}
52
53#[derive(Debug, Clone, Default, PartialEq)]
54#[packet(id = 0x08)]
55pub struct ServerboundPlayChatSessionUpdate {
56    pub session_uuid: Uuid,
57    pub expire_time: i64,
58    #[field(length = "varint")]
59    pub public_key: Vec<u8>,
60    #[field(length = "varint")]
61    pub signature: Vec<u8>,
62}
63
64#[derive(Debug, Clone, Default, PartialEq)]
65#[packet(id = 0x04)]
66pub struct ServerboundPlayMessageAcknowledgement {
67    #[field(varint)]
68    pub count: i32,
69}
70
71#[derive(Debug, Clone, Default, PartialEq)]
72#[packet(id = 0x0d)]
73pub struct ServerboundPlayTabComplete {
74    #[field(varint)]
75    pub transaction_id: i32,
76    pub text: String,
77}
78
79// -- Clientbound packets --
80
81#[derive(Debug, Clone, Default, PartialEq)]
82#[packet(id = 0x51)]
83pub struct ClientboundPlayActionBar {
84    pub text: NbtCompound,
85}
86
87/// Switch enum used by [`ClientboundPlayBossBar`].
88#[derive(Debug, Clone, PartialEq, Encode, Decode, EncodedSize)]
89pub enum ClientboundPlayBossBarAction {
90    #[variant(id = 0)]
91    Variant0 {
92        title: NbtCompound,
93        health: f32,
94        #[field(varint)]
95        color: i32,
96        #[field(varint)]
97        dividers: i32,
98        flags: u8,
99    },
100    #[variant(id = 2)]
101    Variant2 { health: f32 },
102    #[variant(id = 3)]
103    Variant3 { title: NbtCompound },
104    #[variant(id = 4)]
105    Variant4 {
106        #[field(varint)]
107        color: i32,
108        #[field(varint)]
109        dividers: i32,
110    },
111    #[variant(id = 5)]
112    Variant5 { flags: u8 },
113}
114
115impl Default for ClientboundPlayBossBarAction {
116    fn default() -> Self {
117        Self::Variant0 {
118            title: Default::default(),
119            health: Default::default(),
120            color: Default::default(),
121            dividers: Default::default(),
122            flags: Default::default(),
123        }
124    }
125}
126#[derive(Debug, Clone, Default, PartialEq)]
127#[packet(id = 0x0a)]
128pub struct ClientboundPlayBossBar {
129    pub entity_uuid: Uuid,
130    pub action: ClientboundPlayBossBarAction,
131}
132
133#[derive(Debug, Clone, Default, PartialEq)]
134#[packet(id = 0x18)]
135pub struct ClientboundPlayChatSuggestions {
136    #[field(varint)]
137    pub action: i32,
138    #[field(length = "varint")]
139    pub entries: Vec<String>,
140}
141
142#[derive(Debug, Clone, Default, PartialEq)]
143#[packet(id = 0x0f)]
144pub struct ClientboundPlayClearTitles {
145    pub reset: bool,
146}
147
148/// Inline data structure used by [`ClientboundPlayDeclareCommands`].
149#[derive(Debug, Clone, Default, PartialEq, Encode, Decode, EncodedSize)]
150pub struct ClientboundPlayDeclareCommandsCommandNode {
151    pub flags: u8,
152    #[field(length = "varint", element = "varint")]
153    pub children: Vec<i32>,
154    #[field(rest)]
155    pub remaining: Vec<u8>,
156}
157
158#[derive(Debug, Clone, Default, PartialEq)]
159#[packet(id = 0x11)]
160pub struct ClientboundPlayDeclareCommands {
161    #[field(length = "varint")]
162    pub nodes: Vec<ClientboundPlayDeclareCommandsCommandNode>,
163    #[field(varint)]
164    pub root_index: i32,
165}
166
167/// Switch enum used by [`ClientboundPlayHideMessage`].
168#[derive(Debug, Clone, PartialEq, Encode, Decode, EncodedSize)]
169pub enum ClientboundPlayHideMessageId {
170    #[variant(id = 0)]
171    Variant0 {
172        #[field(length = "varint")]
173        signature: Vec<u8>,
174    },
175}
176
177impl Default for ClientboundPlayHideMessageId {
178    fn default() -> Self {
179        Self::Variant0 {
180            signature: Default::default(),
181        }
182    }
183}
184#[derive(Debug, Clone, Default, PartialEq)]
185#[packet(id = 0x1c)]
186pub struct ClientboundPlayHideMessage {
187    pub id: ClientboundPlayHideMessageId,
188}
189
190#[derive(Debug, Clone, Default, PartialEq)]
191#[packet(id = 0x74)]
192pub struct ClientboundPlayPlayerlistHeader {
193    pub header: NbtCompound,
194    pub footer: NbtCompound,
195}
196
197#[derive(Debug, Clone, Default, PartialEq)]
198#[packet(id = 0x1e)]
199pub struct ClientboundPlayProfilelessChat {
200    pub message: NbtCompound,
201    pub r#type: Vec<u8>,
202    pub name: NbtCompound,
203    #[field(optional)]
204    pub target: Option<NbtCompound>,
205}
206
207#[derive(Debug, Clone, Default, PartialEq)]
208#[packet(id = 0x49)]
209pub struct ClientboundPlayResetScore {
210    pub entity_name: String,
211    #[field(optional)]
212    pub objective_name: Option<String>,
213}
214
215#[derive(Debug, Clone, Default, PartialEq)]
216#[packet(id = 0x5c)]
217pub struct ClientboundPlayScoreboardDisplayObjective {
218    #[field(varint)]
219    pub position: i32,
220    pub name: String,
221}
222
223/// Switch enum used by [`ClientboundPlayScoreboardObjective`].
224#[derive(Debug, Clone, PartialEq, Encode, Decode, EncodedSize)]
225pub enum ClientboundPlayScoreboardObjectiveAction {
226    #[variant(id = 0)]
227    Variant0 {
228        display_text: NbtCompound,
229        #[field(varint)]
230        r#type: i32,
231        #[field(optional)]
232        number_format: Option<Vec<u8>>,
233        styling: Vec<u8>,
234    },
235    #[variant(id = 2)]
236    Variant2 {
237        display_text: NbtCompound,
238        #[field(varint)]
239        r#type: i32,
240        #[field(optional)]
241        number_format: Option<Vec<u8>>,
242        styling: Vec<u8>,
243    },
244}
245
246impl Default for ClientboundPlayScoreboardObjectiveAction {
247    fn default() -> Self {
248        Self::Variant0 {
249            display_text: Default::default(),
250            r#type: Default::default(),
251            number_format: Default::default(),
252            styling: Default::default(),
253        }
254    }
255}
256#[derive(Debug, Clone, Default, PartialEq)]
257#[packet(id = 0x64)]
258pub struct ClientboundPlayScoreboardObjective {
259    pub name: String,
260    pub action: ClientboundPlayScoreboardObjectiveAction,
261}
262
263/// Switch enum used by [`ClientboundPlayScoreboardScore`].
264#[derive(Debug, Clone, PartialEq, Encode, Decode, EncodedSize)]
265pub enum ClientboundPlayScoreboardScoreNumberFormat {
266    #[variant(id = 1)]
267    Variant1 { styling: NbtCompound },
268    #[variant(id = 2)]
269    Variant2 { styling: NbtCompound },
270}
271
272impl Default for ClientboundPlayScoreboardScoreNumberFormat {
273    fn default() -> Self {
274        Self::Variant1 {
275            styling: Default::default(),
276        }
277    }
278}
279#[derive(Debug, Clone, Default, PartialEq)]
280#[packet(id = 0x68)]
281pub struct ClientboundPlayScoreboardScore {
282    pub item_name: String,
283    pub score_name: String,
284    #[field(varint)]
285    pub value: i32,
286    #[field(optional)]
287    pub display_name: Option<NbtCompound>,
288    pub number_format: ClientboundPlayScoreboardScoreNumberFormat,
289}
290
291#[derive(Debug, Clone, Default, PartialEq)]
292#[packet(id = 0x6a)]
293pub struct ClientboundPlaySetTitleSubtitle {
294    pub text: NbtCompound,
295}
296
297#[derive(Debug, Clone, Default, PartialEq)]
298#[packet(id = 0x6c)]
299pub struct ClientboundPlaySetTitleText {
300    pub text: NbtCompound,
301}
302
303#[derive(Debug, Clone, Default, PartialEq)]
304#[packet(id = 0x6d)]
305pub struct ClientboundPlaySetTitleTime {
306    pub fade_in: i32,
307    pub stay: i32,
308    pub fade_out: i32,
309}
310
311#[derive(Debug, Clone, Default, PartialEq)]
312#[packet(id = 0x73)]
313pub struct ClientboundPlaySystemChat {
314    pub content: NbtCompound,
315    pub is_action_bar: bool,
316}
317
318/// Inline data structure used by [`ClientboundPlayTabComplete`].
319#[derive(Debug, Clone, Default, PartialEq, Encode, Decode, EncodedSize)]
320pub struct ClientboundPlayTabCompleteMatches {
321    pub r#match: String,
322    #[field(optional)]
323    pub tooltip: Option<NbtCompound>,
324}
325
326#[derive(Debug, Clone, Default, PartialEq)]
327#[packet(id = 0x10)]
328pub struct ClientboundPlayTabComplete {
329    #[field(varint)]
330    pub transaction_id: i32,
331    #[field(varint)]
332    pub start: i32,
333    #[field(varint)]
334    pub length: i32,
335    #[field(length = "varint")]
336    pub matches: Vec<ClientboundPlayTabCompleteMatches>,
337}
338
339/// Switch enum used by [`ClientboundPlayTeams`].
340#[derive(Debug, Clone, PartialEq, Encode, Decode, EncodedSize)]
341pub enum ClientboundPlayTeamsMode {
342    #[variant(id = 0)]
343    Variant0 {
344        name: NbtCompound,
345        friendly_fire: i8,
346        name_tag_visibility: String,
347        collision_rule: String,
348        #[field(varint)]
349        formatting: i32,
350        prefix: NbtCompound,
351        suffix: NbtCompound,
352        #[field(length = "varint")]
353        players: Vec<String>,
354    },
355    #[variant(id = 2)]
356    Variant2 {
357        name: NbtCompound,
358        friendly_fire: i8,
359        name_tag_visibility: String,
360        collision_rule: String,
361        #[field(varint)]
362        formatting: i32,
363        prefix: NbtCompound,
364        suffix: NbtCompound,
365    },
366    #[variant(id = 3)]
367    Variant3 {
368        #[field(length = "varint")]
369        players: Vec<String>,
370    },
371    #[variant(id = 4)]
372    Variant4 {
373        #[field(length = "varint")]
374        players: Vec<String>,
375    },
376}
377
378impl Default for ClientboundPlayTeamsMode {
379    fn default() -> Self {
380        Self::Variant0 {
381            name: Default::default(),
382            friendly_fire: Default::default(),
383            name_tag_visibility: Default::default(),
384            collision_rule: Default::default(),
385            formatting: Default::default(),
386            prefix: Default::default(),
387            suffix: Default::default(),
388            players: Default::default(),
389        }
390    }
391}
392#[derive(Debug, Clone, Default, PartialEq)]
393#[packet(id = 0x67)]
394pub struct ClientboundPlayTeams {
395    pub team: String,
396    pub mode: ClientboundPlayTeamsMode,
397}