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