Method to get the opposite direction: Input = BlockFace, Output = BlockFace

Discussion in 'Resources' started by Tster, Jul 31, 2011.

Thread Status:
Not open for further replies.
  1. Offline


    Needed this for a plugin I'm whipping up, should be correct, tell me if something is wrong:
            public BlockFace getOppositeDirection(BlockFace dir){
                if (dir == BlockFace.UP){
                    dir = BlockFace.DOWN;
                } else if (dir == BlockFace.DOWN){
                    dir = BlockFace.UP;
                }  else if (dir == BlockFace.NORTH){
                    dir = BlockFace.SOUTH;
                }  else if (dir == BlockFace.SOUTH){
                    dir = BlockFace.NORTH;
                }  else if (dir == BlockFace.EAST){
                    dir = BlockFace.WEST;
                }  else if (dir == BlockFace.WEST){
                    dir = BlockFace.EAST;
                return dir;
    Noobs r us, with blockfaces there is a .getOppositeFace method

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 18, 2016
Thread Status:
Not open for further replies.

Share This Page