aboutsummaryrefslogtreecommitdiff
path: root/azalea-entity/src
diff options
context:
space:
mode:
Diffstat (limited to 'azalea-entity/src')
-rw-r--r--azalea-entity/src/data.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/azalea-entity/src/data.rs b/azalea-entity/src/data.rs
index c9083893..ff708653 100644
--- a/azalea-entity/src/data.rs
+++ b/azalea-entity/src/data.rs
@@ -1,4 +1,4 @@
-use azalea_buf::McBufVarReadable;
+use azalea_buf::{BufReadError, McBufVarReadable};
use azalea_buf::{McBuf, McBufReadable, McBufWritable};
use azalea_chat::component::Component;
use azalea_core::{BlockPos, Direction, Particle, Slot};
@@ -17,7 +17,7 @@ pub struct EntityDataItem {
}
impl McBufReadable for EntityMetadata {
- fn read_from(buf: &mut impl Read) -> Result<Self, String> {
+ fn read_from(buf: &mut impl Read) -> Result<Self, BufReadError> {
let mut metadata = Vec::new();
loop {
let index = u8::read_from(buf)?;
@@ -70,8 +70,8 @@ pub enum EntityDataValue {
}
impl McBufReadable for EntityDataValue {
- fn read_from(buf: &mut impl Read) -> Result<Self, String> {
- let data_type = i32::var_read_from(buf)?;
+ fn read_from(buf: &mut impl Read) -> Result<Self, BufReadError> {
+ let data_type = u32::var_read_from(buf)?;
Ok(match data_type {
0 => EntityDataValue::Byte(u8::read_from(buf)?),
1 => EntityDataValue::Int(i32::var_read_from(buf)?),
@@ -110,7 +110,11 @@ impl McBufReadable for EntityDataValue {
}
}),
18 => EntityDataValue::Pose(Pose::read_from(buf)?),
- _ => return Err(format!("Unknown entity data type: {}", data_type)),
+ _ => {
+ return Err(BufReadError::UnexpectedEnumVariant {
+ id: data_type as i32,
+ })
+ }
})
}
}