Skip to main content

BlockPos

Struct BlockPos 

Source
pub struct BlockPos(pub IVec3);
Expand description

A block position.

Tuple Fields§

§0: IVec3

Implementations§

Source§

impl BlockPos

Source

pub const ZERO: BlockPos

Source

pub const MAX_HORIZONTAL_COORDINATE: i32

Maximum horizontal coordinate value: (1 << 26) / 2 - 1 = 33554431

Source

pub const fn new(x: i32, y: i32, z: i32) -> Self

Creates a new BlockPos from coordinates.

Source

pub const fn offset(&self, dx: i32, dy: i32, dz: i32) -> Self

Returns a new BlockPos offset by the given amounts.

Source

pub const fn x(&self) -> i32

Returns the x coordinate.

Source

pub const fn y(&self) -> i32

Returns the y coordinate.

Source

pub const fn z(&self) -> i32

Returns the z coordinate.

Source

pub const fn above(&self) -> Self

Returns the position one block above (Y + 1).

Source

pub const fn above_n(&self, n: i32) -> Self

Returns the position n blocks above (Y + n).

Source

pub const fn below(&self) -> Self

Returns the position one block below (Y - 1).

Source

pub const fn below_n(&self, n: i32) -> Self

Returns the position n blocks below (Y - n).

Source

pub const fn north(&self) -> Self

Returns the position one block to the north (Z - 1).

Source

pub const fn north_n(&self, n: i32) -> Self

Returns the position n blocks to the north (Z - n).

Source

pub const fn south(&self) -> Self

Returns the position one block to the south (Z + 1).

Source

pub const fn south_n(&self, n: i32) -> Self

Returns the position n blocks to the south (Z + n).

Source

pub const fn west(&self) -> Self

Returns the position one block to the west (X - 1).

Source

pub const fn west_n(&self, n: i32) -> Self

Returns the position n blocks to the west (X - n).

Source

pub const fn east(&self) -> Self

Returns the position one block to the east (X + 1).

Source

pub const fn east_n(&self, n: i32) -> Self

Returns the position n blocks to the east (X + n).

Source

pub const fn relative(self, direction: Direction) -> Self

Returns the position offset by one block in the given direction.

Source

pub const fn relative_n(&self, direction: Direction, n: i32) -> Self

Returns the position offset by n blocks in the given direction.

Source

pub const fn relative_axis(&self, axis: Axis, n: i32) -> Self

Returns the position offset by n blocks along the given axis.

Source

pub const fn at_y(&self, y: i32) -> Self

Returns a new position with the same X and Z but the given Y.

Source

pub const fn multiply(&self, factor: i32) -> Self

Returns a new position with all coordinates multiplied by the given factor.

Source

pub fn get_center(&self) -> (f64, f64, f64)

Returns the center of this block as a floating-point position.

Source

pub fn get_bottom_center(&self) -> (f64, f64, f64)

Returns the bottom center of this block (center of the bottom face).

Source

pub const fn containing(x: f64, y: f64, z: f64) -> Self

Creates a BlockPos containing the given floating-point coordinates.

Source

pub const fn min(a: BlockPos, b: BlockPos) -> Self

Returns the minimum coordinates of two positions.

Source

pub const fn max(a: BlockPos, b: BlockPos) -> Self

Returns the maximum coordinates of two positions.

Trait Implementations§

Source§

impl Clone for BlockPos

Source§

fn clone(&self) -> BlockPos

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for BlockPos

Source§

impl Debug for BlockPos

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for BlockPos

Source§

impl From<BlockPos> for PackedBlockPos

Source§

fn from(pos: BlockPos) -> Self

Converts to this type from the input type.
Source§

impl From<BlockPos> for PackedChunkLocalXZ

Source§

fn from(pos: BlockPos) -> Self

Converts to this type from the input type.
Source§

impl From<BlockPos> for PackedSectionBlockPos

Source§

fn from(pos: BlockPos) -> Self

Converts to this type from the input type.
Source§

impl From<DVec3> for BlockPos

Source§

fn from(value: DVec3) -> Self

Converts to this type from the input type.
Source§

impl From<PackedBlockPos> for BlockPos

Source§

fn from(pos: PackedBlockPos) -> Self

Converts to this type from the input type.
Source§

impl Hash for BlockPos

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for BlockPos

Source§

fn eq(&self, other: &BlockPos) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl ReadFrom for BlockPos

Source§

fn read(data: &mut Cursor<&[u8]>) -> Result<Self>

Reads data from a cursor.
Source§

impl StructuralPartialEq for BlockPos

Source§

impl WriteTo for BlockPos

Source§

fn write(&self, writer: &mut impl Write) -> Result<()>

Writes data to a writer.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more