34 public function __construct(
float|
int $x,
float|
int $y,
float|
int $z, ?
World $world){
35 parent::__construct($x, $y, $z);
36 if($world !==
null && !$world->isLoaded()){
37 throw new \InvalidArgumentException(
"Specified world has been unloaded and cannot be used");
40 $this->world = $world;
47 return new Position($pos->x, $pos->y, $pos->z, $world);
54 return new
Position($this->x, $this->y, $this->z, $this->world);
63 if($this->world === null || !$this->world->isLoaded()){
74 if($this->world !== null && !$this->world->isLoaded()){
78 return $this->world !==
null;
87 assert($this->isValid());
89 return Position::fromObject(parent::getSide($side, $step), $this->world);
92 public function __toString(){
93 return "Position(world=" . ($this->isValid() ? $this->getWorld()->getDisplayName() :
"null") .
",x=" . $this->x .
",y=" . $this->y .
",z=" . $this->z .
")";
96 public function equals(Vector3 $v) : bool{
98 return parent::equals($v) && $v->world === $this->world;
100 return parent::equals($v);