aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src/packets/game/serverbound_player_abilities_packet.rs
diff options
context:
space:
mode:
authorEightFactorial <murphkev000@gmail.com>2023-01-30 16:18:14 -0800
committerGitHub <noreply@github.com>2023-01-30 18:18:14 -0600
commit6e818852d868eea963dd2b8489ba75b65c56fb1c (patch)
treee786e919de7d4a1777d91e8e2fa890482970972d /azalea-protocol/src/packets/game/serverbound_player_abilities_packet.rs
parent2539f948c7a88a86b27b1878f6c28976285f348c (diff)
downloadazalea-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/serverbound_player_abilities_packet.rs')
-rwxr-xr-xazalea-protocol/src/packets/game/serverbound_player_abilities_packet.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/azalea-protocol/src/packets/game/serverbound_player_abilities_packet.rs b/azalea-protocol/src/packets/game/serverbound_player_abilities_packet.rs
index 7f979363..1f8727ac 100755
--- a/azalea-protocol/src/packets/game/serverbound_player_abilities_packet.rs
+++ b/azalea-protocol/src/packets/game/serverbound_player_abilities_packet.rs
@@ -1,29 +1,29 @@
use crate::packets::BufReadError;
use azalea_buf::{McBufReadable, McBufWritable};
+use azalea_core::FixedBitSet;
use azalea_protocol_macros::ServerboundGamePacket;
use std::io::Cursor;
#[derive(Clone, Debug, ServerboundGamePacket)]
pub struct ServerboundPlayerAbilitiesPacket {
- is_flying: bool,
+ pub is_flying: bool,
}
impl McBufReadable for ServerboundPlayerAbilitiesPacket {
fn read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
- let byte = u8::read_from(buf)?;
+ let set = FixedBitSet::<2>::read_from(buf)?;
Ok(Self {
- is_flying: byte & 2 != 0,
+ is_flying: set.index(1),
})
}
}
impl McBufWritable for ServerboundPlayerAbilitiesPacket {
fn write_into(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
- let mut byte = 0;
+ let mut set = FixedBitSet::<2>::new();
if self.is_flying {
- byte |= 2;
+ set.set(1);
}
- u8::write_into(&byte, buf)?;
- Ok(())
+ set.write_into(buf)
}
}