From fc22fd80d8463ceb7ad497a6c204c5937cbd7e4d Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 29 Jun 2020 21:03:55 +0100 Subject: [PATCH] Eradicate remaining usages of Position->getWorld() --- src/block/Block.php | 2 +- src/player/Player.php | 2 +- src/world/Position.php | 2 +- src/world/World.php | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/block/Block.php b/src/block/Block.php index bed56f3d20..cb131fcc0b 100644 --- a/src/block/Block.php +++ b/src/block/Block.php @@ -79,7 +79,7 @@ class Block{ } public function __clone(){ - $this->pos = Position::fromObject($this->pos, $this->pos->getWorld()); + $this->pos = Position::fromObject($this->pos, $this->pos->getWorldNonNull()); } public function getIdInfo() : BlockIdentifier{ diff --git a/src/player/Player.php b/src/player/Player.php index 3041352309..df03dc55dd 100644 --- a/src/player/Player.php +++ b/src/player/Player.php @@ -713,7 +713,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener, } protected function switchWorld(World $targetWorld) : bool{ - $oldWorld = $this->location->getWorld(); + $oldWorld = $this->location->isValid() ? $this->location->getWorldNonNull() : null; if(parent::switchWorld($targetWorld)){ if($oldWorld !== null){ foreach($this->usedChunks as $index => $status){ diff --git a/src/world/Position.php b/src/world/Position.php index c670da0861..0d8c4914c6 100644 --- a/src/world/Position.php +++ b/src/world/Position.php @@ -119,7 +119,7 @@ class Position extends Vector3{ public function equals(Vector3 $v) : bool{ if($v instanceof Position){ - return parent::equals($v) and $v->getWorld() === $this->getWorld(); + return parent::equals($v) and $v->world === $this->world; } return parent::equals($v); } diff --git a/src/world/World.php b/src/world/World.php index 2fa0c1e1d2..31f1298419 100644 --- a/src/world/World.php +++ b/src/world/World.php @@ -2043,7 +2043,7 @@ class World implements ChunkManager{ throw new \InvalidArgumentException("Attempted to add a garbage closed Tile to world"); } $pos = $tile->getPos(); - if($pos->getWorld() !== $this){ + if(!$pos->isValid() || $pos->getWorldNonNull() !== $this){ throw new \InvalidArgumentException("Invalid Tile world"); } @@ -2065,7 +2065,7 @@ class World implements ChunkManager{ */ public function removeTile(Tile $tile) : void{ $pos = $tile->getPos(); - if($pos->getWorld() !== $this){ + if(!$pos->isValid() || $pos->getWorldNonNull() !== $this){ throw new \InvalidArgumentException("Invalid Tile world"); }