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