1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 14:26:04 +00:00
azalea/azalea-protocol/src/packets/game/serverbound_player_abilities_packet.rs
mat 6eee543a33
Pathfinder (#25)
Pathfinding is very much not done, but it works enough and I want to get this merged.
TODO: fast replanning, goals that aren't a single node, falling moves (it should be able to play the dropper), parkour moves
2022-11-12 23:54:05 -06:00

29 lines
807 B
Rust
Executable file

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(())
}
}