2012-10-31 01:01:45 -04:00
|
|
|
package org.bukkit;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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,
|
|
|
|
/**
|
|
|
|
* Rotated clockwise by 90 degrees
|
|
|
|
*/
|
|
|
|
CLOCKWISE,
|
|
|
|
/**
|
|
|
|
* Flipped upside-down, a 180 degree rotation
|
|
|
|
*/
|
|
|
|
FLIPPED,
|
|
|
|
/**
|
|
|
|
* Rotated counter-clockwise by 90 degrees
|
|
|
|
*/
|
|
|
|
COUNTER_CLOCKWISE,
|
|
|
|
;
|
|
|
|
|
|
|
|
private static final Rotation [] rotations = values();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rotate clockwise by 90 degrees.
|
|
|
|
*
|
|
|
|
* @return the relative rotation
|
|
|
|
*/
|
|
|
|
public Rotation rotateClockwise() {
|
|
|
|
return rotations[(this.ordinal() + 1) & 0x3];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rotate counter-clockwise by 90 degrees.
|
|
|
|
*
|
|
|
|
* @return the relative rotation
|
|
|
|
*/
|
|
|
|
public Rotation rotateCounterClockwise() {
|
|
|
|
return rotations[(this.ordinal() - 1) & 0x3];
|
|
|
|
}
|
|
|
|
}
|