Struct azalea_core::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()
.
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.
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<BlockPos> for BlockPos
impl AddAssign<BlockPos> for BlockPos
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+=
operation. Read moresource§impl From<&BlockPos> for ChunkBlockPos
impl From<&BlockPos> for ChunkBlockPos
source§impl From<&BlockPos> for ChunkSectionBlockPos
impl From<&BlockPos> for ChunkSectionBlockPos
source§impl From<BlockPos> for ChunkSectionPos
impl From<BlockPos> for ChunkSectionPos
source§impl McBufReadable for BlockPos
impl McBufReadable for BlockPos
source§impl McBufWritable for BlockPos
impl McBufWritable for BlockPos
source§impl PartialEq<BlockPos> for BlockPos
impl PartialEq<BlockPos> for BlockPos
impl Copy for BlockPos
impl Eq for BlockPos
impl StructuralEq for BlockPos
impl StructuralPartialEq for BlockPos
Auto Trait Implementations§
impl RefUnwindSafe for BlockPos
impl Send for BlockPos
impl Sync for BlockPos
impl Unpin for BlockPos
impl UnwindSafe for BlockPos
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more