mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-14 07:25:31 +00:00
World: break random tick blocks initializing out of constructor
and fix a variable clobber by foreach as a side effect
This commit is contained in:
parent
5128bc02bb
commit
51f2a78dcf
@ -71,6 +71,7 @@ use pocketmine\promise\Promise;
|
|||||||
use pocketmine\promise\PromiseResolver;
|
use pocketmine\promise\PromiseResolver;
|
||||||
use pocketmine\scheduler\AsyncPool;
|
use pocketmine\scheduler\AsyncPool;
|
||||||
use pocketmine\Server;
|
use pocketmine\Server;
|
||||||
|
use pocketmine\ServerConfigGroup;
|
||||||
use pocketmine\timings\Timings;
|
use pocketmine\timings\Timings;
|
||||||
use pocketmine\utils\AssumptionFailedError;
|
use pocketmine\utils\AssumptionFailedError;
|
||||||
use pocketmine\utils\Limits;
|
use pocketmine\utils\Limits;
|
||||||
@ -454,6 +455,23 @@ class World implements ChunkManager{
|
|||||||
$this->tickedBlocksPerSubchunkPerTick = $cfg->getPropertyInt("chunk-ticking.blocks-per-subchunk-per-tick", self::DEFAULT_TICKED_BLOCKS_PER_SUBCHUNK_PER_TICK);
|
$this->tickedBlocksPerSubchunkPerTick = $cfg->getPropertyInt("chunk-ticking.blocks-per-subchunk-per-tick", self::DEFAULT_TICKED_BLOCKS_PER_SUBCHUNK_PER_TICK);
|
||||||
$this->maxConcurrentChunkPopulationTasks = $cfg->getPropertyInt("chunk-generation.population-queue-size", 2);
|
$this->maxConcurrentChunkPopulationTasks = $cfg->getPropertyInt("chunk-generation.population-queue-size", 2);
|
||||||
|
|
||||||
|
$this->initRandomTickBlocksFromConfig($cfg);
|
||||||
|
|
||||||
|
$this->timings = new WorldTimings($this);
|
||||||
|
|
||||||
|
$this->workerPool->addWorkerStartHook($workerStartHook = function(int $workerId) : void{
|
||||||
|
if(array_key_exists($workerId, $this->generatorRegisteredWorkers)){
|
||||||
|
$this->logger->debug("Worker $workerId with previously registered generator restarted, flagging as unregistered");
|
||||||
|
unset($this->generatorRegisteredWorkers[$workerId]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$workerPool = $this->workerPool;
|
||||||
|
$this->addOnUnloadCallback(static function() use ($workerPool, $workerStartHook) : void{
|
||||||
|
$workerPool->removeWorkerStartHook($workerStartHook);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private function initRandomTickBlocksFromConfig(ServerConfigGroup $cfg) : void{
|
||||||
$dontTickBlocks = [];
|
$dontTickBlocks = [];
|
||||||
$parser = StringToItemParser::getInstance();
|
$parser = StringToItemParser::getInstance();
|
||||||
foreach($cfg->getProperty("chunk-ticking.disable-block-ticking", []) as $name){
|
foreach($cfg->getProperty("chunk-ticking.disable-block-ticking", []) as $name){
|
||||||
@ -479,19 +497,6 @@ class World implements ChunkManager{
|
|||||||
$this->randomTickBlocks[$state->getFullId()] = true;
|
$this->randomTickBlocks[$state->getFullId()] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->timings = new WorldTimings($this);
|
|
||||||
|
|
||||||
$this->workerPool->addWorkerStartHook($workerStartHook = function(int $workerId) : void{
|
|
||||||
if(array_key_exists($workerId, $this->generatorRegisteredWorkers)){
|
|
||||||
$this->logger->debug("Worker $workerId with previously registered generator restarted, flagging as unregistered");
|
|
||||||
unset($this->generatorRegisteredWorkers[$workerId]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$workerPool = $this->workerPool;
|
|
||||||
$this->addOnUnloadCallback(static function() use ($workerPool, $workerStartHook) : void{
|
|
||||||
$workerPool->removeWorkerStartHook($workerStartHook);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTickRateTime() : float{
|
public function getTickRateTime() : float{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user