blob: 3d9cd9304fca8108c64eb5ad33f067f1d0920216 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
use crate::packets::BufReadError;
use azalea_buf::{McBufReadable, McBufWritable};
use azalea_protocol_macros::ServerboundGamePacket;
#[derive(Clone, Debug, ServerboundGamePacket)]
pub struct ServerboundPlayerAbilitiesPacket {
is_flying: bool,
}
impl McBufReadable for ServerboundPlayerAbilitiesPacket {
fn read_from(buf: &mut impl std::io::Read) -> Result<Self, BufReadError> {
let byte = u8::read_from(buf)?;
Ok(Self {
is_flying: byte & 2 != 0,
})
}
}
impl McBufWritable for ServerboundPlayerAbilitiesPacket {
fn write_into(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
let mut byte = 0;
if self.is_flying {
byte |= 2;
}
byte.write_into(buf)?;
Ok(())
}
}
|