blob: ab1ae9a02c3200365bb01b0ef046b4a07f2f567e (
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
29
|
use crate::packets::BufReadError;
use azalea_buf::{McBufReadable, McBufWritable};
use azalea_protocol_macros::ServerboundGamePacket;
use std::io::Cursor;
#[derive(Clone, Debug, ServerboundGamePacket)]
pub struct ServerboundPlayerAbilitiesPacket {
is_flying: bool,
}
impl McBufReadable for ServerboundPlayerAbilitiesPacket {
fn read_from(buf: &mut Cursor<&[u8]>) -> 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(())
}
}
|