Enum Class Direction

java.lang.Object
java.lang.Enum<Direction>
com.sk89q.worldedit.util.Direction
All Implemented Interfaces:
Serializable, Comparable<Direction>, Constable

public enum Direction extends Enum<Direction>
A collection of cardinal, ordinal, and secondary-ordinal directions.
  • Enum Constant Details

    • NORTH

      public static final Direction NORTH
    • EAST

      public static final Direction EAST
    • SOUTH

      public static final Direction SOUTH
    • WEST

      public static final Direction WEST
    • UP

      public static final Direction UP
    • DOWN

      public static final Direction DOWN
    • NORTHEAST

      public static final Direction NORTHEAST
    • NORTHWEST

      public static final Direction NORTHWEST
    • SOUTHEAST

      public static final Direction SOUTHEAST
    • SOUTHWEST

      public static final Direction SOUTHWEST
    • WEST_NORTHWEST

      public static final Direction WEST_NORTHWEST
    • WEST_SOUTHWEST

      public static final Direction WEST_SOUTHWEST
    • NORTH_NORTHWEST

      public static final Direction NORTH_NORTHWEST
    • NORTH_NORTHEAST

      public static final Direction NORTH_NORTHEAST
    • EAST_NORTHEAST

      public static final Direction EAST_NORTHEAST
    • EAST_SOUTHEAST

      public static final Direction EAST_SOUTHEAST
    • SOUTH_SOUTHEAST

      public static final Direction SOUTH_SOUTHEAST
    • SOUTH_SOUTHWEST

      public static final Direction SOUTH_SOUTHWEST
  • 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
    • isCardinal

      public boolean isCardinal()
      Return true if the direction is of a cardinal direction (north, west east, and south).

      This evaluates as false for directions that have a non-zero Y-component.

      Returns:
      true if cardinal
    • isOrdinal

      public boolean isOrdinal()
      Return true if the direction is of an ordinal direction (northwest, southwest, southeast, northeaast).
      Returns:
      true if ordinal
    • isSecondaryOrdinal

      public boolean isSecondaryOrdinal()
      Return true if the direction is of a secondary ordinal direction (north-northwest, north-northeast, south-southwest, etc.).
      Returns:
      true if secondary ordinal
    • isUpright

      public boolean isUpright()
      Return whether Y component is non-zero.
      Returns:
      true if the Y component is non-zero
    • toVector

      public Vector3 toVector()
      Get the vector.
      Returns:
      the vector
    • toBlockVector

      public BlockVector3 toBlockVector()
      Get the vector.
      Returns:
      the vector
    • findClosest

      @Nullable public static Direction findClosest(Vector3 vector, int flags)
      Find the closest direction to the given direction vector.
      Parameters:
      vector - the vector
      flags - the only flags that are permitted (use bitwise math)
      Returns:
      the closest direction, or null if no direction can be returned
    • valuesOf

      public static List<Direction> valuesOf(int flags)
      Gets all directions with the given flags.
      Parameters:
      flags - The flags
      Returns:
      The directions that fit the flags
    • fromRotationIndex

      public static Optional<Direction> fromRotationIndex(int rotation)
      Converts a rotation index into a Direction.

      Rotation indexes are used in BlockStates, such as sign posts.

      Parameters:
      rotation - The rotation index
      Returns:
      The direction, if applicable
    • toRotationIndex

      public OptionalInt toRotationIndex()