Improve checks for Position::equals() and Location::equals() (#929)

* Add files via upload

* Position::$level can be null.

* Use getLevel() in place of $level

because of WeakPosition.
This commit is contained in:
Muqsit Rayyan 2017-07-04 22:25:25 +03:00 committed by Dylan K. Taylor
parent 1a6517ea4e
commit b8a30309bb
2 changed files with 13 additions and 0 deletions

View File

@ -79,4 +79,11 @@ class Location extends Position{
public function __toString(){
return "Location (level=" . ($this->isValid() ? $this->getLevel()->getName() : "null") . ", x=$this->x, y=$this->y, z=$this->z, yaw=$this->yaw, pitch=$this->pitch)";
}
public function equals(Vector3 $v){
if($v instanceof Location){
return parent::equals($v) and $v->yaw == $this->yaw and $v->pitch == $this->pitch;
}
return parent::equals($v);
}
}

View File

@ -133,4 +133,10 @@ class Position extends Vector3{
return $this;
}
public function equals(Vector3 $v){
if($v instanceof Position){
return parent::equals($v) and $v->getLevel() === $this->getLevel();
}
return parent::equals($v);
}
}