pub(in worldgen::feature) 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
impl Direction
Sourcepub const UPDATE_SHAPE_ORDER: [Direction; 6]
pub const UPDATE_SHAPE_ORDER: [Direction; 6]
The order in which neighbor shape updates are processed.
This matches vanilla’s BlockBehavior.UPDATE_SHAPE_ORDER.
Sourcepub const FLOW_NEIGHBOR_CHECK: [Direction; 5]
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.
Sourcepub const HORIZONTAL: [Direction; 4]
pub const HORIZONTAL: [Direction; 4]
Vanilla Direction.Plane.HORIZONTAL order.
Sourcepub const fn offset(self) -> (i32, i32, i32)
pub const fn offset(self) -> (i32, i32, i32)
Returns the block position offset for this direction.
Sourcepub const fn offset_xz(self) -> (i32, i32)
pub const fn offset_xz(self) -> (i32, i32)
Returns the XZ offset for this direction, treating the vertical directions as no movement.
For Down and Up the result is (0, 0).
Sourcepub const fn offset_vec(self) -> IVec3
pub const fn offset_vec(self) -> IVec3
Returns the block position offset for this direction as an IVec3.
Sourcepub fn relative(self, pos: BlockPos) -> BlockPos
pub fn relative(self, pos: BlockPos) -> BlockPos
Returns the block position relative to the given position in this direction.
Sourcepub fn from_yaw(yaw: f32) -> Direction
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)
Sourcepub const fn to_yaw(self) -> f32
pub const fn to_yaw(self) -> f32
Returns the yaw rotation for this direction.
Only meaningful for horizontal directions. Vertical directions return 0.
Sourcepub const fn positive_for_axis(axis: Axis) -> Direction
pub const fn positive_for_axis(axis: Axis) -> Direction
Returns vanilla Direction.get(AxisDirection.POSITIVE, axis).
Sourcepub const fn is_horizontal(self) -> bool
pub const fn is_horizontal(self) -> bool
Returns whether this direction is horizontal (not up or down).
Sourcepub const fn rotate_y_clockwise(self) -> Direction
pub const fn rotate_y_clockwise(self) -> Direction
Rotates this direction 90 degrees clockwise around the Y axis.
Vertical directions are unchanged.
Sourcepub const fn rotate_y_counter_clockwise(self) -> Direction
pub const fn rotate_y_counter_clockwise(self) -> Direction
Rotates this direction 90 degrees counter-clockwise around the Y axis.
Vertical directions are unchanged.
Sourcepub fn ordered_by_nearest(yaw: f32, pitch: f32) -> [Direction; 6]
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)
Trait Implementations§
impl Copy for Direction
impl StructuralPartialEq for Direction
Auto Trait Implementations§
impl Freeze for Direction
impl RefUnwindSafe for Direction
impl Send for Direction
impl Sync for Direction
impl Unpin for Direction
impl UnsafeUnpin for Direction
impl UnwindSafe for Direction
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
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> ⓘ
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> ⓘ
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 moreArc<SyncMutex<>>