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 public static final ForgeDirection[] VALID_DIRECTIONS = {DOWN, UP, NORTH, SOUTH, WEST, EAST}; 033 public static final int[] opposite = {1, 0, 3, 2, 5, 4, 6}; 034 035 private ForgeDirection(int x, int y, int z) 036 { 037 offsetX = x; 038 offsetY = y; 039 offsetZ = z; 040 flag = 1 << ordinal(); 041 } 042 043 public static ForgeDirection getOrientation(int id) 044 { 045 if (id >= 0 && id < VALID_DIRECTIONS.length) 046 { 047 return VALID_DIRECTIONS[id]; 048 } 049 return UNKNOWN; 050 } 051 052 public ForgeDirection getOpposite() 053 { 054 return getOrientation(opposite[ordinal()]); 055 } 056 }