nurtex_protocol/types/
player_hand.rs1use nurtex_codec::Buffer;
2use nurtex_codec::types::variable::VarI32;
3
4#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
6pub enum AccurateHand {
7 Left,
8 Right,
9}
10
11impl Buffer for AccurateHand {
12 fn read_buf(buffer: &mut std::io::Cursor<&[u8]>) -> Option<Self> {
13 let id = i32::read_var(buffer)?;
14
15 match id {
16 0 => Some(Self::Left),
17 1 => Some(Self::Right),
18 _ => None,
19 }
20 }
21
22 fn write_buf(&self, buffer: &mut impl std::io::Write) -> std::io::Result<()> {
23 let id = match self {
24 Self::Left => 0,
25 Self::Right => 1,
26 };
27
28 id.write_var(buffer)?;
29
30 Ok(())
31 }
32}
33
34#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
36pub enum RelativeHand {
37 MainHand,
38 OffHand,
39}
40
41impl Buffer for RelativeHand {
42 fn read_buf(buffer: &mut std::io::Cursor<&[u8]>) -> Option<Self> {
43 let id = i32::read_var(buffer)?;
44
45 match id {
46 0 => Some(Self::MainHand),
47 1 => Some(Self::OffHand),
48 _ => None,
49 }
50 }
51
52 fn write_buf(&self, buffer: &mut impl std::io::Write) -> std::io::Result<()> {
53 let id = match self {
54 Self::MainHand => 0,
55 Self::OffHand => 1,
56 };
57
58 id.write_var(buffer)?;
59
60 Ok(())
61 }
62}