mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-10 09:02:09 -07:00
Add API for ItemFrames. Adds BUKKIT-2668
As well as adding methods for ItemFrames, this moves some methods previously contained in Painting to Hanging, as they are shared by both classes. An enum was added that represents rotations, similar to a clock-face. This is needed as a contrast to cardinal direction based rotations. By: h31ix <effectsdude@gmail.com>
This commit is contained in:
45
paper-api/src/main/java/org/bukkit/Rotation.java
Normal file
45
paper-api/src/main/java/org/bukkit/Rotation.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package org.bukkit;
|
||||
|
||||
/**
|
||||
* An enum to specify a rotation based orientation, like that on a clock.
|
||||
* It represents how something is viewed, as opposed to cardinal directions.
|
||||
*/
|
||||
public enum Rotation {
|
||||
/**
|
||||
* 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];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user