Minestom/src/main/java/net/minestom/server/utils/Direction.java

54 lines
1.1 KiB
Java
Raw Normal View History

package net.minestom.server.utils;
public enum Direction {
2020-07-01 20:36:19 +02:00
NORTH(0, 0, -1),
EAST(1, 0, 0),
SOUTH(0, 0, 1),
WEST(-1, 0, 0),
UP(0, 1, 0),
DOWN(0, -1, 0);
public static final Direction[] HORIZONTAL = { SOUTH, WEST, NORTH, EAST };
2020-07-01 20:36:19 +02:00
private final int normalX;
private final int normalY;
private final int normalZ;
Direction(int normalX, int normalY, int normalZ) {
this.normalX = normalX;
this.normalY = normalY;
this.normalZ = normalZ;
}
public int normalX() {
return normalX;
}
public int normalY() {
return normalY;
}
public int normalZ() {
return normalZ;
}
public Direction opposite() {
switch (this) {
case UP:
return DOWN;
case DOWN:
return UP;
case EAST:
return WEST;
case WEST:
return EAST;
case NORTH:
return SOUTH;
case SOUTH:
return NORTH;
default:
throw new IllegalArgumentException();
}
}
}