diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2025-12-09 13:29:59 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-09 13:29:59 -0600 |
| commit | 26d619c9a329087a23d6577ee74bd764f50cd773 (patch) | |
| tree | 8020fe902257764a23a445c6ed9987ea4848189d /azalea-core/src/position.rs | |
| parent | 84cd261118c9d1e3145d4d1751c0d22098cd8cd8 (diff) | |
| download | azalea-drasl-26d619c9a329087a23d6577ee74bd764f50cd773.tar.xz | |
Enchantments (#286)
* start implementing enchants
* store parsed registries
* more work on enchants
* implement deserializer for some entity effects
* mostly working definitions for enchants
* fix tests
* detect equipment changes
* fix errors
* update changelog
* fix some imports
* remove outdated todo
* add basic test for enchants applying attributes
* use git simdnbt
Diffstat (limited to 'azalea-core/src/position.rs')
| -rw-r--r-- | azalea-core/src/position.rs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/azalea-core/src/position.rs b/azalea-core/src/position.rs index 03ea49ec..7cd86a03 100644 --- a/azalea-core/src/position.rs +++ b/azalea-core/src/position.rs @@ -14,7 +14,7 @@ use std::{ use azalea_buf::{AzBuf, AzaleaRead, AzaleaWrite, BufReadError}; use serde::{Serialize, Serializer}; -use simdnbt::Deserialize; +use simdnbt::borrow::NbtTag; use crate::{codec_utils::IntArray, direction::Direction, identifier::Identifier, math}; @@ -311,6 +311,13 @@ pub struct Vec3 { pub z: f64, } 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 }) + } +} impl Vec3 { /// Get the distance of this vector to the origin by doing @@ -489,6 +496,13 @@ pub struct Vec3i { pub z: i32, } vec3_impl!(Vec3i, i32); +impl simdnbt::FromNbtTag for Vec3i { + fn from_nbt_tag(tag: NbtTag) -> Option<Self> { + let pos = tag.list()?.ints()?; + let [x, y, z] = <[i32; 3]>::try_from(pos).ok()?; + Some(Self { x, y, z }) + } +} /// Chunk coordinates are used to represent where a chunk is in the world. /// @@ -876,7 +890,7 @@ impl fmt::Display for Vec3 { } /// A 2D vector. -#[derive(Clone, Copy, Debug, Default, PartialEq, AzBuf, Deserialize, Serialize)] +#[derive(Clone, Copy, Debug, Default, PartialEq, AzBuf, simdnbt::Deserialize, Serialize)] pub struct Vec2 { pub x: f32, pub y: f32, |
