2012-10-31 01:01:45 -04:00
|
|
|
package org.bukkit;
|
|
|
|
|
2019-03-13 17:42:57 +11:00
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
|
2012-10-31 01:01:45 -04:00
|
|
|
/**
|
|
|
|
* An enum to specify a rotation based orientation, like that on a clock.
|
2013-12-15 01:07:43 -05:00
|
|
|
* <p>
|
2012-10-31 01:01:45 -04:00
|
|
|
* It represents how something is viewed, as opposed to cardinal directions.
|
|
|
|
*/
|
|
|
|
public enum Rotation {
|
2013-09-10 21:02:53 -05:00
|
|
|
|
2012-10-31 01:01:45 -04:00
|
|
|
/**
|
|
|
|
* No rotation
|
|
|
|
*/
|
|
|
|
NONE,
|
2014-12-02 00:02:30 +01:00
|
|
|
/**
|
|
|
|
* Rotated clockwise by 45 degrees
|
|
|
|
*/
|
|
|
|
CLOCKWISE_45,
|
2012-10-31 01:01:45 -04:00
|
|
|
/**
|
|
|
|
* Rotated clockwise by 90 degrees
|
|
|
|
*/
|
|
|
|
CLOCKWISE,
|
2014-12-02 00:02:30 +01:00
|
|
|
/**
|
|
|
|
* Rotated clockwise by 135 degrees
|
|
|
|
*/
|
|
|
|
CLOCKWISE_135,
|
2012-10-31 01:01:45 -04:00
|
|
|
/**
|
|
|
|
* Flipped upside-down, a 180 degree rotation
|
|
|
|
*/
|
|
|
|
FLIPPED,
|
2014-12-02 00:02:30 +01:00
|
|
|
/**
|
|
|
|
* Flipped upside-down + 45 degree rotation
|
|
|
|
*/
|
|
|
|
FLIPPED_45,
|
2012-10-31 01:01:45 -04:00
|
|
|
/**
|
|
|
|
* Rotated counter-clockwise by 90 degrees
|
|
|
|
*/
|
|
|
|
COUNTER_CLOCKWISE,
|
2014-12-02 00:02:30 +01:00
|
|
|
/**
|
|
|
|
* Rotated counter-clockwise by 45 degrees
|
|
|
|
*/
|
|
|
|
COUNTER_CLOCKWISE_45
|
2012-10-31 01:01:45 -04:00
|
|
|
;
|
|
|
|
|
2017-08-06 09:08:05 +10:00
|
|
|
private static final Rotation[] rotations = values();
|
2012-10-31 01:01:45 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Rotate clockwise by 90 degrees.
|
|
|
|
*
|
|
|
|
* @return the relative rotation
|
|
|
|
*/
|
2019-03-13 17:42:57 +11:00
|
|
|
@NotNull
|
2012-10-31 01:01:45 -04:00
|
|
|
public Rotation rotateClockwise() {
|
2014-12-02 00:02:30 +01:00
|
|
|
return rotations[(this.ordinal() + 1) & 0x7];
|
2012-10-31 01:01:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rotate counter-clockwise by 90 degrees.
|
|
|
|
*
|
|
|
|
* @return the relative rotation
|
|
|
|
*/
|
2019-03-13 17:42:57 +11:00
|
|
|
@NotNull
|
2012-10-31 01:01:45 -04:00
|
|
|
public Rotation rotateCounterClockwise() {
|
2014-12-02 00:02:30 +01:00
|
|
|
return rotations[(this.ordinal() - 1) & 0x7];
|
2012-10-31 01:01:45 -04:00
|
|
|
}
|
|
|
|
}
|