diff --git a/src/pmf/PMFLevel.php b/src/pmf/PMFLevel.php index 41fa8281..b966a723 100644 --- a/src/pmf/PMFLevel.php +++ b/src/pmf/PMFLevel.php @@ -1,11 +1,11 @@ write(Utils::writeFloat($this->levelData["spawnZ"])); $this->write(chr($this->levelData["width"])); $this->write(chr($this->levelData["height"])); + $this->write(Utils::writeShort(strlen($this->levelData["generator"])).$this->levelData["generator"]); $extra = gzdeflate($this->levelData["extra"], PMF_LEVEL_DEFLATE_LEVEL); $this->write(Utils::writeShort(strlen($extra)) . $extra); $this->payloadOffset = ftell($this->fp); @@ -111,7 +112,7 @@ class PMFLevel extends PMF{ } $this->seek(5); $this->levelData["version"] = ord($this->read(1)); - if($this->levelData["version"] > PMF_CURRENT_LEVEL_VERSION){ + if($this->levelData["version"] > PMF_CURRENT_LEVEL_VERSION){ //TODO old worlds support return false; } $this->levelData["name"] = $this->read(Utils::readShort($this->read(2), false)); @@ -122,6 +123,7 @@ class PMFLevel extends PMF{ $this->levelData["spawnZ"] = Utils::readFloat($this->read(4)); $this->levelData["width"] = ord($this->read(1)); $this->levelData["height"] = ord($this->read(1)); + $this->levelData["generator"] = $this->read(Utils::readShort($this->read(2), false)); if(($this->levelData["width"] !== 16 and $this->levelData["width"] !== 32) or $this->levelData["height"] !== 8){ return false; } @@ -293,7 +295,7 @@ class PMFLevel extends PMF{ @gzclose($chunk); return true; } - + protected function fillMiniChunk($X, $Z, $Y){ if($this->isChunkLoaded($X, $Z) === false){ return false; diff --git a/src/world/Level.php b/src/world/Level.php index d1f791d9..5dcb6721 100644 --- a/src/world/Level.php +++ b/src/world/Level.php @@ -12,14 +12,15 @@ class Level{ public $entityList; public $tiles, $blockUpdates, $nextSave, $players = [], $level; private $time, $startCheck, $startTime, $server, $name, $usedChunks, $changedBlocks, $changedCount, $stopTime; - + + private $generator; public function __construct(PMFLevel $level, Config $entities, Config $tiles, Config $blockUpdates, $name){ $this->server = ServerAPI::request(); $this->level = $level; $this->level->level = $this; $this->entityList = []; $this->entities = $entities; - $this->tiles = $tiles; + $this->tiles = $tiles; $this->blockUpdates = $blockUpdates; $this->startTime = $this->time = (int) $this->level->getData("time"); $this->nextSave = $this->startCheck = microtime(true); @@ -32,6 +33,8 @@ class Level{ $this->changedBlocks = []; $this->changedCount = []; $this->mobSpawner = new MobSpawner($this); + $gen = $this->level->levelData["generator"]; + $this->generator = new $gen([]); } public function close(){ diff --git a/src/world/generator/WorldGenerator.php b/src/world/generator/WorldGenerator.php index 21a81754..5d8a5583 100644 --- a/src/world/generator/WorldGenerator.php +++ b/src/world/generator/WorldGenerator.php @@ -20,7 +20,8 @@ class WorldGenerator{ "spawnZ" => 128, "extra" => "", "width" => $this->width, - "height" => $this->height + "height" => $this->height, + "generator" => get_class($generator), ]); $entities = new Config($this->path . "entities.yml", CONFIG_YAML); $tiles = new Config($this->path . "tiles.yml", CONFIG_YAML);