aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src/packets
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-10-08 01:01:54 -0500
committermat <github@matdoes.dev>2022-10-08 01:01:54 -0500
commit4a0d5e7e96a795e3c30deb49723e4cc3d730e37c (patch)
tree7c13661d046ba21a5167f92f861dbb90a347b74b /azalea-protocol/src/packets
parent82c04004dbf37b813e1f4223d56b399c40d68e80 (diff)
downloadazalea-drasl-4a0d5e7e96a795e3c30deb49723e4cc3d730e37c.tar.xz
handle SectionBlocksUpdate packet
Diffstat (limited to 'azalea-protocol/src/packets')
-rw-r--r--azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs10
1 files changed, 7 insertions, 3 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,