azalea_protocol/packets/game/
s_player_abilities.rs1use std::io::{self, Cursor, Write};
2
3use azalea_buf::{AzaleaRead, AzaleaWrite};
4use azalea_core::bitset::FixedBitSet;
5use azalea_protocol_macros::ServerboundGamePacket;
6
7use crate::packets::BufReadError;
8
9#[derive(Clone, Debug, ServerboundGamePacket)]
10pub struct ServerboundPlayerAbilities {
11 pub is_flying: bool,
12}
13
14impl AzaleaRead for ServerboundPlayerAbilities {
15 fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
16 let set = FixedBitSet::<2>::azalea_read(buf)?;
17 Ok(Self {
18 is_flying: set.index(1),
19 })
20 }
21}
22
23impl AzaleaWrite for ServerboundPlayerAbilities {
24 fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
25 let mut set = FixedBitSet::<2>::new();
26 if self.is_flying {
27 set.set(1);
28 }
29 set.azalea_write(buf)
30 }
31}