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 dbb2092ac0
Implement ALL packets (#16)
* add a couple more packets and improve codegen

* enums in packet codegen

* fix enums and MORE PACKETS

* make unsigned numbers the default

* codegen can make hashmaps

* UnsizedByteArray in codegen

* Vec and Option

* enum codgen works in more situations

* ServerboundInteractPacket

* Fix error with new error system

* More packets

* more packets

* more packets

* guess what was added

* yeah it's more packets

* add more packets

* packets

* start adding ClientboundBossEventPacket

* finish boss event packet

* improve codegen for linux

* start on command suggestions packet

* rename declare_commands to commands

* más paquetes

* fix generating custom payload packet

* more packets

* mehr Pakete

* improve codegen for movement packets

* rename move packets to have "packet" at the end

* fix some unused variable warns

* addere plus facis

* pli da pakoj

* plus de paquets

* più pacchetti

* make ChatFormatting a macro in azalea-chat

* change a match to matches! macro

* update SetPlayerTeam to use ChatFormatting

* ClientboundSetScorePacket & fix clippy warnings

* finish game state 🎉

* add remaining packets for other states

* fix error in ping.rs
2022-08-20 15:17:07 -05:00

44 lines
1.3 KiB
Rust

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 packet_macros::ServerboundGamePacket;
use std::io::{Read, 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 impl Read) -> 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(())
}
}