Enum Class Direction

java.lang.Object
java.lang.Enum<Direction>
net.minecraft.core.Direction
All Implemented Interfaces:
Serializable, Comparable<Direction>, Constable, StringRepresentable

public enum Direction extends Enum<Direction> implements StringRepresentable
  • Enum Constant Details

  • Field Details

    • CODEC

      public static final StringRepresentable.EnumCodec<Direction> CODEC
    • VERTICAL_CODEC

      public static final com.mojang.serialization.Codec<Direction> VERTICAL_CODEC
    • BY_ID

      public static final IntFunction<Direction> BY_ID
    • STREAM_CODEC

      public static final StreamCodec<io.netty.buffer.ByteBuf, Direction> STREAM_CODEC
    • LEGACY_ID_CODEC

      @Deprecated public static final com.mojang.serialization.Codec<Direction> LEGACY_ID_CODEC
      Deprecated.
    • LEGACY_ID_CODEC_2D

      @Deprecated public static final com.mojang.serialization.Codec<Direction> LEGACY_ID_CODEC_2D
      Deprecated.
    • YXZ_AXIS_ORDER

      private static final ImmutableList<Direction.Axis> YXZ_AXIS_ORDER
    • YZX_AXIS_ORDER

      private static final ImmutableList<Direction.Axis> YZX_AXIS_ORDER
    • data3d

      private final int data3d
      Ordering index for D-U-N-S-W-E
    • oppositeIndex

      private final int oppositeIndex
      Index of the opposite Direction in the VALUES array
    • data2d

      private final int data2d
      Ordering index for the HORIZONTALS field (S-W-N-E)
    • name

      private final String name
    • axis

      private final Direction.Axis axis
    • axisDirection

      private final Direction.AxisDirection axisDirection
    • normal

      private final Vec3i normal
      Normalized vector that points in the direction of this Direction
    • normalVec3

      private final Vec3 normalVec3
    • normalVec3f

      private final Vector3fc normalVec3f
    • VALUES

      private static final Direction[] VALUES
    • BY_3D_DATA

      private static final Direction[] BY_3D_DATA
    • BY_2D_DATA

      private static final Direction[] BY_2D_DATA
      All Facings with horizontal axis in order S-W-N-E
  • Constructor Details

  • Method Details

    • values

      public static Direction[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Direction valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • orderedByNearest

      public static Direction[] orderedByNearest(Entity entity)
      Gets the Direction values for the provided entity's looking direction. Dependent on yaw and pitch of entity looking.
    • makeDirectionArray

      private static Direction[] makeDirectionArray(Direction axis1, Direction axis2, Direction axis3)
    • rotate

      public static Direction rotate(Matrix4fc matrix, Direction facing)
    • allShuffled

      public static Collection<Direction> allShuffled(RandomSource random)
    • stream

      public static Stream<Direction> stream()
    • getYRot

      public static float getYRot(Direction direction)
    • getRotation

      public Quaternionf getRotation()
    • get3DDataValue

      public int get3DDataValue()
    • get2DDataValue

      public int get2DDataValue()
    • getAxisDirection

      public Direction.AxisDirection getAxisDirection()
    • getFacingAxis

      public static Direction getFacingAxis(Entity entity, Direction.Axis axis)
    • getOpposite

      public Direction getOpposite()
    • getClockWise

      public Direction getClockWise(Direction.Axis axis)
    • getCounterClockWise

      public Direction getCounterClockWise(Direction.Axis axis)
    • getClockWise

      public Direction getClockWise()
    • getClockWiseX

      private Direction getClockWiseX()
    • getCounterClockWiseX

      private Direction getCounterClockWiseX()
    • getClockWiseZ

      private Direction getClockWiseZ()
    • getCounterClockWiseZ

      private Direction getCounterClockWiseZ()
    • getCounterClockWise

      public Direction getCounterClockWise()
    • getStepX

      public int getStepX()
    • getStepY

      public int getStepY()
    • getStepZ

      public int getStepZ()
    • step

      public Vector3f step()
    • getName

      public String getName()
    • getAxis

      public Direction.Axis getAxis()
    • byName

      public static @Nullable Direction byName(String name)
      Returns:
      the Direction specified by the given name or null if no such Direction exists
    • from3DDataValue

      public static Direction from3DDataValue(int data)
      Returns:
      the Direction corresponding to the given index (0-5). Out of bounds values are wrapped around. The order is D-U-N-S-W-E.
      See Also:
    • from2DDataValue

      public static Direction from2DDataValue(int data)
      Returns:
      the Direction corresponding to the given horizontal index (0-3). Out of bounds values are wrapped around. The order is S-W-N-E.
      See Also:
    • fromYRot

      public static Direction fromYRot(double yRot)
      Returns:
      the Direction corresponding to the given angle in degrees (0-360). Out of bounds values are wrapped around. An angle of 0 is SOUTH, an angle of 90 would be WEST.
    • fromAxisAndDirection

      public static Direction fromAxisAndDirection(Direction.Axis axis, Direction.AxisDirection direction)
    • toYRot

      public float toYRot()
    • getRandom

      public static Direction getRandom(RandomSource random)
    • getApproximateNearest

      public static Direction getApproximateNearest(double dx, double dy, double dz)
    • getApproximateNearest

      public static Direction getApproximateNearest(float dx, float dy, float dz)
    • getApproximateNearest

      public static Direction getApproximateNearest(Vec3 vec)
    • getNearest

      @Contract("_,_,_,!null->!null;_,_,_,_->_") public static @Nullable Direction getNearest(int x, int y, int z, @Nullable Direction orElse)
    • getNearest

      @Contract("_,!null->!null;_,_->_") public static @Nullable Direction getNearest(Vec3i vec, @Nullable Direction orElse)
    • toString

      public String toString()
      Overrides:
      toString in class Enum<Direction>
    • getSerializedName

      public String getSerializedName()
      Specified by:
      getSerializedName in interface StringRepresentable
    • verifyVertical

      private static com.mojang.serialization.DataResult<Direction> verifyVertical(Direction v)
    • get

      public static Direction get(Direction.AxisDirection axisDirection, Direction.Axis axis)
    • axisStepOrder

      public static ImmutableList<Direction.Axis> axisStepOrder(Vec3 movement)
    • getUnitVec3i

      public Vec3i getUnitVec3i()
    • getUnitVec3

      public Vec3 getUnitVec3()
    • getUnitVec3f

      public Vector3fc getUnitVec3f()
    • isFacingAngle

      public boolean isFacingAngle(float yAngle)