bumped pmf version, added generator to level data to make chunks generate later

This commit is contained in:
GameHerobrine 2023-02-26 23:20:02 +03:00
parent abe20e8cdf
commit 197e0c63bd
3 changed files with 13 additions and 7 deletions

View file

@ -1,11 +1,11 @@
<?php <?php
define("PMF_CURRENT_LEVEL_VERSION", 0x00); define("PMF_CURRENT_LEVEL_VERSION", 0x01);
class PMFLevel extends PMF{ class PMFLevel extends PMF{
public $isLoaded = true; public $isLoaded = true;
private $levelData = []; public $levelData = [];
private $locationTable = []; private $locationTable = [];
private $log = 4; private $log = 4;
private $payloadOffset = 0; private $payloadOffset = 0;
@ -77,6 +77,7 @@ class PMFLevel extends PMF{
$this->write(Utils::writeFloat($this->levelData["spawnZ"])); $this->write(Utils::writeFloat($this->levelData["spawnZ"]));
$this->write(chr($this->levelData["width"])); $this->write(chr($this->levelData["width"]));
$this->write(chr($this->levelData["height"])); $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); $extra = gzdeflate($this->levelData["extra"], PMF_LEVEL_DEFLATE_LEVEL);
$this->write(Utils::writeShort(strlen($extra)) . $extra); $this->write(Utils::writeShort(strlen($extra)) . $extra);
$this->payloadOffset = ftell($this->fp); $this->payloadOffset = ftell($this->fp);
@ -111,7 +112,7 @@ class PMFLevel extends PMF{
} }
$this->seek(5); $this->seek(5);
$this->levelData["version"] = ord($this->read(1)); $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; return false;
} }
$this->levelData["name"] = $this->read(Utils::readShort($this->read(2), 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["spawnZ"] = Utils::readFloat($this->read(4));
$this->levelData["width"] = ord($this->read(1)); $this->levelData["width"] = ord($this->read(1));
$this->levelData["height"] = 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){ if(($this->levelData["width"] !== 16 and $this->levelData["width"] !== 32) or $this->levelData["height"] !== 8){
return false; return false;
} }

View file

@ -13,6 +13,7 @@ class Level{
public $tiles, $blockUpdates, $nextSave, $players = [], $level; public $tiles, $blockUpdates, $nextSave, $players = [], $level;
private $time, $startCheck, $startTime, $server, $name, $usedChunks, $changedBlocks, $changedCount, $stopTime; private $time, $startCheck, $startTime, $server, $name, $usedChunks, $changedBlocks, $changedCount, $stopTime;
private $generator;
public function __construct(PMFLevel $level, Config $entities, Config $tiles, Config $blockUpdates, $name){ public function __construct(PMFLevel $level, Config $entities, Config $tiles, Config $blockUpdates, $name){
$this->server = ServerAPI::request(); $this->server = ServerAPI::request();
$this->level = $level; $this->level = $level;
@ -32,6 +33,8 @@ class Level{
$this->changedBlocks = []; $this->changedBlocks = [];
$this->changedCount = []; $this->changedCount = [];
$this->mobSpawner = new MobSpawner($this); $this->mobSpawner = new MobSpawner($this);
$gen = $this->level->levelData["generator"];
$this->generator = new $gen([]);
} }
public function close(){ public function close(){

View file

@ -20,7 +20,8 @@ class WorldGenerator{
"spawnZ" => 128, "spawnZ" => 128,
"extra" => "", "extra" => "",
"width" => $this->width, "width" => $this->width,
"height" => $this->height "height" => $this->height,
"generator" => get_class($generator),
]); ]);
$entities = new Config($this->path . "entities.yml", CONFIG_YAML); $entities = new Config($this->path . "entities.yml", CONFIG_YAML);
$tiles = new Config($this->path . "tiles.yml", CONFIG_YAML); $tiles = new Config($this->path . "tiles.yml", CONFIG_YAML);