dataPath = $dataPath; if(!file_exists($this->dataPath)){ throw new LevelException("Level data not found at $dataPath"); } $this->compoundTag = $this->load(); if($this->compoundTag === null){ throw new LevelException("Invalid level data"); } } /** * @return CompoundTag */ abstract protected function load() : ?CompoundTag; abstract protected function fix() : void; public function getCompoundTag() : CompoundTag{ return $this->compoundTag; } /* The below are common between PC and PE */ public function getName() : string{ return $this->compoundTag->getString("LevelName"); } public function getGenerator() : string{ return $this->compoundTag->getString("generatorName", "DEFAULT"); } public function getGeneratorOptions() : array{ return ["preset" => $this->compoundTag->getString("generatorOptions", "")]; } public function getSeed() : int{ return $this->compoundTag->getLong("RandomSeed"); } public function getTime() : int{ return $this->compoundTag->getLong("Time", 0, true); } public function setTime(int $value) : void{ $this->compoundTag->setLong("Time", $value, true); //some older PM worlds had this in the wrong format } public function getSpawn() : Vector3{ return new Vector3($this->compoundTag->getInt("SpawnX"), $this->compoundTag->getInt("SpawnY"), $this->compoundTag->getInt("SpawnZ")); } public function setSpawn(Vector3 $pos) : void{ $this->compoundTag->setInt("SpawnX", $pos->getFloorX()); $this->compoundTag->setInt("SpawnY", $pos->getFloorY()); $this->compoundTag->setInt("SpawnZ", $pos->getFloorZ()); } }