Skip to main content

basalt_mc_protocol/packets/play/
entity.rs

1//! Play state — entity 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::{Position, Uuid, Vec3f, Vec3f64, Vec3i16};
8
9// -- Serverbound packets --
10
11#[derive(Debug, Clone, Default, PartialEq)]
12#[packet(id = 0x3a)]
13pub struct ServerboundPlayArmAnimation {
14    #[field(varint)]
15    pub hand: i32,
16}
17
18#[derive(Debug, Clone, Default, PartialEq)]
19#[packet(id = 0x28)]
20pub struct ServerboundPlayEntityAction {
21    #[field(varint)]
22    pub entity_id: i32,
23    #[field(varint)]
24    pub action_id: i32,
25    #[field(varint)]
26    pub jump_boost: i32,
27}
28
29#[derive(Debug, Clone, Default, PartialEq)]
30#[packet(id = 0x17)]
31pub struct ServerboundPlayQueryEntityNbt {
32    #[field(varint)]
33    pub transaction_id: i32,
34    #[field(varint)]
35    pub entity_id: i32,
36}
37
38/// Switch enum used by [`ServerboundPlayUseEntity`].
39#[derive(Debug, Clone, PartialEq, Encode, Decode, EncodedSize)]
40pub enum ServerboundPlayUseEntityMouse {
41    #[variant(id = 0)]
42    Variant0 {
43        #[field(varint)]
44        hand: i32,
45    },
46    #[variant(id = 2)]
47    Variant2 {
48        x: f32,
49        y: f32,
50        z: f32,
51        #[field(varint)]
52        hand: i32,
53    },
54}
55
56impl Default for ServerboundPlayUseEntityMouse {
57    fn default() -> Self {
58        Self::Variant0 {
59            hand: Default::default(),
60        }
61    }
62}
63#[derive(Debug, Clone, Default, PartialEq)]
64#[packet(id = 0x18)]
65pub struct ServerboundPlayUseEntity {
66    #[field(varint)]
67    pub target: i32,
68    pub mouse: ServerboundPlayUseEntityMouse,
69    pub sneaking: bool,
70}
71
72// -- Clientbound packets --
73
74#[derive(Debug, Clone, Default, PartialEq)]
75#[packet(id = 0x03)]
76pub struct ClientboundPlayAnimation {
77    #[field(varint)]
78    pub entity_id: i32,
79    pub animation: u8,
80}
81
82#[derive(Debug, Clone, Default, PartialEq)]
83#[packet(id = 0x5e)]
84pub struct ClientboundPlayAttachEntity {
85    pub entity_id: i32,
86    pub vehicle_id: i32,
87}
88
89#[derive(Debug, Clone, Default, PartialEq)]
90#[packet(id = 0x06)]
91pub struct ClientboundPlayBlockBreakAnimation {
92    #[field(varint)]
93    pub entity_id: i32,
94    pub location: Position,
95    pub destroy_stage: i8,
96}
97
98#[derive(Debug, Clone, Default, PartialEq)]
99#[packet(id = 0x76)]
100pub struct ClientboundPlayCollect {
101    #[field(varint)]
102    pub collected_entity_id: i32,
103    #[field(varint)]
104    pub collector_entity_id: i32,
105    #[field(varint)]
106    pub pickup_item_count: i32,
107}
108
109#[derive(Debug, Clone, Default, PartialEq)]
110#[packet(id = 0x1a)]
111pub struct ClientboundPlayDamageEvent {
112    #[field(varint)]
113    pub entity_id: i32,
114    #[field(varint)]
115    pub source_type_id: i32,
116    #[field(varint)]
117    pub source_cause_id: i32,
118    #[field(varint)]
119    pub source_direct_id: i32,
120    #[field(optional)]
121    pub source_position: Option<Vec3f64>,
122}
123
124#[derive(Debug, Clone, Default, PartialEq)]
125#[packet(id = 0x47)]
126pub struct ClientboundPlayEntityDestroy {
127    #[field(length = "varint", element = "varint")]
128    pub entity_ids: Vec<i32>,
129}
130
131#[derive(Debug, Clone, Default, PartialEq)]
132#[packet(id = 0x7d)]
133pub struct ClientboundPlayEntityEffect {
134    #[field(varint)]
135    pub entity_id: i32,
136    #[field(varint)]
137    pub effect_id: i32,
138    #[field(varint)]
139    pub amplifier: i32,
140    #[field(varint)]
141    pub duration: i32,
142    pub flags: u8,
143}
144
145#[derive(Debug, Clone, Default, PartialEq)]
146#[packet(id = 0x60)]
147pub struct ClientboundPlayEntityEquipment {
148    #[field(varint)]
149    pub entity_id: i32,
150    #[field(rest)]
151    pub equipments: Vec<u8>,
152}
153
154#[derive(Debug, Clone, Default, PartialEq)]
155#[packet(id = 0x4d)]
156pub struct ClientboundPlayEntityHeadRotation {
157    #[field(varint)]
158    pub entity_id: i32,
159    pub head_yaw: i8,
160}
161
162#[derive(Debug, Clone, Default, PartialEq)]
163#[packet(id = 0x32)]
164pub struct ClientboundPlayEntityLook {
165    #[field(varint)]
166    pub entity_id: i32,
167    pub yaw: i8,
168    pub pitch: i8,
169    pub on_ground: bool,
170}
171
172#[derive(Debug, Clone, Default, PartialEq)]
173#[packet(id = 0x5d)]
174pub struct ClientboundPlayEntityMetadata {
175    #[field(varint)]
176    pub entity_id: i32,
177    #[field(rest)]
178    pub metadata: Vec<u8>,
179}
180
181#[derive(Debug, Clone, Default, PartialEq)]
182#[packet(id = 0x30)]
183pub struct ClientboundPlayEntityMoveLook {
184    #[field(varint)]
185    pub entity_id: i32,
186    pub d_x: i16,
187    pub d_y: i16,
188    pub d_z: i16,
189    pub yaw: i8,
190    pub pitch: i8,
191    pub on_ground: bool,
192}
193
194#[derive(Debug, Clone, Default, PartialEq)]
195#[packet(id = 0x6e)]
196pub struct ClientboundPlayEntitySoundEffect {
197    pub sound: Vec<u8>,
198    #[field(varint)]
199    pub sound_category: i32,
200    #[field(varint)]
201    pub entity_id: i32,
202    pub volume: f32,
203    pub pitch: f32,
204    pub seed: i64,
205}
206
207#[derive(Debug, Clone, Default, PartialEq)]
208#[packet(id = 0x1f)]
209pub struct ClientboundPlayEntityStatus {
210    pub entity_id: i32,
211    pub entity_status: i8,
212}
213
214#[derive(Debug, Clone, Default, PartialEq)]
215#[packet(id = 0x77)]
216pub struct ClientboundPlayEntityTeleport {
217    #[field(varint)]
218    pub entity_id: i32,
219    pub x: f64,
220    pub y: f64,
221    pub z: f64,
222    pub yaw: i8,
223    pub pitch: i8,
224    pub on_ground: bool,
225}
226
227/// Inline data structure used by [`ClientboundPlayEntityUpdateAttributes`].
228#[derive(Debug, Clone, Default, PartialEq, Encode, Decode, EncodedSize)]
229pub struct ClientboundPlayEntityUpdateAttributesPropertiesModifiers {
230    pub uuid: String,
231    pub amount: f64,
232    pub operation: i8,
233}
234
235/// Inline data structure used by [`ClientboundPlayEntityUpdateAttributes`].
236#[derive(Debug, Clone, Default, PartialEq, Encode, Decode, EncodedSize)]
237pub struct ClientboundPlayEntityUpdateAttributesProperties {
238    #[field(varint)]
239    pub key: i32,
240    pub value: f64,
241    #[field(length = "varint")]
242    pub modifiers: Vec<ClientboundPlayEntityUpdateAttributesPropertiesModifiers>,
243}
244
245#[derive(Debug, Clone, Default, PartialEq)]
246#[packet(id = 0x7c)]
247pub struct ClientboundPlayEntityUpdateAttributes {
248    #[field(varint)]
249    pub entity_id: i32,
250    #[field(length = "varint")]
251    pub properties: Vec<ClientboundPlayEntityUpdateAttributesProperties>,
252}
253
254#[derive(Debug, Clone, Default, PartialEq)]
255#[packet(id = 0x5f)]
256pub struct ClientboundPlayEntityVelocity {
257    #[field(varint)]
258    pub entity_id: i32,
259    pub velocity: Vec3i16,
260}
261
262#[derive(Debug, Clone, Default, PartialEq)]
263#[packet(id = 0x25)]
264pub struct ClientboundPlayHurtAnimation {
265    #[field(varint)]
266    pub entity_id: i32,
267    pub yaw: f32,
268}
269
270/// Inline data structure used by [`ClientboundPlayMoveMinecart`].
271#[derive(Debug, Clone, Default, PartialEq, Encode, Decode, EncodedSize)]
272pub struct ClientboundPlayMoveMinecartSteps {
273    pub position: Vec3f,
274    pub movement: Vec3f,
275    pub yaw: f32,
276    pub pitch: f32,
277    pub weight: f32,
278}
279
280#[derive(Debug, Clone, Default, PartialEq)]
281#[packet(id = 0x31)]
282pub struct ClientboundPlayMoveMinecart {
283    #[field(varint)]
284    pub entity_id: i32,
285    #[field(length = "varint")]
286    pub steps: Vec<ClientboundPlayMoveMinecartSteps>,
287}
288
289#[derive(Debug, Clone, Default, PartialEq)]
290#[packet(id = 0x2f)]
291pub struct ClientboundPlayRelEntityMove {
292    #[field(varint)]
293    pub entity_id: i32,
294    pub d_x: i16,
295    pub d_y: i16,
296    pub d_z: i16,
297    pub on_ground: bool,
298}
299
300#[derive(Debug, Clone, Default, PartialEq)]
301#[packet(id = 0x48)]
302pub struct ClientboundPlayRemoveEntityEffect {
303    #[field(varint)]
304    pub entity_id: i32,
305    #[field(varint)]
306    pub effect_id: i32,
307}
308
309#[derive(Debug, Clone, Default, PartialEq)]
310#[packet(id = 0x65)]
311pub struct ClientboundPlaySetPassengers {
312    #[field(varint)]
313    pub entity_id: i32,
314    #[field(length = "varint", element = "varint")]
315    pub passengers: Vec<i32>,
316}
317
318#[derive(Debug, Clone, Default, PartialEq)]
319#[packet(id = 0x80)]
320pub struct ClientboundPlaySetProjectilePower {
321    #[field(varint)]
322    pub id: i32,
323    pub acceleration_power: f64,
324}
325
326#[derive(Debug, Clone, Default, PartialEq)]
327#[packet(id = 0x01)]
328pub struct ClientboundPlaySpawnEntity {
329    #[field(varint)]
330    pub entity_id: i32,
331    pub object_uuid: Uuid,
332    #[field(varint)]
333    pub r#type: i32,
334    pub x: f64,
335    pub y: f64,
336    pub z: f64,
337    pub pitch: i8,
338    pub yaw: i8,
339    pub head_pitch: i8,
340    #[field(varint)]
341    pub object_data: i32,
342    pub velocity: Vec3i16,
343}
344
345#[derive(Debug, Clone, Default, PartialEq)]
346#[packet(id = 0x02)]
347pub struct ClientboundPlaySpawnEntityExperienceOrb {
348    #[field(varint)]
349    pub entity_id: i32,
350    pub x: f64,
351    pub y: f64,
352    pub z: f64,
353    pub count: i16,
354}
355
356#[derive(Debug, Clone, Default, PartialEq)]
357#[packet(id = 0x20)]
358pub struct ClientboundPlaySyncEntityPosition {
359    #[field(varint)]
360    pub entity_id: i32,
361    pub x: f64,
362    pub y: f64,
363    pub z: f64,
364    pub dx: f64,
365    pub dy: f64,
366    pub dz: f64,
367    pub yaw: f32,
368    pub pitch: f32,
369    pub on_ground: bool,
370}