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