aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src/packets/game/serverbound_player_input_packet.rs
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2024-10-23 00:08:13 -0500
committerGitHub <noreply@github.com>2024-10-23 00:08:13 -0500
commit40e4096d2435533eacb817ad5a5e12c7ced8fa5c (patch)
tree937c4024bb7f69b19b6d053e02a9e5b3b02d98aa /azalea-protocol/src/packets/game/serverbound_player_input_packet.rs
parentabc7b43b8c641b6dc4b107bb9624b86235bd36db (diff)
downloadazalea-drasl-40e4096d2435533eacb817ad5a5e12c7ced8fa5c.tar.xz
1.21.2 (#171)
* partially implement 24w35a * start updating to 24w39a + itemcomponent codegen * fix codegen and broken packets to finish updating to 24w39a :D * update to 1.21.2 except for blocks * update ServerboundPlayerInputPacket impl
Diffstat (limited to 'azalea-protocol/src/packets/game/serverbound_player_input_packet.rs')
-rwxr-xr-xazalea-protocol/src/packets/game/serverbound_player_input_packet.rs49
1 files changed, 33 insertions, 16 deletions
diff --git a/azalea-protocol/src/packets/game/serverbound_player_input_packet.rs b/azalea-protocol/src/packets/game/serverbound_player_input_packet.rs
index db6e51a9..a461ddf5 100755
--- a/azalea-protocol/src/packets/game/serverbound_player_input_packet.rs
+++ b/azalea-protocol/src/packets/game/serverbound_player_input_packet.rs
@@ -7,37 +7,54 @@ use azalea_protocol_macros::ServerboundGamePacket;
#[derive(Clone, Debug, ServerboundGamePacket)]
pub struct ServerboundPlayerInputPacket {
- pub xxa: f32,
- pub zza: f32,
- pub is_jumping: bool,
- pub is_shift_key_down: bool,
+ pub forward: bool,
+ pub backward: bool,
+ pub left: bool,
+ pub right: bool,
+ pub jump: bool,
+ pub shift: bool,
+ pub sprint: bool,
}
impl McBufReadable for ServerboundPlayerInputPacket {
fn read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
- let xxa = f32::read_from(buf)?;
- let zza = f32::read_from(buf)?;
- let set = FixedBitSet::<2>::read_from(buf)?;
+ let set = FixedBitSet::<7>::read_from(buf)?;
Ok(Self {
- xxa,
- zza,
- is_jumping: set.index(0),
- is_shift_key_down: set.index(1),
+ forward: set.index(0),
+ backward: set.index(1),
+ left: set.index(2),
+ right: set.index(3),
+ jump: set.index(4),
+ shift: set.index(5),
+ sprint: set.index(6),
})
}
}
impl McBufWritable for ServerboundPlayerInputPacket {
fn write_into(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
- self.xxa.write_into(buf)?;
- self.zza.write_into(buf)?;
- let mut set = FixedBitSet::<2>::new();
- if self.is_jumping {
+ let mut set = FixedBitSet::<7>::new();
+ if self.forward {
set.set(0);
}
- if self.is_shift_key_down {
+ if self.backward {
set.set(1);
}
+ if self.left {
+ set.set(2);
+ }
+ if self.right {
+ set.set(3);
+ }
+ if self.jump {
+ set.set(4);
+ }
+ if self.shift {
+ set.set(5);
+ }
+ if self.sprint {
+ set.set(6);
+ }
set.write_into(buf)
}
}