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/position.rs | |
| parent | 4bd67cb6a7bf0dc24c4ca2e4bed0a6fdac2b44ce (diff) | |
| download | azalea-drasl-edd9ac93ec6abef4e57c6de828ee59b13da8d58f.tar.xz | |
fix warning when Vec3 codec is represented as floats
Diffstat (limited to 'azalea-core/src/position.rs')
| -rw-r--r-- | azalea-core/src/position.rs | 14 |
1 files changed, 11 insertions, 3 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 + } } } |
