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