diff options
| author | mat <git@matdoes.dev> | 2025-12-18 13:15:23 -1400 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-12-18 13:15:23 -1400 |
| commit | edd9ac93ec6abef4e57c6de828ee59b13da8d58f (patch) | |
| tree | 343d10bc7ef60549d3c478f814d0332dfddc8ba3 /azalea-core/src | |
| parent | 4bd67cb6a7bf0dc24c4ca2e4bed0a6fdac2b44ce (diff) | |
| download | azalea-drasl-edd9ac93ec6abef4e57c6de828ee59b13da8d58f.tar.xz | |
fix warning when Vec3 codec is represented as floats
Diffstat (limited to 'azalea-core/src')
| -rw-r--r-- | azalea-core/src/position.rs | 14 | ||||
| -rw-r--r-- | azalea-core/src/registry_holder/entity_effect.rs | 7 |
2 files changed, 17 insertions, 4 deletions
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<Self> { - 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<Self, DeserializeError> { 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 } } |
