mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Flat: clean up generation of base chunk
This commit is contained in:
parent
709abb02e6
commit
172abef2a7
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user