Skip to main content

Direction

Enum Direction 

Source
pub enum Direction {
    Down,
    Up,
    North,
    South,
    West,
    East,
}
Expand description

The six cardinal directions in Minecraft.

Variants§

§

Down

Negative Y direction.

§

Up

Positive Y direction.

§

North

Negative Z direction.

§

South

Positive Z direction.

§

West

Negative X direction.

§

East

Positive X direction.

Implementations§

Source§

impl Direction

Source

pub const UPDATE_SHAPE_ORDER: [Direction; 6]

The order in which neighbor shape updates are processed. This matches vanilla’s BlockBehavior.UPDATE_SHAPE_ORDER.

Source

pub const FLOW_NEIGHBOR_CHECK: [Direction; 5]

Vanilla: LiquidBlock.POSSIBLE_FLOW_DIRECTIONS mapped through getOpposite(). Used by LiquidBlock.shouldSpreadLiquid() to check neighbors for lava-water interactions.

Source

pub const HORIZONTAL: [Direction; 4]

The 4 horizontal directions.

Source

pub const ALL: [Direction; 6]

The 6 directions.

Source

pub const fn offset(self) -> (i32, i32, i32)

Returns the block position offset for this direction.

Source

pub const fn relative(self, pos: BlockPos) -> BlockPos

Returns the block position relative to the given position in this direction.

Source

pub const fn get_axis(self) -> Axis

Returns the axis this direction is on.

Source

pub const fn opposite(self) -> Direction

Returns the opposite direction.

Source

pub fn from_yaw(yaw: f32) -> Direction

Returns the horizontal direction from a yaw rotation.

Yaw values follow Minecraft’s convention:

  • 0° = South (+Z)
  • 90° = West (-X)
  • 180° = North (-Z)
  • 270° = East (+X)
Source

pub const fn to_yaw(self) -> f32

Returns the yaw rotation for this direction.

Only meaningful for horizontal directions. Vertical directions return 0.

Source

pub const fn axis(self) -> Axis

Returns the axis this direction is on.

Source

pub const fn is_horizontal(self) -> bool

Returns whether this direction is horizontal (not up or down).

Source

pub const fn rotate_y_clockwise(self) -> Direction

Rotates this direction 90 degrees clockwise around the Y axis.

Vertical directions are unchanged.

Source

pub const fn rotate_y_counter_clockwise(self) -> Direction

Rotates this direction 90 degrees counter-clockwise around the Y axis.

Vertical directions are unchanged.

Source

pub fn ordered_by_nearest(yaw: f32, pitch: f32) -> [Direction; 6]

Returns all directions ordered by how closely they match the player’s look direction.

This matches vanilla’s Direction.orderedByNearest(Entity).

  • yaw: Player’s yaw rotation in degrees (0 = South, 90 = West, 180 = North, 270 = East)
  • pitch: Player’s pitch rotation in degrees (negative = looking up, positive = looking down)
Source

const fn make_direction_array( axis1: Direction, axis2: Direction, axis3: Direction, ) -> [Direction; 6]

Creates an array of all 6 directions ordered by magnitude.

The order is: 3 primary directions by magnitude, then their opposites in reverse order. This matches vanilla’s Direction.makeDirectionArray().

Source

pub const fn as_str(&self) -> &str

Returns the direction name as a string (for PropertyEnum compatibility).

Trait Implementations§

Source§

impl Clone for Direction

Source§

fn clone(&self) -> Direction

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 Direction

Source§

impl Debug for Direction

Source§

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

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

impl PartialEq for Direction

Source§

fn eq(&self, other: &Direction) -> 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 Direction

Source§

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

Reads data from a cursor.
Source§

impl StructuralPartialEq for Direction

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
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