Skip to main content

nurtex_protocol/packets/play/
packets.rs

1use nurtex_codec::Buffer;
2use nurtex_derive::Packet;
3use uuid::Uuid;
4
5use crate::types::{
6  AdditionalMessageInfo, BlockPos, ChunkData, ClientCommand, Experience, Face, 
7  GameEvent, InteractType, Item, LightData, LpVector3, PhysicsFlags, PlayerAction, 
8  PlayerCommand, RelativeHand, ResourcePackState, Rotation, TeleportFlags, TextComponent, Vector3,
9};
10
11#[derive(Clone, Debug, PartialEq, Packet)]
12pub struct MultisideKeepAlive {
13  pub id: i64,
14}
15
16#[derive(Clone, Debug, PartialEq, Packet)]
17pub struct ClientsidePing {
18  pub id: i32,
19}
20
21#[derive(Clone, Debug, PartialEq, Packet)]
22pub struct ClientsidePingResponse {
23  pub timestamp: i64,
24}
25
26#[derive(Clone, Debug, PartialEq, Packet)]
27pub struct ClientsideDamageEvent {
28  #[varint]
29  pub entity_id: i32,
30  #[varint]
31  pub source_type_id: i32,
32  #[varint]
33  pub source_cause_id: i32,
34  #[varint]
35  pub source_direct_id: i32,
36  pub source_position: Vector3,
37}
38
39#[derive(Clone, Debug, PartialEq, Packet)]
40pub struct ClientsideUpdateEntityPos {
41  #[varint]
42  pub entity_id: i32,
43  pub delta_x: i16,
44  pub delta_y: i16,
45  pub delta_z: i16,
46  pub on_ground: bool,
47}
48
49#[derive(Clone, Debug, PartialEq, Packet)]
50pub struct ClientsideUpdateEntityRot {
51  #[varint]
52  pub entity_id: i32,
53  pub yaw_angle: i8,
54  pub pitch_angle: i8,
55  pub on_ground: bool,
56}
57
58#[derive(Clone, Debug, PartialEq, Packet)]
59pub struct ClientsideUpdateEntityPosRot {
60  #[varint]
61  pub entity_id: i32,
62  pub delta_x: i16,
63  pub delta_y: i16,
64  pub delta_z: i16,
65  pub yaw_angle: i8,
66  pub pitch_angle: i8,
67  pub on_ground: bool,
68}
69
70#[derive(Clone, Debug, PartialEq, Packet)]
71pub struct ClientsidePlayerPosition {
72  #[varlong]
73  pub teleport_id: i64,
74  pub position: Vector3,
75  pub velocity: Vector3,
76  pub rotation: Rotation,
77  pub teleport_flags: TeleportFlags,
78}
79
80#[derive(Clone, Debug, PartialEq, Packet)]
81pub struct ClientsidePlayerRotation {
82  pub yaw: f32,
83  pub relative_yaw: bool,
84  pub pitch: f32,
85  pub relative_pitch: bool,
86}
87
88#[derive(Clone, Debug, PartialEq, Packet)]
89pub struct ClientsidePlayerLookAt {
90  #[varint]
91  pub gaze: i32,
92  pub target_pos: Vector3,
93  pub is_entity: bool,
94  pub entity_id: Option<i32>,
95  pub entity_gaze: Option<i32>,
96}
97
98#[derive(Clone, Debug, PartialEq, Packet)]
99pub struct ClientsidePlayerCombatKill {
100  #[varint]
101  pub player_id: i32,
102}
103
104#[derive(Clone, Debug, PartialEq, Packet)]
105pub struct ClientsideSetHealth {
106  pub health: f32,
107  #[varint]
108  pub food: i32,
109  pub food_saturation: f32,
110}
111
112#[derive(Clone, Debug, PartialEq, Packet)]
113pub struct ClientsideSetExperience {
114  pub experience: Experience,
115}
116
117#[derive(Clone, Debug, PartialEq, Packet)]
118pub struct ClientsideSetPassengers {
119  #[varint]
120  pub entity_id: i32,
121  #[vec_varint]
122  pub passengers: Vec<i32>,
123}
124
125#[derive(Clone, Debug, PartialEq, Packet)]
126pub struct ClientsideSetEntityVelocity {
127  #[varint]
128  pub entity_id: i32,
129  pub velocity: LpVector3,
130}
131
132#[derive(Clone, Debug, PartialEq, Packet)]
133pub struct ClientsideSpawnEntity {
134  #[varint]
135  pub entity_id: i32,
136  pub entity_uuid: Uuid,
137  #[varint]
138  pub entity_type: i32,
139  pub position: Vector3,
140  pub velocity: LpVector3,
141  pub pitch_angle: i8,
142  pub yaw_angle: i8,
143  pub head_yaw_angle: i8,
144  #[varint]
145  pub data: i32,
146}
147
148#[derive(Clone, Debug, PartialEq, Packet)]
149pub struct ClientsideRemoveEntities {
150  #[vec_varint]
151  pub entities: Vec<i32>,
152}
153
154#[derive(Clone, Debug, PartialEq, Packet)]
155pub struct ClientsideDisconnect;
156
157#[derive(Clone, Debug, PartialEq, Packet)]
158pub struct ClientsidePlayerChat {
159  #[varint]
160  pub global_index: i32,
161  pub sender_uuid: Uuid,
162  #[varint]
163  pub index: i32,
164  pub message_signature: Option<Vec<u8>>,
165  pub message: String,
166  pub timestamp: i64,
167  pub salt: i64,
168  #[varint]
169  pub message_id: i32,
170  pub signature: Option<Vec<u8>>,
171}
172
173#[derive(Clone, Debug, PartialEq, Packet)]
174pub struct ClientsideSystemChat {
175  pub message: TextComponent,
176  pub overlay: bool,
177}
178
179#[derive(Clone, Debug, PartialEq, Packet)]
180pub struct ClientsideTransfer {
181  pub server_host: String,
182  #[varint]
183  pub server_port: i32,
184}
185
186#[derive(Clone, Debug, PartialEq, Packet)]
187pub struct ClientsideSetHeldItem {
188  #[varint]
189  pub slot: i32,
190}
191
192#[derive(Clone, Debug, PartialEq, Packet)]
193pub struct ClientsideSetEntityLink {
194  #[varint]
195  pub attached_entity_id: i32,
196  #[varint]
197  pub holding_entity_id: i32,
198}
199
200#[derive(Clone, Debug, PartialEq, Packet)]
201pub struct ClientsideChunkCacheRadius {
202  #[varint]
203  pub view_distance: i32,
204}
205
206#[derive(Clone, Debug, PartialEq, Packet)]
207pub struct ClientsideChunkCacheCenter {
208  #[varint]
209  pub chunk_x: i32,
210  #[varint]
211  pub chunk_z: i32,
212}
213
214#[derive(Clone, Debug, PartialEq, Packet)]
215pub struct ClientsideSetCamera {
216  #[varint]
217  pub camera_id: i32,
218}
219
220#[derive(Clone, Debug, PartialEq, Packet)]
221pub struct ClientsideRotateHead {
222  #[varint]
223  pub entity_id: i32,
224  pub head_yaw: i8,
225}
226
227#[derive(Clone, Debug, PartialEq, Packet)]
228pub struct ClientsideSectionBlocksUpdate {
229  pub chunk_section_position: i64,
230  #[vec_varlong]
231  pub head_yaw: Vec<i64>,
232}
233
234#[derive(Clone, Debug, PartialEq, Packet)]
235pub struct ClientsideAddResourcePack {
236  pub uuid: uuid::Uuid,
237  pub url: String,
238  pub hash: String,
239  pub forced: bool,
240}
241
242#[derive(Clone, Debug, PartialEq, Packet)]
243pub struct ClientsideRemoveResourcePack {
244  pub uuid: uuid::Uuid,
245}
246
247#[derive(Clone, Debug, PartialEq, Packet)]
248pub struct ClientsideRemoveEntityEffect {
249  #[varint]
250  pub entity_id: i32,
251  #[varint]
252  pub effect_id: i32,
253}
254
255#[derive(Clone, Debug, PartialEq, Packet)]
256pub struct ClientsideOpenContainer {
257  #[varint]
258  pub window_id: i32,
259  #[varint]
260  pub window_type: i32,
261}
262
263#[derive(Clone, Debug, PartialEq, Packet)]
264pub struct ClientsideMoveVehicle {
265  pub position: Vector3,
266  pub rotation: Rotation,
267}
268
269#[derive(Clone, Debug, PartialEq, Packet)]
270pub struct ClientsideLogin {
271  pub entity_id: i32,
272  pub is_hardcore: bool,
273  pub dimension_names: Vec<String>,
274  #[varint]
275  pub max_players: i32,
276  #[varint]
277  pub view_distance: i32,
278  #[varint]
279  pub simulation_distance: i32,
280  pub reduced_debug_info: bool,
281  pub enable_respawn_screen: bool,
282  #[varint]
283  pub dimension_type: i32,
284  pub dimension_name: String,
285  pub hashed_seed: i64,
286}
287
288#[derive(Clone, Debug, PartialEq, Packet)]
289pub struct ClientsideEntityPositionSync {
290  #[varint]
291  pub entity_id: i32,
292  pub position: Vector3,
293  pub velocity: Vector3,
294  pub rotation: Rotation,
295  pub on_ground: bool,
296}
297
298#[derive(Clone, Debug, PartialEq, Packet)]
299pub struct ClientsideExplosion {
300  pub position: Vector3,
301  pub radius: f32,
302  pub block_count: i32,
303  pub player_delta_velocity: Option<Vector3>,
304  #[varint]
305  pub explosion_particle_id: i32,
306}
307
308#[derive(Clone, Debug, PartialEq, Packet)]
309pub struct ClientsideUnloadChunk {
310  pub chunk_x: i32,
311  pub chunk_z: i32,
312}
313
314#[derive(Clone, Debug, PartialEq, Packet)]
315pub struct ClientsideGameEvent {
316  pub event: GameEvent,
317  pub value: f32,
318}
319
320#[derive(Clone, Debug, PartialEq, Packet)]
321pub struct ClientsideClearChat {
322  #[varint]
323  pub message_id: i32,
324  pub signature: Option<Vec<u8>>,
325}
326
327#[derive(Clone, Debug, PartialEq, Packet)]
328pub struct ClientsideLoadChunkWithLight {
329  pub chunk_x: i32,
330  pub chunk_z: i32,
331  pub chunk_data: ChunkData,
332  pub light_data: LightData,
333}
334
335#[derive(Clone, Debug, PartialEq, Packet)]
336pub struct ClientsideBlockUpdate {
337  pub block_pos: BlockPos,
338  #[varint]
339  pub new_block: i32,
340}
341
342#[derive(Clone, Debug, PartialEq, Packet)]
343pub struct ClientsideContainerSetContent {
344  #[varint]
345  pub container_id: i32,
346  #[varint]
347  pub state_id: i32,
348  pub items: Vec<Item>,
349  pub carried_item: Item,
350}
351
352#[derive(Clone, Debug, PartialEq, Packet)]
353pub struct ClientsideContainerSetSlot {
354  #[varint]
355  pub container_id: i32,
356  #[varint]
357  pub state_id: i32,
358  pub slot: i16,
359  pub item: Item,
360}
361
362#[derive(Clone, Debug, PartialEq, Packet)]
363pub struct ClientsideChunkBatchStart;
364
365#[derive(Clone, Debug, PartialEq, Packet)]
366pub struct ClientsideChunkBatchFinished {
367  #[varint]
368  pub batch_size: i32,
369}
370
371#[derive(Clone, Debug, PartialEq, Packet)]
372pub struct ClientsideLightUpdate {
373  #[varint]
374  pub chunk_x: i32,
375  #[varint]
376  pub chunk_z: i32,
377  pub light_data: LightData,
378}
379
380#[derive(Clone, Debug, PartialEq, Packet)]
381pub struct ClientsideCloseContainer {
382  #[varint]
383  pub container_id: i32,
384}
385
386#[derive(Clone, Debug, PartialEq, Packet)]
387pub struct ClientsideContainerSetData {
388  #[varint]
389  pub container_id: i32,
390  #[varint]
391  pub property: i32,
392  #[varint]
393  pub value: i32,
394}
395
396#[derive(Clone, Debug, PartialEq, Packet)]
397pub struct ServersidePong {
398  pub id: i32,
399}
400
401#[derive(Clone, Debug, PartialEq, Packet)]
402pub struct ServersidePingRequest {
403  pub timestamp: i64,
404}
405
406#[derive(Clone, Debug, PartialEq, Packet)]
407pub struct ServersideAcceptTeleportation {
408  #[varlong]
409  pub teleport_id: i64,
410}
411
412#[derive(Clone, Debug, PartialEq, Packet)]
413pub struct ServersideSwingArm {
414  pub hand: RelativeHand,
415}
416
417#[derive(Clone, Debug, PartialEq, Packet)]
418pub struct ServersideUseItem {
419  pub hand: RelativeHand,
420  #[varint]
421  pub sequence: i32,
422  pub rotation: Rotation,
423}
424
425#[derive(Clone, Debug, PartialEq, Packet)]
426pub struct ServersideMovePlayerPos {
427  pub position: Vector3,
428  pub flags: PhysicsFlags,
429}
430
431#[derive(Clone, Debug, PartialEq, Packet)]
432pub struct ServersideMovePlayerRot {
433  pub rotation: Rotation,
434  pub flags: PhysicsFlags,
435}
436
437#[derive(Clone, Debug, PartialEq, Packet)]
438pub struct ServersideMovePlayerPosRot {
439  pub position: Vector3,
440  pub rotation: Rotation,
441  pub flags: PhysicsFlags,
442}
443
444#[derive(Clone, Debug, PartialEq, Packet)]
445pub struct ServersideMovePlayerStatusOnly {
446  pub flags: PhysicsFlags,
447}
448
449#[derive(Clone, Debug, PartialEq, Packet)]
450pub struct ServersideClientCommand {
451  pub command: ClientCommand,
452}
453
454#[derive(Clone, Debug, PartialEq, Packet)]
455pub struct ServersideChatCommand {
456  pub command: String,
457}
458
459#[derive(Clone, Debug, PartialEq, Packet)]
460pub struct ServersideChatMessage {
461  pub message: String,
462  pub timestamp: i64,
463  pub salt: i64,
464  pub signature: Option<Vec<u8>>,
465  pub additional_info: AdditionalMessageInfo,
466}
467
468#[derive(Clone, Debug, PartialEq, Packet)]
469pub struct ServersideSetHeldItem {
470  pub slot: i16,
471}
472
473#[derive(Clone, Debug, PartialEq, Packet)]
474pub struct ServersideInteract {
475  #[varint]
476  pub entity: i32,
477  pub interact_type: InteractType,
478  pub target_x: Option<f32>,
479  pub target_y: Option<f32>,
480  pub target_z: Option<f32>,
481  pub hand: Option<RelativeHand>,
482  pub sneak_key_pressed: bool,
483}
484
485#[derive(Clone, Debug, PartialEq, Packet)]
486pub struct ServersidePlayerAction {
487  pub action: PlayerAction,
488  pub block_pos: BlockPos,
489  pub face: Face,
490  #[varint]
491  pub sequence: i32,
492}
493
494#[derive(Clone, Debug, PartialEq, Packet)]
495pub struct ServersidePlayerCommand {
496  #[varint]
497  pub entity_id: i32,
498  pub command: PlayerCommand,
499  #[varint]
500  pub jump_boost: i32,
501}
502
503#[derive(Clone, Debug, PartialEq, Packet)]
504pub struct ServersideResourcePackResponse {
505  pub uuid: Uuid,
506  pub state: ResourcePackState,
507}
508
509#[derive(Clone, Debug, PartialEq, Packet)]
510pub struct ServersideContainerClick {
511  #[varint]
512  pub container_id: i32,
513  #[varint]
514  pub state_id: i32,
515  pub slot: i16,
516  pub button: i8,
517  #[varint]
518  pub mode: i32,
519  pub clicked_item: Item,
520}
521
522#[derive(Clone, Debug, PartialEq, Packet)]
523pub struct ServersideContainerClose {
524  #[varint]
525  pub container_id: i32,
526}
527
528#[derive(Clone, Debug, PartialEq, Packet)]
529pub struct ServersideEditBook {
530  pub slot: i32,
531  pub pages: Vec<String>,
532  pub title: Option<String>,
533}