x = $x; $this->y = $y; $this->z = $z; $this->level = $level; } public static function fromObject(Vector3 $pos, Level $level = null){ return new Position($pos->x, $pos->y, $pos->z, $level); } /** * @return Level */ public function getLevel(){ return $this->level; } public function setLevel(Level $level){ $this->level = $level; return $this; } /** * Checks if this object has a valid reference to a Level * * @return bool */ public function isValid(){ return $this->getLevel() instanceof Level; } /** * Returns a side Vector * * @param int $side * @param int $step * * @return Position * * @throws LevelException */ public function getSide($side, $step = 1){ assert($this->isValid()); return Position::fromObject(parent::getSide($side, $step), $this->level); } public function __toString(){ return "Position(level=" . ($this->isValid() ? $this->getLevel()->getName() : "null") . ",x=" . $this->x . ",y=" . $this->y . ",z=" . $this->z . ")"; } /** * @param $x * @param $y * @param $z * * @return Position */ public function setComponents($x, $y, $z){ $this->x = $x; $this->y = $y; $this->z = $z; return $this; } }