001/* 002 * Trident - A Multithreaded Server Alternative 003 * Copyright 2014 The TridentSDK Team 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package net.tridentsdk.base; 018 019import net.tridentsdk.util.Vector; 020 021/** 022 * TODO Write Description 023 * 024 * @author The TridentSDK Team 025 * @since 0.4-alpha 026 */ 027public enum BlockFace { 028 029 DOWN((byte) 0, new Vector(0, -1, 0)), 030 UP((byte) 1, new Vector(0, 1, 0)), 031 NORTH((byte) 2, new Vector(0, 0, -1)), 032 SOUTH((byte) 3, new Vector(0, 0, 1)), 033 WEST((byte) 4, new Vector(-1, 0, 0)), 034 EAST((byte) 5, new Vector(1, 0, 0)); 035 036 private byte direction; 037 private Vector relative; 038 039 BlockFace(byte direction, Vector relative){ 040 this.direction = direction; 041 this.relative = relative; 042 } 043 044 public BlockFace getOpposite(){ 045 switch(this){ 046 case DOWN: 047 return UP; 048 case UP: 049 return DOWN; 050 case NORTH: 051 return SOUTH; 052 case SOUTH: 053 return NORTH; 054 case WEST: 055 return EAST; 056 default: 057 return WEST; 058 } 059 } 060 061 public int direction(){ 062 return direction; 063 } 064 065 public Vector relative(){ 066 return relative; 067 } 068 069 public static BlockFace directionToFace(byte direction){ 070 switch(direction){ 071 case 0: 072 return DOWN; 073 case 1: 074 return UP; 075 case 2: 076 return NORTH; 077 case 3: 078 return SOUTH; 079 case 4: 080 return WEST; 081 default: 082 return EAST; 083 } 084 } 085 086}