pub struct BlockLocation {
pub x: i32,
pub y: i16,
pub z: i32,
}
Expand description
A block location stored by (x,z) = i32, y = i16. y is signed to preserve compatibility with 1.17, where the world height can be much higher and goes to negative values.
Fields§
§x: i32
§y: i16
§z: i32
Implementations§
Source§impl BlockLocation
impl BlockLocation
pub fn new(x: i32, y: i16, z: i32) -> BlockLocation
pub fn faces(self) -> [Location; 6]
pub fn below(&self) -> BlockLocation
pub fn above(&self) -> BlockLocation
pub fn get(&self, idx: usize) -> i32
pub fn set(&mut self, idx: usize, value: i32)
pub fn from_flts(x: impl Float, y: impl Float, z: impl Float) -> BlockLocation
pub fn add_y(&self, dy: i16) -> BlockLocation
pub fn center_bottom(&self) -> Location
pub fn true_center(&self) -> Location
Source§impl BlockLocation
impl BlockLocation
pub fn dist2(&self, other: BlockLocation) -> f64
pub fn abs_dif(&self, other: BlockLocation) -> (u32, u16, u32)
pub fn manhatten(&self, other: BlockLocation) -> u64
pub fn dist(&self, other: BlockLocation) -> f64
Trait Implementations§
Source§impl Add for BlockLocation
impl Add for BlockLocation
Source§impl Clone for BlockLocation
impl Clone for BlockLocation
Source§fn clone(&self) -> BlockLocation
fn clone(&self) -> BlockLocation
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for BlockLocation
impl Debug for BlockLocation
Source§impl Default for BlockLocation
impl Default for BlockLocation
Source§fn default() -> BlockLocation
fn default() -> BlockLocation
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for BlockLocation
impl<'de> Deserialize<'de> for BlockLocation
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for BlockLocation
impl Display for BlockLocation
Source§impl From<BlockLocation> for BlockLocation2D
impl From<BlockLocation> for BlockLocation2D
Source§fn from(loc: BlockLocation) -> Self
fn from(loc: BlockLocation) -> Self
Converts to this type from the input type.
Source§impl From<BlockLocation> for ChunkLocation
impl From<BlockLocation> for ChunkLocation
Source§fn from(loc: BlockLocation) -> Self
fn from(loc: BlockLocation) -> Self
Converts to this type from the input type.
Source§impl From<BlockLocation2D> for BlockLocation
impl From<BlockLocation2D> for BlockLocation
Source§fn from(loc: BlockLocation2D) -> Self
fn from(loc: BlockLocation2D) -> Self
Converts to this type from the input type.
Source§impl From<Change> for BlockLocation
impl From<Change> for BlockLocation
Source§impl From<Location> for BlockLocation
impl From<Location> for BlockLocation
Source§impl Hash for BlockLocation
impl Hash for BlockLocation
Source§impl Ord for BlockLocation
impl Ord for BlockLocation
Source§fn cmp(&self, other: &BlockLocation) -> Ordering
fn cmp(&self, other: &BlockLocation) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for BlockLocation
impl PartialEq for BlockLocation
Source§impl PartialOrd for BlockLocation
impl PartialOrd for BlockLocation
Source§impl Serialize for BlockLocation
impl Serialize for BlockLocation
impl Copy for BlockLocation
impl Eq for BlockLocation
impl StructuralPartialEq for BlockLocation
Auto Trait Implementations§
impl Freeze for BlockLocation
impl RefUnwindSafe for BlockLocation
impl Send for BlockLocation
impl Sync for BlockLocation
impl Unpin for BlockLocation
impl UnwindSafe for BlockLocation
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more