aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src/packets
diff options
context:
space:
mode:
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,