mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-04 17:06:16 +00:00
Replaced some instanceof to null checks
This commit is contained in:
@ -64,7 +64,7 @@ class Position extends Vector3{
|
||||
* @return bool
|
||||
*/
|
||||
public function isValid(){
|
||||
return isset($this->level) and $this->level instanceof Level;
|
||||
return $this->level !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -109,21 +109,6 @@ class Position extends Vector3{
|
||||
return Position::fromObject(parent::getSide($side, $step), $this->level);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the distance between two points or objects
|
||||
*
|
||||
* @param Vector3 $pos
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function distance(Vector3 $pos){
|
||||
if(($pos instanceof Position) and $pos->getLevel() !== $this->getLevel()){
|
||||
return PHP_INT_MAX;
|
||||
}
|
||||
|
||||
return parent::distance($pos);
|
||||
}
|
||||
|
||||
public function __toString(){
|
||||
return "Position(level=" . ($this->isValid() ? $this->getLevel()->getName() : "null") . ",x=" . $this->x . ",y=" . $this->y . ",z=" . $this->z . ")";
|
||||
}
|
||||
|
Reference in New Issue
Block a user