aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src/packets/game/clientbound_player_position_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/clientbound_player_position_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/clientbound_player_position_packet.rs')
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_player_position_packet.rs27
1 files changed, 14 insertions, 13 deletions
diff --git a/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs
index 03a2658e..3ad422e7 100755
--- a/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs
@@ -1,5 +1,6 @@
use azalea_buf::{BufReadError, McBuf};
use azalea_buf::{McBufReadable, McBufWritable};
+use azalea_core::FixedBitSet;
use azalea_protocol_macros::ClientboundGamePacket;
use std::io::{Cursor, Write};
@@ -29,35 +30,35 @@ pub struct RelativeArguments {
impl McBufReadable for RelativeArguments {
fn read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
- let byte = u8::read_from(buf)?;
+ let set = FixedBitSet::<5>::read_from(buf)?;
Ok(RelativeArguments {
- x: byte & 0b1 != 0,
- y: byte & 0b10 != 0,
- z: byte & 0b100 != 0,
- y_rot: byte & 0b1000 != 0,
- x_rot: byte & 0b10000 != 0,
+ x: set.index(0),
+ y: set.index(1),
+ z: set.index(2),
+ y_rot: set.index(3),
+ x_rot: set.index(4),
})
}
}
impl McBufWritable for RelativeArguments {
fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
- let mut byte = 0;
+ let mut set = FixedBitSet::<5>::new();
if self.x {
- byte |= 0b1;
+ set.set(0);
}
if self.y {
- byte |= 0b10;
+ set.set(1);
}
if self.z {
- byte |= 0b100;
+ set.set(2);
}
if self.y_rot {
- byte |= 0b1000;
+ set.set(3);
}
if self.x_rot {
- byte |= 0b10000;
+ set.set(4);
}
- u8::write_into(&byte, buf)
+ set.write_into(buf)
}
}