diff --git a/resources/pocketmine.yml b/resources/pocketmine.yml index 408b5b95b3d..350398aa184 100644 --- a/resources/pocketmine.yml +++ b/resources/pocketmine.yml @@ -215,6 +215,7 @@ worlds: # seed: 404 # generator: FLAT # preset: 2;bedrock,59xstone,3xdirt,grass;1 + # blocks-per-subchunk-per-tick: 3 plugins: #Setting this to true will cause the legacy structure to be used where plugin data is placed inside the --plugins dir. diff --git a/src/world/World.php b/src/world/World.php index 2ff2b5b2ea9..1f35c9e47b7 100644 --- a/src/world/World.php +++ b/src/world/World.php @@ -520,7 +520,7 @@ public function __construct( $this->logger->warning("\"chunk-ticking.per-tick\" setting is deprecated, but you've used it to disable chunk ticking. Set \"chunk-ticking.tick-radius\" to 0 in \"pocketmine.yml\" instead."); $this->chunkTickRadius = 0; } - $this->tickedBlocksPerSubchunkPerTick = $cfg->getPropertyInt(YmlServerProperties::CHUNK_TICKING_BLOCKS_PER_SUBCHUNK_PER_TICK, self::DEFAULT_TICKED_BLOCKS_PER_SUBCHUNK_PER_TICK); + $this->initTickedBlocksPerSubchunkPerTick($cfg); $this->maxConcurrentChunkPopulationTasks = $cfg->getPropertyInt(YmlServerProperties::CHUNK_GENERATION_POPULATION_QUEUE_SIZE, 2); $this->initRandomTickBlocksFromConfig($cfg); @@ -3461,4 +3461,23 @@ public function unloadChunks(bool $force = false) : void{ } } } + + private function initTickedBlocksPerSubchunkPerTick(ServerConfigGroup $cfg) : void { + $this->tickedBlocksPerSubchunkPerTick = $cfg->getPropertyInt(YmlServerProperties::CHUNK_TICKING_BLOCKS_PER_SUBCHUNK_PER_TICK, self::DEFAULT_TICKED_BLOCKS_PER_SUBCHUNK_PER_TICK); + $specificTick = $cfg->getPropertyInt("worlds." . $this->getFolderName() . ".blocks-per-subchunk-per-tick", -1); + if($specificTick >= 0){ + $this->tickedBlocksPerSubchunkPerTick = $specificTick; + } + } + + public function setTickedBlocksPerSubchunkPerTick(int $tickedBlocksPerSubchunkPerTick) : void{ + if($tickedBlocksPerSubchunkPerTick < 0){ + throw new \InvalidArgumentException("Ticked blocks per subchunk per tick must be non-negative"); + } + $this->tickedBlocksPerSubchunkPerTick = $tickedBlocksPerSubchunkPerTick; + } + + public function getTickedBlocksPerSubchunkPerTick() : int{ + return $this->tickedBlocksPerSubchunkPerTick; + } }