aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src/packets
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2024-01-08 00:12:54 -0600
committermat <git@matdoes.dev>2024-01-08 00:12:54 -0600
commitcfbfdd77b4a400ef3bace378ff413aa2ff3bf57c (patch)
tree2d5fc56e4b2fbccb27b0a07c14002cf4c5eefaa0 /azalea-protocol/src/packets
parent0aa439d5caa8028b6d310de45258cbcef16ca2eb (diff)
downloadazalea-drasl-cfbfdd77b4a400ef3bace378ff413aa2ff3bf57c.tar.xz
fix ping packet, explosion packet, and panic less
Diffstat (limited to 'azalea-protocol/src/packets')
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_explode_packet.rs21
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_ping_packet.rs1
2 files changed, 17 insertions, 5 deletions
diff --git a/azalea-protocol/src/packets/game/clientbound_explode_packet.rs b/azalea-protocol/src/packets/game/clientbound_explode_packet.rs
index ae39135a..58e61e2e 100755
--- a/azalea-protocol/src/packets/game/clientbound_explode_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_explode_packet.rs
@@ -1,9 +1,12 @@
-use std::io::{Cursor, Write};
+use std::{
+ io::{Cursor, Write},
+ str::FromStr,
+};
use azalea_buf::{
BufReadError, McBuf, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable,
};
-use azalea_core::position::BlockPos;
+use azalea_core::{position::BlockPos, resource_location::ResourceLocation};
use azalea_protocol_macros::ClientboundGamePacket;
use azalea_registry::{ParticleKind, SoundEvent};
@@ -59,7 +62,14 @@ impl McBufReadable for ClientboundExplodePacket {
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)?;
+
+ let sound_event_resource_location = ResourceLocation::read_from(buf)?.to_string();
+ let explosion_sound =
+ SoundEvent::from_str(&sound_event_resource_location).map_err(|_| {
+ BufReadError::UnexpectedStringEnumVariant {
+ id: sound_event_resource_location,
+ }
+ })?;
Ok(Self {
x,
@@ -108,7 +118,10 @@ impl McBufWritable for ClientboundExplodePacket {
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)?;
+
+ let sound_event_resource_location =
+ ResourceLocation::new(&self.explosion_sound.to_string());
+ sound_event_resource_location.write_into(buf)?;
Ok(())
}
diff --git a/azalea-protocol/src/packets/game/clientbound_ping_packet.rs b/azalea-protocol/src/packets/game/clientbound_ping_packet.rs
index 82de4fab..0bd2c8c3 100755
--- a/azalea-protocol/src/packets/game/clientbound_ping_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_ping_packet.rs
@@ -3,6 +3,5 @@ use azalea_protocol_macros::ClientboundGamePacket;
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
pub struct ClientboundPingPacket {
- #[var]
pub id: u32,
}