diff --git a/src/pocketmine/level/generator/Flat.php b/src/pocketmine/level/generator/Flat.php index cf629dca7..8478250c4 100644 --- a/src/pocketmine/level/generator/Flat.php +++ b/src/pocketmine/level/generator/Flat.php @@ -26,13 +26,11 @@ namespace pocketmine\level\generator; use pocketmine\block\Block; use pocketmine\block\BlockFactory; use pocketmine\item\ItemFactory; -use pocketmine\level\ChunkManager; use pocketmine\level\format\Chunk; use pocketmine\level\generator\object\OreType; use pocketmine\level\generator\populator\Ore; use pocketmine\level\generator\populator\Populator; use pocketmine\math\Vector3; -use pocketmine\utils\Random; class Flat extends Generator{ /** @var Chunk */ @@ -53,7 +51,6 @@ class Flat extends Generator{ $this->preset = "2;7,2x3,2;1;"; //$this->preset = "2;7,59x1,3x3,2;1;spawn(radius=10 block=89),decoration(treecount=80 grasscount=45)"; $this->options = $options; - $this->chunk = null; if(isset($this->options["decoration"])){ $ores = new Ore(); @@ -86,7 +83,7 @@ class Flat extends Generator{ return $result; } - protected function parsePreset($preset, $chunkX, $chunkZ){ + protected function generateBaseChunk(string $preset) : void{ $this->preset = $preset; $preset = explode(";", $preset); $version = (int) $preset[0]; @@ -99,7 +96,7 @@ class Flat extends Generator{ $this->floorLevel = $y = count($this->structure); - $this->chunk = clone $this->level->getChunk($chunkX, $chunkZ); + $this->chunk = new Chunk(0, 0); $this->chunk->setGenerated(); for($Z = 0; $Z < 16; ++$Z){ @@ -139,25 +136,12 @@ class Flat extends Generator{ } } - public function init(ChunkManager $level, Random $random){ - parent::init($level, $random); - - /* - // Commented out : We want to delay this - if(isset($this->options["preset"]) and $this->options["preset"] != ""){ - $this->parsePreset($this->options["preset"]); - }else{ - $this->parsePreset($this->preset); - } - */ - } - public function generateChunk(int $chunkX, int $chunkZ){ if($this->chunk === null){ if(isset($this->options["preset"]) and $this->options["preset"] != ""){ - $this->parsePreset($this->options["preset"], $chunkX, $chunkZ); + $this->generateBaseChunk($this->options["preset"]); }else{ - $this->parsePreset($this->preset, $chunkX, $chunkZ); + $this->generateBaseChunk($this->preset); } } $chunk = clone $this->chunk;