mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Generator: small reduction of code duplication
This commit is contained in:
parent
996935e9b2
commit
3c9af5cd6d
@ -35,12 +35,8 @@ use pocketmine\math\Vector3;
|
||||
use pocketmine\utils\Random;
|
||||
|
||||
class Flat extends Generator{
|
||||
/** @var ChunkManager */
|
||||
private $level;
|
||||
/** @var Chunk */
|
||||
private $chunk;
|
||||
/** @var Random */
|
||||
private $random;
|
||||
/** @var Populator[] */
|
||||
private $populators = [];
|
||||
private $structure, $chunks, $options, $floorLevel, $preset;
|
||||
@ -148,8 +144,7 @@ class Flat extends Generator{
|
||||
}
|
||||
|
||||
public function init(ChunkManager $level, Random $random){
|
||||
$this->level = $level;
|
||||
$this->random = $random;
|
||||
parent::init($level, $random);
|
||||
|
||||
/*
|
||||
// Commented out : We want to delay this
|
||||
|
@ -52,10 +52,18 @@ abstract class Generator{
|
||||
return $convertedSeed;
|
||||
}
|
||||
|
||||
/** @var ChunkManager */
|
||||
protected $level;
|
||||
/** @var Random */
|
||||
protected $random;
|
||||
|
||||
abstract public function __construct(array $settings = []);
|
||||
|
||||
|
||||
abstract public function init(ChunkManager $level, Random $random);
|
||||
public function init(ChunkManager $level, Random $random){
|
||||
$this->level = $level;
|
||||
$this->random = $random;
|
||||
}
|
||||
|
||||
abstract public function generateChunk(int $chunkX, int $chunkZ);
|
||||
|
||||
|
@ -37,10 +37,6 @@ class Nether extends Generator{
|
||||
|
||||
/** @var Populator[] */
|
||||
private $populators = [];
|
||||
/** @var ChunkManager */
|
||||
private $level;
|
||||
/** @var Random */
|
||||
private $random;
|
||||
/** @var int */
|
||||
private $waterHeight = 32;
|
||||
/** @var int */
|
||||
@ -95,8 +91,7 @@ class Nether extends Generator{
|
||||
}
|
||||
|
||||
public function init(ChunkManager $level, Random $random){
|
||||
$this->level = $level;
|
||||
$this->random = $random;
|
||||
parent::init($level, $random);
|
||||
$this->random->setSeed($this->level->getSeed());
|
||||
$this->noiseBase = new Simplex($this->random, 4, 1 / 4, 1 / 64);
|
||||
$this->random->setSeed($this->level->getSeed());
|
||||
|
@ -42,10 +42,6 @@ class Normal extends Generator{
|
||||
|
||||
/** @var Populator[] */
|
||||
private $populators = [];
|
||||
/** @var ChunkManager */
|
||||
private $level;
|
||||
/** @var Random */
|
||||
private $random;
|
||||
/** @var int */
|
||||
private $waterHeight = 62;
|
||||
/** @var int */
|
||||
@ -109,8 +105,7 @@ class Normal extends Generator{
|
||||
}
|
||||
|
||||
public function init(ChunkManager $level, Random $random){
|
||||
$this->level = $level;
|
||||
$this->random = $random;
|
||||
parent::init($level, $random);
|
||||
$this->random->setSeed($this->level->getSeed());
|
||||
$this->noiseBase = new Simplex($this->random, 4, 1 / 4, 1 / 32);
|
||||
$this->random->setSeed($this->level->getSeed());
|
||||
|
Loading…
x
Reference in New Issue
Block a user