aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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)?;