Skip to main content

azalea_protocol/packets/game/
c_level_particles.rs

1use azalea_buf::AzBuf;
2use azalea_core::position::Vec3;
3use azalea_protocol_macros::ClientboundGamePacket;
4use azalea_registry::registry_holder::particle::Particle;
5
6#[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)]
7pub struct ClientboundLevelParticles {
8    pub particle: Particle,
9    pub override_limiter: bool,
10    pub always_show: bool,
11    pub pos: Vec3,
12    pub x_dist: f32,
13    pub y_dist: f32,
14    pub z_dist: f32,
15    pub x_max_speed: f32,
16    pub y_max_speed: f32,
17    pub z_max_speed: f32,
18    #[var]
19    pub count: u32,
20    pub randomization_kind: RandomizationKind,
21}
22
23#[derive(AzBuf, Clone, Copy, Debug, PartialEq)]
24pub enum RandomizationKind {
25    Default,
26    Alternative,
27    AlternativeWithSpeed,
28}
29
30#[cfg(test)]
31mod tests {
32    use std::io::Cursor;
33
34    use azalea_buf::AzBuf;
35
36    use super::*;
37
38    #[test]
39    fn test_read_hypixel_particles() {
40        tracing_subscriber::fmt()
41            .with_max_level(tracing::Level::TRACE)
42            .init();
43
44        #[rustfmt::skip]
45        let contents = [21, 255, 128, 0, 128, 63, 128, 0, 0, 1, 1, 192, 56, 174, 132, 32, 0, 0, 0, 64, 80, 245, 194, 128, 0, 0, 0, 192, 14, 21, 162, 192, 0, 0, 0, 63, 0, 128, 129, 0, 0, 0, 0, 63, 0, 128, 129, 63, 128, 0, 0, 63, 128, 0, 0, 63, 128, 0, 0, 0, 0];
46        let mut buf: Cursor<&[u8]> = Cursor::new(contents.as_slice());
47        let packet = ClientboundLevelParticles::azalea_read(Default::default(), &mut buf).unwrap();
48        println!("{packet:?}");
49
50        assert_eq!(buf.position(), contents.len() as u64);
51    }
52}