net.minestom.server.utils.Direction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of minestom-lib-snapshots Show documentation
Show all versions of minestom-lib-snapshots Show documentation
1.21 Lightweight Minecraft server
package net.minestom.server.utils;
import org.jetbrains.annotations.NotNull;
public enum Direction {
DOWN(0, -1, 0),
UP(0, 1, 0),
NORTH(0, 0, -1),
SOUTH(0, 0, 1),
WEST(-1, 0, 0),
EAST(1, 0, 0);
public static final Direction[] HORIZONTAL = {SOUTH, WEST, NORTH, EAST};
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 @NotNull Direction opposite() {
return switch (this) {
case UP -> DOWN;
case DOWN -> UP;
case EAST -> WEST;
case WEST -> EAST;
case NORTH -> SOUTH;
case SOUTH -> NORTH;
};
}
}