diff options
| author | mat <github@matdoes.dev> | 2022-10-08 01:01:54 -0500 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2022-10-08 01:01:54 -0500 |
| commit | 4a0d5e7e96a795e3c30deb49723e4cc3d730e37c (patch) | |
| tree | 7c13661d046ba21a5167f92f861dbb90a347b74b /azalea-protocol | |
| parent | 82c04004dbf37b813e1f4223d56b399c40d68e80 (diff) | |
| download | azalea-drasl-4a0d5e7e96a795e3c30deb49723e4cc3d730e37c.tar.xz | |
handle SectionBlocksUpdate packet
Diffstat (limited to 'azalea-protocol')
| -rw-r--r-- | azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs | 10 | ||||
| -rw-r--r-- | azalea-protocol/src/read.rs | 2 |
2 files changed, 8 insertions, 4 deletions
diff --git a/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs b/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs index 357a30f6..f9b1cd1e 100644 --- a/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs @@ -1,5 +1,7 @@ -use azalea_buf::{BufReadError, McBuf}; -use azalea_buf::{McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable}; +use azalea_block::BlockState; +use azalea_buf::{ + BufReadError, McBuf, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable, +}; use azalea_core::{ChunkSectionBlockPos, ChunkSectionPos}; use azalea_protocol_macros::ClientboundGamePacket; use std::io::{Cursor, Write}; @@ -14,7 +16,7 @@ pub struct ClientboundSectionBlocksUpdatePacket { #[derive(Clone, Debug)] pub struct BlockStateWithPosition { pub pos: ChunkSectionBlockPos, - pub state: u32, + pub state: BlockState, } impl McBufReadable for BlockStateWithPosition { @@ -22,6 +24,8 @@ impl McBufReadable for BlockStateWithPosition { let data = u64::var_read_from(buf)?; let position_part = data & 4095; let state = (data >> 12) as u32; + let state = BlockState::try_from(state) + .map_err(|_| BufReadError::UnexpectedEnumVariant { id: state as i32 })?; let pos = ChunkSectionBlockPos { x: (position_part >> 8 & 15) as u8, y: (position_part & 15) as u8, diff --git a/azalea-protocol/src/read.rs b/azalea-protocol/src/read.rs index 2f0391b9..61d5d914 100644 --- a/azalea-protocol/src/read.rs +++ b/azalea-protocol/src/read.rs @@ -12,7 +12,7 @@ use std::{ io::{Cursor, Read}, }; use thiserror::Error; -use tokio::io::{AsyncRead, AsyncReadExt}; +use tokio::io::AsyncRead; use tokio_util::codec::{BytesCodec, FramedRead}; #[derive(Error, Debug)] |
