    001    package net.minecraftforge.common;
    002
    003    public enum ForgeDirection
    004    {
    005        /** -Y */
    006        DOWN(0, -1, 0),
    007
    008        /** +Y */
    009        UP(0, 1, 0),
    010
    011        /** -Z */
    012        NORTH(0, 0, -1),
    013
    014        /** +Z */
    015        SOUTH(0, 0, 1),
    016
    017        /** -X */
    018        WEST(-1, 0, 0),
    019
    020        /** +X */
    021        EAST(1, 0, 0),
    022
    023        /**
    024         * Used only by getOrientation, for invalid inputs
    025         */
    026        UNKNOWN(0, 0, 0);
    027
    028        public final int offsetX;
    029        public final int offsetY;
    030        public final int offsetZ;
    031        public final int flag;
    032
    033        private ForgeDirection(int x, int y, int z)
    034        {
    035            offsetX = x;
    036            offsetY = y;
    037            offsetZ = z;
    038            flag = 1 << ordinal();
    039        }
    040
    041        public static ForgeDirection getOrientation(int id)
    042        {
    043            if (id >= 0 && id < ForgeDirection.values().length)
    044            {
    045                return ForgeDirection.values()[id];
    046            }
    047            return UNKNOWN;
    048        }
    049
    050        public static final int[] opposite = new int[] { 1, 0,  3, 2,  5, 4, 6};
    051
    052        public ForgeDirection getOpposite()
    053        {
    054            return getOrientation(opposite[ordinal()]);
    055        }
    056    }