diff options
| author | EightFactorial <murphkev000@gmail.com> | 2023-01-30 16:18:14 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-30 18:18:14 -0600 |
| commit | 6e818852d868eea963dd2b8489ba75b65c56fb1c (patch) | |
| tree | e786e919de7d4a1777d91e8e2fa890482970972d /azalea-protocol/src/packets/game/clientbound_boss_event_packet.rs | |
| parent | 2539f948c7a88a86b27b1878f6c28976285f348c (diff) | |
| download | azalea-drasl-6e818852d868eea963dd2b8489ba75b65c56fb1c.tar.xz | |
More packet fixes, tests, handle error (#61)
* Fix packet, fix tests, fixedbitsets
* Clippy: Nightmare Mode
* Fix mistake
* simplify impl Display and make thing pub
---------
Co-authored-by: mat <github@matdoes.dev>
Diffstat (limited to 'azalea-protocol/src/packets/game/clientbound_boss_event_packet.rs')
| -rwxr-xr-x | azalea-protocol/src/packets/game/clientbound_boss_event_packet.rs | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/azalea-protocol/src/packets/game/clientbound_boss_event_packet.rs b/azalea-protocol/src/packets/game/clientbound_boss_event_packet.rs index 59378d3e..3ffbaea1 100755 --- a/azalea-protocol/src/packets/game/clientbound_boss_event_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_boss_event_packet.rs @@ -2,6 +2,7 @@ use azalea_buf::{ BufReadError, McBuf, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable, }; use azalea_chat::Component; +use azalea_core::FixedBitSet; use azalea_protocol_macros::ClientboundGamePacket; use std::io::Cursor; use std::io::Write; @@ -116,28 +117,28 @@ pub struct Properties { impl McBufReadable for Properties { fn read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> { - let byte = u8::read_from(buf)?; + let set = FixedBitSet::<3>::read_from(buf)?; Ok(Self { - darken_screen: byte & 1 != 0, - play_music: byte & 2 != 0, - create_world_fog: byte & 4 != 0, + darken_screen: set.index(0), + play_music: set.index(1), + create_world_fog: set.index(2), }) } } impl McBufWritable for Properties { fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { - let mut byte = 0; + let mut set = FixedBitSet::<3>::new(); if self.darken_screen { - byte |= 1; + set.set(0); } if self.play_music { - byte |= 2; + set.set(1); } if self.create_world_fog { - byte |= 4; + set.set(2); } - u8::write_into(&byte, buf)?; + set.write_into(buf)?; Ok(()) } } |
