mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
Further refactors to prepare for y=-64 lower limit
This commit is contained in:
@ -42,7 +42,9 @@ class GeneratorRegisterTask extends AsyncTask{
|
||||
/** @var int */
|
||||
public $worldId;
|
||||
/** @var int */
|
||||
public $worldHeight = World::Y_MAX;
|
||||
public $worldMinY;
|
||||
/** @var int */
|
||||
public $worldMaxY;
|
||||
|
||||
/**
|
||||
* @param mixed[] $generatorSettings
|
||||
@ -54,7 +56,8 @@ class GeneratorRegisterTask extends AsyncTask{
|
||||
$this->settings = igbinary_serialize($generatorSettings);
|
||||
$this->seed = $world->getSeed();
|
||||
$this->worldId = $world->getId();
|
||||
$this->worldHeight = $world->getWorldHeight();
|
||||
$this->worldMinY = $world->getMinY();
|
||||
$this->worldMaxY = $world->getMaxY();
|
||||
}
|
||||
|
||||
public function onRun() : void{
|
||||
@ -63,6 +66,6 @@ class GeneratorRegisterTask extends AsyncTask{
|
||||
* @see Generator::__construct()
|
||||
*/
|
||||
$generator = new $this->generatorClass($this->seed, igbinary_unserialize($this->settings));
|
||||
ThreadLocalGeneratorContext::register(new ThreadLocalGeneratorContext($generator, $this->worldHeight), $this->worldId);
|
||||
ThreadLocalGeneratorContext::register(new ThreadLocalGeneratorContext($generator, $this->worldMinY, $this->worldMaxY), $this->worldId);
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ class PopulationTask extends AsyncTask{
|
||||
throw new AssumptionFailedError("Generator context should have been initialized before any PopulationTask execution");
|
||||
}
|
||||
$generator = $context->getGenerator();
|
||||
$manager = new SimpleChunkManager($context->getWorldHeight());
|
||||
$manager = new SimpleChunkManager($context->getWorldMinY(), $context->getWorldMaxY());
|
||||
|
||||
/** @var Chunk[] $chunks */
|
||||
$chunks = [];
|
||||
|
@ -47,15 +47,21 @@ final class ThreadLocalGeneratorContext{
|
||||
|
||||
/** @var Generator */
|
||||
private $generator;
|
||||
/** @var int */
|
||||
private $worldHeight;
|
||||
|
||||
public function __construct(Generator $generator, int $worldHeight){
|
||||
/** @var int */
|
||||
private $worldMinY;
|
||||
/** @var int */
|
||||
private $worldMaxY;
|
||||
|
||||
public function __construct(Generator $generator, int $worldMinY, int $worldMaxY){
|
||||
$this->generator = $generator;
|
||||
$this->worldHeight = $worldHeight;
|
||||
$this->worldMinY = $worldMinY;
|
||||
$this->worldMaxY = $worldMaxY;
|
||||
}
|
||||
|
||||
public function getGenerator() : Generator{ return $this->generator; }
|
||||
|
||||
public function getWorldHeight() : int{ return $this->worldHeight; }
|
||||
public function getWorldMinY() : int{ return $this->worldMinY; }
|
||||
|
||||
public function getWorldMaxY() : int{ return $this->worldMaxY; }
|
||||
}
|
||||
|
Reference in New Issue
Block a user