diff --git a/src/pocketmine/math/Vector3.php b/src/pocketmine/math/Vector3.php index 32a92ebda..36801282a 100644 --- a/src/pocketmine/math/Vector3.php +++ b/src/pocketmine/math/Vector3.php @@ -157,23 +157,20 @@ class Vector3{ } } - public static function getOppositeSide($side){ - switch((int) $side){ - case Vector3::SIDE_DOWN: - return Vector3::SIDE_UP; - case Vector3::SIDE_UP: - return Vector3::SIDE_DOWN; - case Vector3::SIDE_NORTH: - return Vector3::SIDE_SOUTH; - case Vector3::SIDE_SOUTH: - return Vector3::SIDE_NORTH; - case Vector3::SIDE_WEST: - return Vector3::SIDE_EAST; - case Vector3::SIDE_EAST: - return Vector3::SIDE_WEST; - default: - return -1; + /** + * Returns the Vector3 side number opposite the specified one + * + * @param int $side 0-5 one of the Vector3::SIDE_* constants + * @return int + * + * @throws \InvalidArgumentException if an invalid side is supplied + */ + public static function getOppositeSide(int $side) : int{ + if($side >= 0 and $side <= 5){ + return $side ^ 0x01; } + + throw new \InvalidArgumentException("Invalid side $side given to getOppositeSide"); } public function distance(Vector3 $pos){