azalea_protocol/packets/game/
s_player_abilities.rs1use std::io::{self, Cursor, Write};
2
3use azalea_buf::AzBuf;
4use azalea_core::bitset::FixedBitSet;
5use azalea_protocol_macros::ServerboundGamePacket;
6
7use crate::packets::BufReadError;
8
9#[derive(Clone, Debug, PartialEq, ServerboundGamePacket)]
10pub struct ServerboundPlayerAbilities {
11 pub is_flying: bool,
12}
13
14impl AzBuf 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 fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
22 let mut set = FixedBitSet::<2>::new();
23 if self.is_flying {
24 set.set(1);
25 }
26 set.azalea_write(buf)
27 }
28}