aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src
diff options
context:
space:
mode:
Diffstat (limited to 'azalea-protocol/src')
-rw-r--r--azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs10
-rw-r--r--azalea-protocol/src/read.rs2
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)]