aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-06-26 12:32:01 +0930
committermat <git@matdoes.dev>2025-06-26 10:05:58 +0700
commitf9e4b65713bbacabcd54416a388a92b90f56ab47 (patch)
tree25d392d60836351311e9f498d40277c226c1e32c /azalea-protocol
parentaf1ef9310093aa3c8dfd5054eb6d0b8c7c0d0b31 (diff)
downloadazalea-drasl-f9e4b65713bbacabcd54416a388a92b90f56ab47.tar.xz
start adding packet_order test
Diffstat (limited to 'azalea-protocol')
-rw-r--r--azalea-protocol/src/common/movements.rs30
-rw-r--r--azalea-protocol/src/packets/game/s_move_player_pos.rs4
-rw-r--r--azalea-protocol/src/packets/game/s_move_player_pos_rot.rs4
-rw-r--r--azalea-protocol/src/packets/game/s_move_player_rot.rs4
-rw-r--r--azalea-protocol/src/packets/game/s_move_player_status_only.rs4
5 files changed, 42 insertions, 4 deletions
diff --git a/azalea-protocol/src/common/movements.rs b/azalea-protocol/src/common/movements.rs
index a70342b3..e88fb87e 100644
--- a/azalea-protocol/src/common/movements.rs
+++ b/azalea-protocol/src/common/movements.rs
@@ -131,3 +131,33 @@ impl AzaleaWrite for RelativeMovements {
set.azalea_write(buf)
}
}
+
+#[derive(Clone, Copy, Debug, Default)]
+pub struct MoveFlags {
+ pub on_ground: bool,
+ pub horizontal_collision: bool,
+}
+impl AzaleaWrite for MoveFlags {
+ fn azalea_write(&self, buf: &mut impl io::Write) -> Result<(), io::Error> {
+ let mut bitset = FixedBitSet::<8>::new();
+ if self.on_ground {
+ bitset.set(0);
+ }
+ if self.horizontal_collision {
+ bitset.set(1);
+ }
+ bitset.azalea_write(buf)?;
+ Ok(())
+ }
+}
+impl AzaleaRead for MoveFlags {
+ fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
+ let bitset = FixedBitSet::<8>::azalea_read(buf)?;
+ let on_ground = bitset.index(0);
+ let horizontal_collision = bitset.index(1);
+ Ok(Self {
+ on_ground,
+ horizontal_collision,
+ })
+ }
+}
diff --git a/azalea-protocol/src/packets/game/s_move_player_pos.rs b/azalea-protocol/src/packets/game/s_move_player_pos.rs
index 2daf1d42..fd1f4a9f 100644
--- a/azalea-protocol/src/packets/game/s_move_player_pos.rs
+++ b/azalea-protocol/src/packets/game/s_move_player_pos.rs
@@ -2,8 +2,10 @@ use azalea_buf::AzBuf;
use azalea_core::position::Vec3;
use azalea_protocol_macros::ServerboundGamePacket;
+use crate::common::movements::MoveFlags;
+
#[derive(Clone, Debug, AzBuf, ServerboundGamePacket)]
pub struct ServerboundMovePlayerPos {
pub pos: Vec3,
- pub on_ground: bool,
+ pub flags: MoveFlags,
}
diff --git a/azalea-protocol/src/packets/game/s_move_player_pos_rot.rs b/azalea-protocol/src/packets/game/s_move_player_pos_rot.rs
index 3460c709..feee0137 100644
--- a/azalea-protocol/src/packets/game/s_move_player_pos_rot.rs
+++ b/azalea-protocol/src/packets/game/s_move_player_pos_rot.rs
@@ -3,9 +3,11 @@ use azalea_core::position::Vec3;
use azalea_entity::LookDirection;
use azalea_protocol_macros::ServerboundGamePacket;
+use crate::common::movements::MoveFlags;
+
#[derive(Clone, Debug, AzBuf, ServerboundGamePacket)]
pub struct ServerboundMovePlayerPosRot {
pub pos: Vec3,
pub look_direction: LookDirection,
- pub on_ground: bool,
+ pub flags: MoveFlags,
}
diff --git a/azalea-protocol/src/packets/game/s_move_player_rot.rs b/azalea-protocol/src/packets/game/s_move_player_rot.rs
index 6aef91b0..d158af8c 100644
--- a/azalea-protocol/src/packets/game/s_move_player_rot.rs
+++ b/azalea-protocol/src/packets/game/s_move_player_rot.rs
@@ -2,8 +2,10 @@ use azalea_buf::AzBuf;
use azalea_entity::LookDirection;
use azalea_protocol_macros::ServerboundGamePacket;
+use crate::common::movements::MoveFlags;
+
#[derive(Clone, Debug, AzBuf, ServerboundGamePacket)]
pub struct ServerboundMovePlayerRot {
pub look_direction: LookDirection,
- pub on_ground: bool,
+ pub flags: MoveFlags,
}
diff --git a/azalea-protocol/src/packets/game/s_move_player_status_only.rs b/azalea-protocol/src/packets/game/s_move_player_status_only.rs
index 155841f0..162b6b0e 100644
--- a/azalea-protocol/src/packets/game/s_move_player_status_only.rs
+++ b/azalea-protocol/src/packets/game/s_move_player_status_only.rs
@@ -1,7 +1,9 @@
use azalea_buf::AzBuf;
use azalea_protocol_macros::ServerboundGamePacket;
+use crate::common::movements::MoveFlags;
+
#[derive(Clone, Debug, AzBuf, ServerboundGamePacket)]
pub struct ServerboundMovePlayerStatusOnly {
- pub on_ground: bool,
+ pub flags: MoveFlags,
}