Files
Pumpkin/pumpkin-protocol/src/bedrock/server/interaction.rs
unschlagbar 2e2236bf3b Bedrock player joining (#1063)
Co-authored-by: unschlagbar <adrian@kuhlmann@gmx.de>
Co-authored-by: Alexander Medvedev <lilalexmed@proton.me>
Co-authored-by: unschlagbar <adrian@kuhlmann@gmx.de>
2025-07-26 17:31:00 +02:00

42 lines
937 B
Rust

use std::io::{Error, Read};
use pumpkin_macros::packet;
use crate::{codec::var_ulong::VarULong, serial::PacketRead};
#[derive(Debug, PacketRead)]
#[packet(33)]
pub struct SInteraction {
// https://mojang.github.io/bedrock-protocol-docs/html/InteractPacket.html
pub action: Action,
pub target_runtime_id: VarULong,
}
#[derive(Debug)]
#[repr(i8)]
pub enum Action {
Invalid = 0,
StopRiding = 3,
InteractUpdate = 4,
NpcOpen = 5,
OpenInventory = 6,
}
impl PacketRead for Action {
fn read<R: Read>(reader: &mut R) -> Result<Self, Error> {
let mut byte = [0];
reader.read_exact(&mut byte)?;
let this = match byte[0] {
0 => Self::Invalid,
3 => Self::StopRiding,
4 => Self::InteractUpdate,
5 => Self::NpcOpen,
6 => Self::OpenInventory,
_ => return Err(Error::other("")),
};
Ok(this)
}
}