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 { 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(()) } }