diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 0b39ee2ed..77e869a52 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -86,7 +86,6 @@ use pocketmine\level\format\Chunk; use pocketmine\level\Level; use pocketmine\level\Location; use pocketmine\level\Position; -use pocketmine\level\WeakPosition; use pocketmine\math\AxisAlignedBB; use pocketmine\math\Vector3; use pocketmine\metadata\MetadataValue; @@ -299,7 +298,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ /** @var Vector3|null */ protected $sleeping = null; - /** @var WeakPosition|null */ + /** @var Position|null */ private $spawnPosition = null; //TODO: Abilities @@ -1166,7 +1165,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ * @return bool */ public function hasValidSpawnPosition() : bool{ - return $this->spawnPosition instanceof WeakPosition and $this->spawnPosition->isValid(); + return $this->spawnPosition !== null and $this->spawnPosition->isValid(); } /** @@ -1181,7 +1180,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ }else{ $level = $pos->getLevel(); } - $this->spawnPosition = new WeakPosition($pos->x, $pos->y, $pos->z, $level); + $this->spawnPosition = new Position($pos->x, $pos->y, $pos->z, $level); $pk = new SetSpawnPositionPacket(); $pk->x = $this->spawnPosition->getFloorX(); $pk->y = $this->spawnPosition->getFloorY(); @@ -2099,9 +2098,9 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ if(!$this->hasValidSpawnPosition()){ if(($level = $this->server->getLevelByName($this->namedtag->getString("SpawnLevel", ""))) instanceof Level){ - $this->spawnPosition = new WeakPosition($this->namedtag->getInt("SpawnX"), $this->namedtag->getInt("SpawnY"), $this->namedtag->getInt("SpawnZ"), $level); + $this->spawnPosition = new Position($this->namedtag->getInt("SpawnX"), $this->namedtag->getInt("SpawnY"), $this->namedtag->getInt("SpawnZ"), $level); }else{ - $this->spawnPosition = WeakPosition::fromObject($this->level->getSafeSpawn()); + $this->spawnPosition = $this->level->getSafeSpawn(); } } diff --git a/src/pocketmine/level/WeakPosition.php b/src/pocketmine/level/WeakPosition.php deleted file mode 100644 index b843970c7..000000000 --- a/src/pocketmine/level/WeakPosition.php +++ /dev/null @@ -1,90 +0,0 @@ -x = $x; - $this->y = $y; - $this->z = $z; - $this->levelId = ($level !== null ? $level->getId() : -1); - } - - public static function fromObject(Vector3 $pos, Level $level = null){ - return new WeakPosition($pos->x, $pos->y, $pos->z, $level); - } - - /** - * @return Level|null - */ - public function getLevel(){ - return Server::getInstance()->getLevel($this->levelId); - } - - /** - * @param Level|null $level - * - * @return $this - * - * @throws \InvalidArgumentException if the specified Level has been closed - */ - public function setLevel(Level $level = null){ - if($level !== null and $level->isClosed()){ - throw new \InvalidArgumentException("Specified level has been unloaded and cannot be used"); - } - - $this->levelId = ($level !== null ? $level->getId() : -1); - return $this; - } - - /** - * Returns a side Vector - * - * @param int $side - * @param int $step - * - * @return WeakPosition - */ - public function getSide(int $side, int $step = 1){ - assert($this->isValid()); - - return WeakPosition::fromObject(parent::getSide($side, $step), $this->level); - } - - public function __toString(){ - return "Weak" . parent::__toString(); - } -}