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