mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
Generator no longer requires a ChunkManager to construct
this allows injection of arbitrary ChunkManagers into a single Generator instance. The objective here was to remove the requirement to cache a SimpleChunkManager instance in worker-local storage, because that requires that the chunks it stores be manually removed to avoid memory leaks. However, there are some other obstacles, primarily the worldHeight which is not retained anywhere else.
This commit is contained in:
@ -48,8 +48,6 @@ abstract class Generator{
|
||||
return $convertedSeed;
|
||||
}
|
||||
|
||||
/** @var ChunkManager */
|
||||
protected $world;
|
||||
/** @var int */
|
||||
protected $seed;
|
||||
/**
|
||||
@ -62,19 +60,16 @@ abstract class Generator{
|
||||
protected $random;
|
||||
|
||||
/**
|
||||
* @throws InvalidGeneratorOptionsException
|
||||
*
|
||||
* @param mixed[] $options
|
||||
* @phpstan-param array<string, mixed> $options
|
||||
*/
|
||||
public function __construct(ChunkManager $world, int $seed, array $options = []){
|
||||
$this->world = $world;
|
||||
public function __construct(int $seed, array $options = []){
|
||||
$this->seed = $seed;
|
||||
$this->options = $options;
|
||||
$this->random = new Random($seed);
|
||||
}
|
||||
|
||||
abstract public function generateChunk(int $chunkX, int $chunkZ) : void;
|
||||
abstract public function generateChunk(ChunkManager $world, int $chunkX, int $chunkZ) : void;
|
||||
|
||||
abstract public function populateChunk(int $chunkX, int $chunkZ) : void;
|
||||
abstract public function populateChunk(ChunkManager $world, int $chunkX, int $chunkZ) : void;
|
||||
}
|
||||
|
Reference in New Issue
Block a user