diff options
Diffstat (limited to 'azalea-protocol/src/packets/game/clientbound_explode_packet.rs')
| -rwxr-xr-x | azalea-protocol/src/packets/game/clientbound_explode_packet.rs | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/azalea-protocol/src/packets/game/clientbound_explode_packet.rs b/azalea-protocol/src/packets/game/clientbound_explode_packet.rs index 720f06a4..ae39135a 100755 --- a/azalea-protocol/src/packets/game/clientbound_explode_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_explode_packet.rs @@ -1,8 +1,11 @@ use std::io::{Cursor, Write}; -use azalea_buf::{BufReadError, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable}; +use azalea_buf::{ + BufReadError, McBuf, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable, +}; use azalea_core::position::BlockPos; use azalea_protocol_macros::ClientboundGamePacket; +use azalea_registry::{ParticleKind, SoundEvent}; #[derive(Clone, Debug, PartialEq, ClientboundGamePacket)] pub struct ClientboundExplodePacket { @@ -14,6 +17,18 @@ pub struct ClientboundExplodePacket { pub knockback_x: f32, pub knockback_y: f32, pub knockback_z: f32, + pub block_interaction: BlockInteraction, + pub small_explosion_particles: ParticleKind, + pub large_explosion_particles: ParticleKind, + pub explosion_sound: SoundEvent, +} + +#[derive(Clone, Copy, Debug, PartialEq, McBuf)] +pub enum BlockInteraction { + Keep, + Destroy, + DestroyWithDecay, + TriggerBlock, } impl McBufReadable for ClientboundExplodePacket { @@ -41,6 +56,11 @@ impl McBufReadable for ClientboundExplodePacket { let knockback_y = f32::read_from(buf)?; let knockback_z = f32::read_from(buf)?; + let block_interaction = BlockInteraction::read_from(buf)?; + let small_explosion_particles = ParticleKind::read_from(buf)?; + let large_explosion_particles = ParticleKind::read_from(buf)?; + let explosion_sound = SoundEvent::read_from(buf)?; + Ok(Self { x, y, @@ -50,6 +70,10 @@ impl McBufReadable for ClientboundExplodePacket { knockback_x, knockback_y, knockback_z, + block_interaction, + small_explosion_particles, + large_explosion_particles, + explosion_sound, }) } } @@ -80,6 +104,12 @@ impl McBufWritable for ClientboundExplodePacket { self.knockback_x.write_into(buf)?; self.knockback_y.write_into(buf)?; self.knockback_z.write_into(buf)?; + + self.block_interaction.write_into(buf)?; + self.small_explosion_particles.write_into(buf)?; + self.large_explosion_particles.write_into(buf)?; + self.explosion_sound.write_into(buf)?; + Ok(()) } } @@ -110,6 +140,10 @@ mod tests { knockback_x: 1_000.0, knockback_y: 2_000.0, knockback_z: 3_000.0, + block_interaction: BlockInteraction::Destroy, + small_explosion_particles: ParticleKind::Explosion, + large_explosion_particles: ParticleKind::ExplosionEmitter, + explosion_sound: SoundEvent::EntityGenericExplode, }; let mut buf = Vec::new(); packet.write_into(&mut buf).unwrap(); |
