aboutsummaryrefslogtreecommitdiff
path: root/src/v1_15_2.rs
diff options
context:
space:
mode:
authorJoey Sacchini <joey@sacchini.net>2020-10-13 14:48:32 -0400
committerJoey Sacchini <joey@sacchini.net>2020-10-13 14:48:32 -0400
commit716f80ae1e6e3c817c1cd958e09216b414ca0388 (patch)
tree11287c750f57ddb01551b1e153cff79e80eba54f /src/v1_15_2.rs
parent58b0cc73e97314dba2b9b1d4c4ac9a9f924f0247 (diff)
downloadmcproto-rs-716f80ae1e6e3c817c1cd958e09216b414ca0388.tar.gz
mcproto-rs-716f80ae1e6e3c817c1cd958e09216b414ca0388.tar.bz2
mcproto-rs-716f80ae1e6e3c817c1cd958e09216b414ca0388.zip
fix stop sound
Diffstat (limited to 'src/v1_15_2.rs')
-rw-r--r--src/v1_15_2.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/v1_15_2.rs b/src/v1_15_2.rs
index 34568f9..7622018 100644
--- a/src/v1_15_2.rs
+++ b/src/v1_15_2.rs
@@ -2155,12 +2155,13 @@ pub struct StopSoundSpec {
impl Serialize for StopSoundSpec {
fn mc_serialize<S: Serializer>(&self, to: &mut S) -> SerializeResult {
+ let has_sound = self.sound.is_some();
+ let has_source = self.source.is_some();
let mut flags = 0;
- if self.sound.is_some() && self.source.is_some() {
- flags |= 0x03;
- } else if self.sound.is_some() {
+ if has_sound {
flags |= 0x02;
- } else if self.source.is_some() {
+ }
+ if has_source {
flags |= 0x01;
}
@@ -2181,9 +2182,8 @@ impl Deserialize for StopSoundSpec {
fn mc_deserialize(data: &[u8]) -> DeserializeResult<'_, Self> {
let Deserialized { value: flags, data } = u8::mc_deserialize(data)?;
- let is_both_present = flags & 0x03 != 0;
- let is_source_present = is_both_present || flags & 0x01 != 0;
- let is_sound_present = is_both_present || flags & 0x02 != 0;
+ let is_source_present = flags & 0x01 != 0;
+ let is_sound_present = flags & 0x02 != 0;
let (source, data) = if is_source_present {
let Deserialized { value: source, data } = SoundCategory::mc_deserialize(data)?;