Add NamedSoundEffect

This commit is contained in:
timvisee 2021-11-14 15:34:21 +01:00
parent bef4fa8c00
commit d26a525c7b
No known key found for this signature in database
GPG Key ID: B8DB720BC383E172

View File

@ -29,6 +29,7 @@ pub enum GameClientBoundPacket {
EntityAction(EntityAction), EntityAction(EntityAction),
PluginMessage(PluginMessage), PluginMessage(PluginMessage),
NamedSoundEffect(NamedSoundEffect),
Respawn(Respawn), Respawn(Respawn),
PlayerPositionAndLook(PlayerPositionAndLook), PlayerPositionAndLook(PlayerPositionAndLook),
SpawnPosition(SpawnPosition), SpawnPosition(SpawnPosition),
@ -80,6 +81,7 @@ impl GameClientBoundPacket {
match self { match self {
GameClientBoundPacket::ClientBoundChatMessage(_) => 0x0E, GameClientBoundPacket::ClientBoundChatMessage(_) => 0x0E,
GameClientBoundPacket::PluginMessage(_) => 0x18, GameClientBoundPacket::PluginMessage(_) => 0x18,
GameClientBoundPacket::NamedSoundEffect(_) => 0x19,
GameClientBoundPacket::GameDisconnect(_) => 0x1A, GameClientBoundPacket::GameDisconnect(_) => 0x1A,
GameClientBoundPacket::ClientBoundKeepAlive(_) => 0x20, GameClientBoundPacket::ClientBoundKeepAlive(_) => 0x20,
GameClientBoundPacket::ChunkData(_) => 0x21, GameClientBoundPacket::ChunkData(_) => 0x21,
@ -108,6 +110,11 @@ impl GameClientBoundPacket {
Ok(GameClientBoundPacket::PluginMessage(plugin_message)) Ok(GameClientBoundPacket::PluginMessage(plugin_message))
} }
0x19 => {
let named_sound_effect = NamedSoundEffect::decode(reader)?;
Ok(GameClientBoundPacket::NamedSoundEffect(named_sound_effect))
}
0x1A => { 0x1A => {
let game_disconnect = GameDisconnect::decode(reader)?; let game_disconnect = GameDisconnect::decode(reader)?;
@ -178,6 +185,24 @@ pub struct PluginMessage {
pub data: Vec<u8>, pub data: Vec<u8>,
} }
// TODO(timvisee): implement new()
// TODO(timvisee): remove clone?
#[derive(Clone, Encoder, Decoder, Debug)]
pub struct NamedSoundEffect {
#[data_type(max_length = 32767)]
pub sound_name: String,
#[data_type(with = "var_int")]
pub sound_category: i32,
// Mulitplied by 8
pub effect_pos_x: i32,
// Mulitplied by 8
pub effect_pos_y: i32,
// Mulitplied by 8
pub effect_pos_z: i32,
pub volume: f32,
pub pitch: f32,
}
// TODO(timvisee): implement new() // TODO(timvisee): implement new()
// TODO(timvisee): remove clone? // TODO(timvisee): remove clone?
#[derive(Clone, Encoder, Decoder, Debug)] #[derive(Clone, Encoder, Decoder, Debug)]