Skip to main content

basalt_mc_protocol/packets/play/
player.rs

1//! Play state — player 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 = 0x26)]
13pub struct ServerboundPlayAbilities {
14    pub flags: i8,
15}
16
17#[derive(Debug, Clone, Default, PartialEq)]
18#[packet(id = 0x0a)]
19pub struct ServerboundPlayClientCommand {
20    #[field(varint)]
21    pub action_id: i32,
22}
23
24#[derive(Debug, Clone, Default, PartialEq)]
25#[packet(id = 0x1f)]
26pub struct ServerboundPlayFlying {
27    pub flags: u8,
28}
29
30#[derive(Debug, Clone, Default, PartialEq)]
31#[packet(id = 0x1b)]
32pub struct ServerboundPlayLockDifficulty {
33    pub locked: bool,
34}
35
36#[derive(Debug, Clone, Default, PartialEq)]
37#[packet(id = 0x1e)]
38pub struct ServerboundPlayLook {
39    pub yaw: f32,
40    pub pitch: f32,
41    pub flags: u8,
42}
43
44#[derive(Debug, Clone, Default, PartialEq)]
45#[packet(id = 0x29)]
46pub struct ServerboundPlayPlayerInput {
47    pub inputs: u8,
48}
49
50#[derive(Debug, Clone, Default, PartialEq)]
51#[packet(id = 0x2a)]
52pub struct ServerboundPlayPlayerLoaded;
53
54#[derive(Debug, Clone, Default, PartialEq)]
55#[packet(id = 0x1c)]
56pub struct ServerboundPlayPosition {
57    pub x: f64,
58    pub y: f64,
59    pub z: f64,
60    pub flags: u8,
61}
62
63#[derive(Debug, Clone, Default, PartialEq)]
64#[packet(id = 0x1d)]
65pub struct ServerboundPlayPositionLook {
66    pub x: f64,
67    pub y: f64,
68    pub z: f64,
69    pub yaw: f32,
70    pub pitch: f32,
71    pub flags: u8,
72}
73
74#[derive(Debug, Clone, Default, PartialEq)]
75#[packet(id = 0x03)]
76pub struct ServerboundPlaySetDifficulty {
77    pub new_difficulty: u8,
78}
79
80#[derive(Debug, Clone, Default, PartialEq)]
81#[packet(id = 0x3b)]
82pub struct ServerboundPlaySpectate {
83    pub target: Uuid,
84}
85
86#[derive(Debug, Clone, Default, PartialEq)]
87#[packet(id = 0x21)]
88pub struct ServerboundPlaySteerBoat {
89    pub left_paddle: bool,
90    pub right_paddle: bool,
91}
92
93#[derive(Debug, Clone, Default, PartialEq)]
94#[packet(id = 0x00)]
95pub struct ServerboundPlayTeleportConfirm {
96    #[field(varint)]
97    pub teleport_id: i32,
98}
99
100#[derive(Debug, Clone, Default, PartialEq)]
101#[packet(id = 0x20)]
102pub struct ServerboundPlayVehicleMove {
103    pub x: f64,
104    pub y: f64,
105    pub z: f64,
106    pub yaw: f32,
107    pub pitch: f32,
108    pub on_ground: bool,
109}
110
111// -- Clientbound packets --
112
113#[derive(Debug, Clone, Default, PartialEq)]
114#[packet(id = 0x3a)]
115pub struct ClientboundPlayAbilities {
116    pub flags: i8,
117    pub flying_speed: f32,
118    pub walking_speed: f32,
119}
120
121#[derive(Debug, Clone, Default, PartialEq)]
122#[packet(id = 0x57)]
123pub struct ClientboundPlayCamera {
124    #[field(varint)]
125    pub camera_id: i32,
126}
127
128#[derive(Debug, Clone, Default, PartialEq)]
129#[packet(id = 0x3e)]
130pub struct ClientboundPlayDeathCombatEvent {
131    #[field(varint)]
132    pub player_id: i32,
133    pub message: NbtCompound,
134}
135
136#[derive(Debug, Clone, Default, PartialEq)]
137#[packet(id = 0x0b)]
138pub struct ClientboundPlayDifficulty {
139    pub difficulty: u8,
140    pub difficulty_locked: bool,
141}
142
143#[derive(Debug, Clone, Default, PartialEq)]
144#[packet(id = 0x3c)]
145pub struct ClientboundPlayEndCombatEvent {
146    #[field(varint)]
147    pub duration: i32,
148}
149
150#[derive(Debug, Clone, Default, PartialEq)]
151#[packet(id = 0x3d)]
152pub struct ClientboundPlayEnterCombatEvent;
153
154#[derive(Debug, Clone, Default, PartialEq)]
155#[packet(id = 0x61)]
156pub struct ClientboundPlayExperience {
157    pub experience_bar: f32,
158    #[field(varint)]
159    pub level: i32,
160    #[field(varint)]
161    pub total_experience: i32,
162}
163
164#[derive(Debug, Clone, Default, PartialEq)]
165#[packet(id = 0x41)]
166pub struct ClientboundPlayFacePlayer {
167    #[field(varint)]
168    pub feet_eyes: i32,
169    pub x: f64,
170    pub y: f64,
171    pub z: f64,
172    pub is_entity: bool,
173    pub entity_id: Vec<u8>,
174    pub entity_feet_eyes: Vec<u8>,
175}
176
177#[derive(Debug, Clone, Default, PartialEq)]
178#[packet(id = 0x23)]
179pub struct ClientboundPlayGameStateChange {
180    pub reason: u8,
181    pub game_mode: f32,
182}
183
184/// Inline data structure used by [`ClientboundPlayLogin`].
185#[derive(Debug, Clone, Default, PartialEq, Encode, Decode, EncodedSize)]
186pub struct ClientboundPlayLoginSpawninfo {
187    #[field(varint)]
188    pub dimension: i32,
189    pub name: String,
190    pub hashed_seed: i64,
191    pub gamemode: i8,
192    pub previous_gamemode: u8,
193    pub is_debug: bool,
194    pub is_flat: bool,
195    #[field(optional)]
196    pub death: Option<Vec<u8>>,
197    #[field(varint)]
198    pub portal_cooldown: i32,
199    #[field(varint)]
200    pub sea_level: i32,
201}
202
203#[derive(Debug, Clone, Default, PartialEq)]
204#[packet(id = 0x2c)]
205pub struct ClientboundPlayLogin {
206    pub entity_id: i32,
207    pub is_hardcore: bool,
208    #[field(length = "varint")]
209    pub world_names: Vec<String>,
210    #[field(varint)]
211    pub max_players: i32,
212    #[field(varint)]
213    pub view_distance: i32,
214    #[field(varint)]
215    pub simulation_distance: i32,
216    pub reduced_debug_info: bool,
217    pub enable_respawn_screen: bool,
218    pub do_limited_crafting: bool,
219    pub world_state: ClientboundPlayLoginSpawninfo,
220    pub enforces_secure_chat: bool,
221}
222
223/// Inline data structure used by [`ClientboundPlayPlayerChat`].
224#[derive(Debug, Clone, Default, PartialEq, Encode, Decode, EncodedSize)]
225pub struct ClientboundPlayPlayerChatPreviousmessages {
226    #[field(varint)]
227    pub id: i32,
228    pub signature: Vec<u8>,
229}
230
231/// Switch enum used by [`ClientboundPlayPlayerChat`].
232#[derive(Debug, Clone, PartialEq, Encode, Decode, EncodedSize)]
233pub enum ClientboundPlayPlayerChatFiltertype {
234    #[variant(id = 2)]
235    Variant2 {
236        #[field(length = "varint")]
237        filter_type_mask: Vec<i64>,
238    },
239}
240
241impl Default for ClientboundPlayPlayerChatFiltertype {
242    fn default() -> Self {
243        Self::Variant2 {
244            filter_type_mask: Default::default(),
245        }
246    }
247}
248#[derive(Debug, Clone, Default, PartialEq)]
249#[packet(id = 0x3b)]
250pub struct ClientboundPlayPlayerChat {
251    pub sender_uuid: Uuid,
252    #[field(varint)]
253    pub index: i32,
254    #[field(optional)]
255    pub signature: Option<Vec<u8>>,
256    pub plain_message: String,
257    pub timestamp: i64,
258    pub salt: i64,
259    #[field(length = "varint")]
260    pub previous_messages: Vec<ClientboundPlayPlayerChatPreviousmessages>,
261    #[field(optional)]
262    pub unsigned_chat_content: Option<NbtCompound>,
263    pub filter_type: ClientboundPlayPlayerChatFiltertype,
264    pub r#type: Vec<u8>,
265    pub network_name: NbtCompound,
266    #[field(optional)]
267    pub network_target_name: Option<NbtCompound>,
268}
269
270/// Inline data structure used by [`ClientboundPlayPlayerInfo`].
271#[derive(Debug, Clone, Default, PartialEq, Encode, Decode, EncodedSize)]
272pub struct ClientboundPlayPlayerInfoData {
273    pub uuid: Uuid,
274    #[field(rest)]
275    pub remaining: Vec<u8>,
276}
277
278#[derive(Debug, Clone, Default, PartialEq)]
279#[packet(id = 0x40)]
280pub struct ClientboundPlayPlayerInfo {
281    pub action: u8,
282    #[field(length = "varint")]
283    pub data: Vec<ClientboundPlayPlayerInfoData>,
284}
285
286#[derive(Debug, Clone, Default, PartialEq)]
287#[packet(id = 0x3f)]
288pub struct ClientboundPlayPlayerRemove {
289    #[field(length = "varint")]
290    pub players: Vec<Uuid>,
291}
292
293#[derive(Debug, Clone, Default, PartialEq)]
294#[packet(id = 0x43)]
295pub struct ClientboundPlayPlayerRotation {
296    pub yaw: f32,
297    pub pitch: f32,
298}
299
300#[derive(Debug, Clone, Default, PartialEq)]
301#[packet(id = 0x42)]
302pub struct ClientboundPlayPosition {
303    #[field(varint)]
304    pub teleport_id: i32,
305    pub x: f64,
306    pub y: f64,
307    pub z: f64,
308    pub dx: f64,
309    pub dy: f64,
310    pub dz: f64,
311    pub yaw: f32,
312    pub pitch: f32,
313    pub flags: u32,
314}
315
316/// Inline data structure used by [`ClientboundPlayRespawn`].
317#[derive(Debug, Clone, Default, PartialEq, Encode, Decode, EncodedSize)]
318pub struct ClientboundPlayRespawnSpawninfo {
319    #[field(varint)]
320    pub dimension: i32,
321    pub name: String,
322    pub hashed_seed: i64,
323    pub gamemode: i8,
324    pub previous_gamemode: u8,
325    pub is_debug: bool,
326    pub is_flat: bool,
327    #[field(optional)]
328    pub death: Option<Vec<u8>>,
329    #[field(varint)]
330    pub portal_cooldown: i32,
331    #[field(varint)]
332    pub sea_level: i32,
333}
334
335#[derive(Debug, Clone, Default, PartialEq)]
336#[packet(id = 0x4c)]
337pub struct ClientboundPlayRespawn {
338    pub world_state: ClientboundPlayRespawnSpawninfo,
339    pub copy_metadata: u8,
340}
341
342#[derive(Debug, Clone, Default, PartialEq)]
343#[packet(id = 0x69)]
344pub struct ClientboundPlaySimulationDistance {
345    #[field(varint)]
346    pub distance: i32,
347}
348
349#[derive(Debug, Clone, Default, PartialEq)]
350#[packet(id = 0x62)]
351pub struct ClientboundPlayUpdateHealth {
352    pub health: f32,
353    #[field(varint)]
354    pub food: i32,
355    pub food_saturation: f32,
356}
357
358#[derive(Debug, Clone, Default, PartialEq)]
359#[packet(id = 0x33)]
360pub struct ClientboundPlayVehicleMove {
361    pub x: f64,
362    pub y: f64,
363    pub z: f64,
364    pub yaw: f32,
365    pub pitch: f32,
366}