31 public ?
World $world =
null;
33 public function __construct(
float|
int $x,
float|
int $y,
float|
int $z, ?
World $world){
34 parent::__construct($x, $y, $z);
35 if($world !==
null && !$world->isLoaded()){
36 throw new \InvalidArgumentException(
"Specified world has been unloaded and cannot be used");
39 $this->world = $world;
46 return new Position($pos->x, $pos->y, $pos->z, $world);
53 return new
Position($this->x, $this->y, $this->z, $this->world);
62 if($this->world === null || !$this->world->isLoaded()){
73 if($this->world !== null && !$this->world->isLoaded()){
79 return $this->world !==
null;
87 public function getSide(
int $side,
int $step = 1){
88 assert($this->isValid());
90 return Position::fromObject(parent::getSide($side, $step), $this->world);
93 public function __toString(){
94 return "Position(world=" . ($this->isValid() ? $this->getWorld()->getDisplayName() :
"null") .
",x=" . $this->x .
",y=" . $this->y .
",z=" . $this->z .
")";
97 public function equals(Vector3 $v) : bool{
99 return parent::equals($v) && $v->world === $this->world;
101 return parent::equals($v);