aboutsummaryrefslogtreecommitdiff
path: root/azalea-core/src/position.rs
diff options
context:
space:
mode:
Diffstat (limited to 'azalea-core/src/position.rs')
-rwxr-xr-xazalea-core/src/position.rs14
1 files changed, 12 insertions, 2 deletions
diff --git a/azalea-core/src/position.rs b/azalea-core/src/position.rs
index ea54c60c..d04f58cc 100755
--- a/azalea-core/src/position.rs
+++ b/azalea-core/src/position.rs
@@ -1,5 +1,5 @@
use crate::ResourceLocation;
-use azalea_buf::{BufReadError, McBufReadable, McBufWritable};
+use azalea_buf::{BufReadError, McBuf, McBufReadable, McBufWritable};
use std::{
io::{Cursor, Write},
ops::{Add, AddAssign, Mul, Rem, Sub},
@@ -109,7 +109,7 @@ macro_rules! vec3_impl {
};
}
-#[derive(Clone, Copy, Debug, Default, PartialEq)]
+#[derive(Clone, Copy, Debug, Default, PartialEq, McBuf)]
pub struct Vec3 {
pub x: f64,
pub y: f64,
@@ -270,12 +270,22 @@ impl From<&Vec3> for BlockPos {
}
}
}
+impl From<Vec3> for BlockPos {
+ fn from(pos: Vec3) -> Self {
+ BlockPos::from(&pos)
+ }
+}
impl From<&Vec3> for ChunkPos {
fn from(pos: &Vec3) -> Self {
ChunkPos::from(&BlockPos::from(pos))
}
}
+impl From<Vec3> for ChunkPos {
+ fn from(pos: Vec3) -> Self {
+ ChunkPos::from(&pos)
+ }
+}
const PACKED_X_LENGTH: u64 = 1 + 25; // minecraft does something a bit more complicated to get this 25
const PACKED_Z_LENGTH: u64 = PACKED_X_LENGTH;