Struct azalea_core::position::BlockPos
source · pub struct BlockPos {
pub x: i32,
pub y: i32,
pub z: i32,
}
Expand description
The coordinates of a block in the world. For entities (if the coordinate
with decimals), use Vec3
instead.
Fields§
§x: i32
§y: i32
§z: i32
Implementations§
source§impl BlockPos
impl BlockPos
pub fn new(x: i32, y: i32, z: i32) -> Self
sourcepub fn length_sqr(&self) -> i32
pub fn length_sqr(&self) -> i32
Get the distance of this vector to the origin by doing x^2 + y^2 + z^2
.
sourcepub fn distance_to_sqr(&self, other: &Self) -> i32
pub fn distance_to_sqr(&self, other: &Self) -> i32
Get the squared distance from this position to another position.
Equivalent to (self - other).length_sqr()
.
pub fn horizontal_distance_sqr(&self) -> i32
pub fn horizontal_distance_to_sqr(&self, other: &Self) -> i32
sourcepub fn down(&self, y: i32) -> Self
pub fn down(&self, y: i32) -> Self
Return a new instance of this position with the y coordinate decreased by the given number.
sourcepub fn up(&self, y: i32) -> Self
pub fn up(&self, y: i32) -> Self
Return a new instance of this position with the y coordinate increased by the given number.
sourcepub fn north(&self, z: i32) -> Self
pub fn north(&self, z: i32) -> Self
Return a new instance of this position with the z coordinate subtracted by the given number.
sourcepub fn east(&self, x: i32) -> Self
pub fn east(&self, x: i32) -> Self
Return a new instance of this position with the x coordinate increased by the given number.
sourcepub fn south(&self, z: i32) -> Self
pub fn south(&self, z: i32) -> Self
Return a new instance of this position with the z coordinate increased by the given number.
sourcepub fn west(&self, x: i32) -> Self
pub fn west(&self, x: i32) -> Self
Return a new instance of this position with the x coordinate subtracted by the given number.
pub fn dot(&self, other: Self) -> i32
source§impl BlockPos
impl BlockPos
sourcepub fn center(&self) -> Vec3
pub fn center(&self) -> Vec3
Get the absolute center of a block position by adding 0.5 to each coordinate.
sourcepub fn to_vec3_floored(&self) -> Vec3
pub fn to_vec3_floored(&self) -> Vec3
Convert the block position into a Vec3 without centering it.
sourcepub fn length_manhattan(&self) -> u32
pub fn length_manhattan(&self) -> u32
Get the distance of this vector from the origin by doing x + y + z
.
Trait Implementations§
source§impl AddAssign for BlockPos
impl AddAssign for BlockPos
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+=
operation. Read more