From edd9ac93ec6abef4e57c6de828ee59b13da8d58f Mon Sep 17 00:00:00 2001 From: mat Date: Thu, 18 Dec 2025 13:15:23 -1400 Subject: fix warning when Vec3 codec is represented as floats --- azalea-core/src/position.rs | 14 +++++++++++--- azalea-core/src/registry_holder/entity_effect.rs | 7 ++++++- 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'azalea-core/src') diff --git a/azalea-core/src/position.rs b/azalea-core/src/position.rs index cdf4b1b9..80b189ce 100644 --- a/azalea-core/src/position.rs +++ b/azalea-core/src/position.rs @@ -314,9 +314,17 @@ pub struct Vec3 { vec3_impl!(Vec3, f64); impl simdnbt::FromNbtTag for Vec3 { fn from_nbt_tag(tag: NbtTag) -> Option { - let pos = tag.list()?.doubles()?; - let [x, y, z] = <[f64; 3]>::try_from(pos).ok()?; - Some(Self { x, y, z }) + let pos = tag.list()?; + if let Some(pos) = pos.doubles() { + let [x, y, z] = <[f64; 3]>::try_from(pos).ok()?; + Some(Self { x, y, z }) + } else if let Some(pos) = pos.floats() { + // used on hypixel + let [x, y, z] = <[f32; 3]>::try_from(pos).ok()?.map(|f| f as f64); + Some(Self { x, y, z }) + } else { + None + } } } diff --git a/azalea-core/src/registry_holder/entity_effect.rs b/azalea-core/src/registry_holder/entity_effect.rs index 4cb914e3..00efde21 100644 --- a/azalea-core/src/registry_holder/entity_effect.rs +++ b/azalea-core/src/registry_holder/entity_effect.rs @@ -12,6 +12,7 @@ use simdnbt::{ Deserialize, DeserializeError, borrow::{NbtCompound, NbtTag}, }; +use tracing::error; use crate::{ position::{Vec3, Vec3i}, @@ -44,7 +45,7 @@ pub enum EntityEffect { impl Deserialize for EntityEffect { fn from_compound(nbt: NbtCompound) -> Result { let kind = get_in_compound(&nbt, "type")?; - match kind { + let res = match kind { EntityEffectKind::AllOf => Deserialize::from_compound(nbt).map(Self::AllOf), EntityEffectKind::ApplyMobEffect => { Deserialize::from_compound(nbt).map(Self::ApplyMobEffect) @@ -78,7 +79,11 @@ impl Deserialize for EntityEffect { EntityEffectKind::SummonEntity => { Deserialize::from_compound(nbt).map(Self::SummonEntity) } + }; + if res.is_err() { + error!("Error deserializing EntityEffect {kind}: {nbt:?}"); } + res } } -- cgit v1.2.3