1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
use std::{
io,
io::{Cursor, Write},
};
use azalea_buf::{AzBuf, BufReadError};
use azalea_core::position::BlockPos;
use azalea_protocol_macros::ServerboundGamePacket;
use azalea_registry::identifier::Identifier;
#[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)]
pub struct ServerboundSetJigsawBlock {
pub pos: BlockPos,
pub name: Identifier,
pub target: Identifier,
pub pool: Identifier,
pub final_state: String,
pub joint: String,
#[var]
pub selection_priority: i32,
#[var]
pub placement_priority: i32,
}
pub enum JointType {
Rollable,
Aligned,
}
impl AzBuf for JointType {
fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
let name = String::azalea_read(buf)?;
match name.as_str() {
"rollable" => Ok(JointType::Rollable),
"aligned" => Ok(JointType::Aligned),
_ => Err(BufReadError::UnexpectedStringEnumVariant { id: name }),
}
}
fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
match self {
JointType::Rollable => "rollable".to_owned().azalea_write(buf)?,
JointType::Aligned => "aligned".to_owned().azalea_write(buf)?,
};
Ok(())
}
}
|