mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-18 17:11:28 +00:00
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:
parent
1a6517ea4e
commit
b8a30309bb
@ -79,4 +79,11 @@ class Location extends Position{
|
|||||||
public function __toString(){
|
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)";
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,4 +133,10 @@ class Position extends Vector3{
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function equals(Vector3 $v){
|
||||||
|
if($v instanceof Position){
|
||||||
|
return parent::equals($v) and $v->getLevel() === $this->getLevel();
|
||||||
|
}
|
||||||
|
return parent::equals($v);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user