diff options
Diffstat (limited to 'azalea-core/src/position.rs')
| -rwxr-xr-x | azalea-core/src/position.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/azalea-core/src/position.rs b/azalea-core/src/position.rs index cba58415..5d923d39 100755 --- a/azalea-core/src/position.rs +++ b/azalea-core/src/position.rs @@ -309,6 +309,21 @@ impl Vec3 { let z = self.z * (x_delta as f64) - self.x * (y_delta as f64); Vec3 { x, y, z } } + + pub fn to_block_pos_floor(&self) -> BlockPos { + BlockPos { + x: self.x.floor() as i32, + y: self.y.floor() as i32, + z: self.z.floor() as i32, + } + } + pub fn to_block_pos_ceil(&self) -> BlockPos { + BlockPos { + x: self.x.ceil() as i32, + y: self.y.ceil() as i32, + z: self.z.ceil() as i32, + } + } } /// The coordinates of a block in the world. For entities (if the coordinate @@ -600,6 +615,16 @@ impl From<ChunkSectionPos> for ChunkPos { ChunkPos { x: pos.x, z: pos.z } } } +impl From<&Vec3> for ChunkSectionPos { + fn from(pos: &Vec3) -> Self { + ChunkSectionPos::from(&BlockPos::from(pos)) + } +} +impl From<Vec3> for ChunkSectionPos { + fn from(pos: Vec3) -> Self { + ChunkSectionPos::from(&pos) + } +} impl From<&BlockPos> for ChunkBlockPos { #[inline] |
