diff --git a/classes/API/LevelAPI.php b/classes/API/LevelAPI.php index 0d8e421fa..37e822364 100644 --- a/classes/API/LevelAPI.php +++ b/classes/API/LevelAPI.php @@ -66,8 +66,15 @@ class LevelAPI{ return $this->map->map[$X][$Z]; } + public function getBlockFace($x, $y, $z, $face){ + $data = array("x" => $x, "y" => $y, "z" => $z); + BlockFace::setPosition($data, $face); + return $this->getBlock($data["x"], $data["y"], $data["z"]); + } + public function getBlock($x, $y, $z){ - return $this->map->getBlock($x, $y, $z); + $b = $this->map->getBlock($x, $y, $z); + $b[2] = array($x, $y, $z); } public function getFloor($x, $z){ diff --git a/classes/Data.class.php b/classes/Data.class.php index c3b4618c4..1a4991925 100644 --- a/classes/Data.class.php +++ b/classes/Data.class.php @@ -25,12 +25,46 @@ the Free Software Foundation, either version 3 of the License, or */ +class BlockFace{ + const BOTTOM = 0; + const TOP = 1; + const DOWN = 0; + const UP = 1; + const SOUTH = 3; + const EAST = 5; + const NORTH = 2; + const WEST = 4; + public static function setPosition(&$data, $face){ + switch((int) $face){ + case 0: + --$data["y"]; + break; + case 1: + ++$data["y"]; + break; + case 2: + --$data["z"]; + break; + case 3: + ++$data["z"]; + break; + case 4: + --$data["x"]; + break; + case 5: + ++$data["x"]; + break; + default: + return false; + } + return true; + } +} + class Material{ static $flowable = array( 0 => true, 6 => true, - //8 => true, - //9 => true, 30 => true, 31 => true, 32 => true,