chunkedge_protocol/packets/play/
level_particles_s2c.rs

1use chunkedge_binary::{Decode, Encode, VarInt};
2use chunkedge_generated::block::BlockState;
3use chunkedge_item::ItemStack;
4use chunkedge_math::{DVec3, Vec3};
5
6use crate::{BlockPos, Packet};
7
8#[derive(Clone, Debug, Packet, Encode, Decode)]
9pub struct LevelParticlesS2c {
10    pub long_distance: bool,
11    pub always_visible: bool,
12    pub position: DVec3,
13    pub offset: Vec3,
14    pub max_speed: f32,
15    pub count: i32,
16    pub particle: Particle,
17}
18
19#[derive(Clone, PartialEq, Debug, Encode, Decode)]
20pub enum Particle {
21    // TODO: Move to registry?
22    AngryVillager,
23    Block(BlockState),
24    BlockMarker(BlockState),
25    Bubble,
26    Cloud,
27    Crit,
28    DamageIndicator,
29    DragonBreath,
30    DrippingLava,
31    FallingLava,
32    LandingLava,
33    DrippingWater,
34    FallingWater,
35    Dust {
36        /// The color, encoded as 0xRRGGBB; top bits are ignored.
37        color: i32,
38        //// The scale, will be clamped between 0.01 and 4.
39        scale: f32,
40    },
41    DustColorTransition {
42        /// The color to transition from, encoded as 0xRRGGBB; top bits are
43        /// ignored.
44        from_color: i32,
45        /// The color to transition from, encoded as 0xRRGGBB; top bits are
46        /// ignored.
47        to_color: i32,
48        /// The scale, will be clamped between 0.01 and 4.
49        scale: f32,
50    },
51    Effect,
52    ElderGuardian,
53    EnchantedHit,
54    Enchant,
55    EndRod,
56    EntityEffect {
57        /// The ARGB components of the color encoded as an Int
58        color: i32,
59    },
60    ExplosionEmitter,
61    Explosion,
62    Gust,
63    SmallGust,
64    GustEmitterLarge,
65    GustEmitterSmall,
66    SonicBoom,
67    FallingDust(BlockState),
68    Firework,
69    Fishing,
70    Flame,
71    Infested,
72    CherryLeaves,
73    PaleOakLeaves,
74    TintedLeaves {
75        /// The ARGB components of the color encoded as an Int
76        color: i32,
77    },
78    SculkSoul,
79    SculkCharge {
80        /// How much the particle will be rotated when displayed.
81        roll: f32,
82    },
83    SculkChargePop,
84    SoulFireFlame,
85    Soul,
86    Flash,
87    HappyVillager,
88    Composter,
89    Heart,
90    InstantEffect,
91    /// If the item is air or its count is 0, the client might crash.
92    Item(Box<ItemStack>),
93    Vibration {
94        /// The type of the vibration source defined by the
95        /// `minecraft:position_source_type` builtin registry.
96        source: VibrationSourceType,
97        /// The amount of ticks it takes for the vibration to travel from its
98        /// source to its destination.
99        ticks: VarInt,
100    },
101    Trail {
102        position: DVec3,
103        /// The trail color, encoded as 0xRRGGBB; top bits are ignored.
104        color: i32,
105        /// Life time in ticks
106        duration: VarInt,
107    },
108    ItemSlime,
109    ItemCobweb,
110    ItemSnowball,
111    LargeSmoke,
112    Lava,
113    Mycelium,
114    Note,
115    Poof,
116    Portal,
117    Rain,
118    Smoke,
119    WhiteSmoke,
120    Sneeze,
121    Spit,
122    SquidInk,
123    SweepAttack,
124    TotemOfUndying,
125    Underwater,
126    Splash,
127    Witch,
128    BubblePop,
129    CurrentDown,
130    BubbleColumnUp,
131    Nautilus,
132    Dolphin,
133    CampfireCosySmoke,
134    CampfireSignalSmoke,
135    DrippingHoney,
136    FallingHoney,
137    LandingHoney,
138    FallingNectar,
139    FallingSporeBlossom,
140    Ash,
141    CrimsonSpore,
142    WarpedSpore,
143    SporeBlossomAir,
144    DrippingObsidianTear,
145    FallingObsidianTear,
146    LandingObsidianTear,
147    ReversePortal,
148    WhiteAsh,
149    SmallFlame,
150    Snowflake,
151    DrippingDripstoneLava,
152    FallingDripstoneLava,
153    DrippingDripstoneWater,
154    FallingDripstoneWater,
155    GlowSquidInk,
156    Glow,
157    WaxOn,
158    WaxOff,
159    ElectricSpark,
160    Scrape,
161    Shriek {
162        /// The time in ticks before the particle is displayed
163        delay: VarInt,
164    },
165    EggCrack,
166    DustPlume,
167    TrialSpawnerDetection,
168    TrialSpawnerDetectionOminous,
169    VaultConnection,
170    DustPillar(BlockState),
171    OminousSpawning,
172    RaidOmen,
173    TrialOmen,
174    BlockCrumble(BlockState),
175    Firefly,
176}
177
178#[derive(Clone, PartialEq, Debug, Encode, Decode)]
179pub enum VibrationSourceType {
180    Block {
181        /// The position of the block the vibration originated from.
182        block_pos: BlockPos,
183    },
184    Entity {
185        /// The ID of the entity the vibration originated from.
186        ///
187        /// See `EntityId`.
188        id: VarInt,
189        /// Entity eye height.
190        eye_height: f32,
191    },
192}
193
194impl Particle {
195    pub const fn id(&self) -> i32 {
196        match self {
197            Particle::AngryVillager => 0,
198            Particle::Block(_) => 1,
199            Particle::BlockMarker(_) => 2,
200            Particle::Bubble => 3,
201            Particle::Cloud => 4,
202            Particle::Crit => 5,
203            Particle::DamageIndicator => 6,
204            Particle::DragonBreath => 7,
205            Particle::DrippingLava => 8,
206            Particle::FallingLava => 9,
207            Particle::LandingLava => 10,
208            Particle::DrippingWater => 11,
209            Particle::FallingWater => 12,
210            Particle::Dust { .. } => 13,
211            Particle::DustColorTransition { .. } => 14,
212            Particle::Effect => 15,
213            Particle::ElderGuardian => 16,
214            Particle::EnchantedHit => 17,
215            Particle::Enchant => 18,
216            Particle::EndRod => 19,
217            Particle::EntityEffect { .. } => 20,
218            Particle::ExplosionEmitter => 21,
219            Particle::Explosion => 22,
220            Particle::Gust => 23,
221            Particle::SmallGust => 24,
222            Particle::GustEmitterLarge => 25,
223            Particle::GustEmitterSmall => 26,
224            Particle::SonicBoom => 27,
225            Particle::FallingDust(_) => 28,
226            Particle::Firework => 29,
227            Particle::Fishing => 30,
228            Particle::Flame => 31,
229            Particle::Infested => 32,
230            Particle::CherryLeaves => 33,
231            Particle::PaleOakLeaves => 34,
232            Particle::TintedLeaves { .. } => 35,
233            Particle::SculkSoul => 36,
234            Particle::SculkCharge { .. } => 37,
235            Particle::SculkChargePop => 38,
236            Particle::SoulFireFlame => 39,
237            Particle::Soul => 40,
238            Particle::Flash => 41,
239            Particle::HappyVillager => 42,
240            Particle::Composter => 43,
241            Particle::Heart => 44,
242            Particle::InstantEffect => 45,
243            Particle::Item(..) => 46,
244            Particle::Vibration { .. } => 47,
245            Particle::Trail { .. } => 48,
246            Particle::ItemSlime => 49,
247            Particle::ItemCobweb => 50,
248            Particle::ItemSnowball => 51,
249            Particle::LargeSmoke => 52,
250            Particle::Lava => 53,
251            Particle::Mycelium => 54,
252            Particle::Note => 55,
253            Particle::Poof => 56,
254            Particle::Portal => 57,
255            Particle::Rain => 58,
256            Particle::Smoke => 59,
257            Particle::WhiteSmoke => 60,
258            Particle::Sneeze => 61,
259            Particle::Spit => 62,
260            Particle::SquidInk => 63,
261            Particle::SweepAttack => 64,
262            Particle::TotemOfUndying => 65,
263            Particle::Underwater => 66,
264            Particle::Splash => 67,
265            Particle::Witch => 68,
266            Particle::BubblePop => 69,
267            Particle::CurrentDown => 70,
268            Particle::BubbleColumnUp => 71,
269            Particle::Nautilus => 72,
270            Particle::Dolphin => 73,
271            Particle::CampfireCosySmoke => 74,
272            Particle::CampfireSignalSmoke => 75,
273            Particle::DrippingHoney => 76,
274            Particle::FallingHoney => 77,
275            Particle::LandingHoney => 78,
276            Particle::FallingNectar => 79,
277            Particle::FallingSporeBlossom => 80,
278            Particle::Ash => 81,
279            Particle::CrimsonSpore => 82,
280            Particle::WarpedSpore => 83,
281            Particle::SporeBlossomAir => 84,
282            Particle::DrippingObsidianTear => 85,
283            Particle::FallingObsidianTear => 86,
284            Particle::LandingObsidianTear => 87,
285            Particle::ReversePortal => 88,
286            Particle::WhiteAsh => 89,
287            Particle::SmallFlame => 90,
288            Particle::Snowflake => 91,
289            Particle::DrippingDripstoneLava => 92,
290            Particle::FallingDripstoneLava => 93,
291            Particle::DrippingDripstoneWater => 94,
292            Particle::FallingDripstoneWater => 95,
293            Particle::GlowSquidInk => 96,
294            Particle::Glow => 97,
295            Particle::WaxOn => 98,
296            Particle::WaxOff => 99,
297            Particle::ElectricSpark => 100,
298            Particle::Scrape => 101,
299            Particle::Shriek { .. } => 102,
300            Particle::EggCrack => 103,
301            Particle::DustPlume => 104,
302            Particle::TrialSpawnerDetection => 105,
303            Particle::TrialSpawnerDetectionOminous => 106,
304            Particle::VaultConnection => 107,
305            Particle::DustPillar(_) => 108,
306            Particle::OminousSpawning => 109,
307            Particle::RaidOmen => 110,
308            Particle::TrialOmen => 111,
309            Particle::BlockCrumble(_) => 112,
310            Particle::Firefly => 113,
311        }
312    }
313}