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
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]
The 4 horizontal directions.
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 relative(self, pos: BlockPos) -> BlockPos
pub const 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 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)