1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 14:26:04 +00:00
azalea/azalea-protocol/src/packets/game/serverbound_set_jigsaw_block_packet.rs
mat 6eee543a33
Pathfinder (#25)
Pathfinding is very much not done, but it works enough and I want to get this merged.
TODO: fast replanning, goals that aren't a single node, falling moves (it should be able to play the dropper), parkour moves
2022-11-12 23:54:05 -06:00

45 lines
1.4 KiB
Rust
Executable file

use crate::packets::BufReadError;
use crate::packets::McBufWritable;
use azalea_buf::McBuf;
use azalea_buf::McBufReadable;
use azalea_core::BlockPos;
use azalea_core::ResourceLocation;
use azalea_protocol_macros::ServerboundGamePacket;
use std::io::Cursor;
use std::io::Write;
#[derive(Clone, Debug, McBuf, ServerboundGamePacket)]
pub struct ServerboundSetJigsawBlockPacket {
pub pos: BlockPos,
pub name: ResourceLocation,
pub target: ResourceLocation,
pub pool: ResourceLocation,
pub final_state: String,
pub joint: String, // TODO: Does JigsawBlockEntity$JointType::getSerializedName, may not be implemented
}
pub enum JointType {
Rollable,
Aligned,
}
impl McBufReadable for JointType {
fn read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
let name = String::read_from(buf)?;
match name.as_str() {
"rollable" => Ok(JointType::Rollable),
"aligned" => Ok(JointType::Aligned),
_ => Err(BufReadError::UnexpectedStringEnumVariant { id: name }),
}
}
}
impl McBufWritable for JointType {
fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
match self {
JointType::Rollable => "rollable".to_string().write_into(buf)?,
JointType::Aligned => "aligned".to_string().write_into(buf)?,
};
Ok(())
}
}