diff options
| author | mat <git@matdoes.dev> | 2024-12-05 06:30:47 +0000 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2024-12-05 06:30:47 +0000 |
| commit | 39f4d68e1ff1f0fa0d45663335d83299d5d37790 (patch) | |
| tree | ac61d7bf437a1874c91d5c794b732dc599f86259 /azalea-protocol/src/packets/game/c_player_position.rs | |
| parent | 6379035b852f1b619565d27f5cee3b93042c2312 (diff) | |
| download | azalea-drasl-39f4d68e1ff1f0fa0d45663335d83299d5d37790.tar.xz | |
fix container_set_content, player_position, and recipe_book_remove packets
Diffstat (limited to 'azalea-protocol/src/packets/game/c_player_position.rs')
| -rwxr-xr-x | azalea-protocol/src/packets/game/c_player_position.rs | 53 |
1 files changed, 35 insertions, 18 deletions
diff --git a/azalea-protocol/src/packets/game/c_player_position.rs b/azalea-protocol/src/packets/game/c_player_position.rs index aa030fc5..e742df22 100755 --- a/azalea-protocol/src/packets/game/c_player_position.rs +++ b/azalea-protocol/src/packets/game/c_player_position.rs @@ -8,11 +8,19 @@ use azalea_protocol_macros::ClientboundGamePacket; pub struct ClientboundPlayerPosition { #[var] pub id: u32, + pub change: PositionMoveRotation, + pub relative: RelativeMovements, +} + +/// These values are either absolute or relative, depending on the fields from +/// the [`RelativeMovements`]. +#[derive(Clone, Debug, AzBuf)] +pub struct PositionMoveRotation { pub pos: Vec3, - pub delta_movement: Vec3, + /// The updated delta movement (velocity). + pub delta: Vec3, pub y_rot: f32, pub x_rot: f32, - pub relative_arguments: RelativeMovements, } #[derive(Debug, Clone)] @@ -22,6 +30,10 @@ pub struct RelativeMovements { pub z: bool, pub y_rot: bool, pub x_rot: bool, + pub delta_x: bool, + pub delta_y: bool, + pub delta_z: bool, + pub rotate_delta: bool, } impl AzaleaRead for RelativeMovements { @@ -34,28 +46,33 @@ impl AzaleaRead for RelativeMovements { z: set.index(2), y_rot: set.index(3), x_rot: set.index(4), + delta_x: set.index(5), + delta_y: set.index(6), + delta_z: set.index(7), + rotate_delta: set.index(8), }) } } impl AzaleaWrite for RelativeMovements { fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { - let mut set = FixedBitSet::<5>::new(); - if self.x { - set.set(0); - } - if self.y { - set.set(1); - } - if self.z { - set.set(2); - } - if self.y_rot { - set.set(3); - } - if self.x_rot { - set.set(4); - } + let mut set = FixedBitSet::<32>::new(); + let mut set_bit = |index: usize, value: bool| { + if value { + set.set(index); + } + }; + + set_bit(0, self.x); + set_bit(1, self.y); + set_bit(2, self.z); + set_bit(3, self.y_rot); + set_bit(4, self.x_rot); + set_bit(5, self.delta_x); + set_bit(6, self.delta_y); + set_bit(7, self.delta_z); + set_bit(8, self.rotate_delta); + set.azalea_write(buf) } } |
