mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 10:22:56 +00:00
Added options and API to enable/disable random ticking for specific block IDs
This commit is contained in:
@ -346,6 +346,13 @@ class Level implements ChunkManager, Metadatable{
|
||||
$this->clearChunksOnTick = (bool) $this->server->getProperty("chunk-ticking.clear-tick-list", true);
|
||||
$this->cacheChunks = (bool) $this->server->getProperty("chunk-sending.cache-chunks", false);
|
||||
|
||||
$dontTickBlocks = $this->server->getProperty("chunk-ticking.disable-block-ticking", []);
|
||||
foreach($dontTickBlocks as $id){
|
||||
if(isset($this->randomTickBlocks[$id])){
|
||||
unset($this->randomTickBlocks[$id]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->timings = new LevelTimings($this);
|
||||
$this->temporalPosition = new Position(0, 0, 0, $this);
|
||||
$this->temporalVector = new Vector3(0, 0, 0);
|
||||
@ -877,6 +884,14 @@ class Level implements ChunkManager, Metadatable{
|
||||
unset($this->chunkCache[Level::chunkHash($chunkX, $chunkZ)]);
|
||||
}
|
||||
|
||||
public function addRandomTickedBlock(int $id){
|
||||
$this->randomTickBlocks[$id] = Block::$list[$id];
|
||||
}
|
||||
|
||||
public function removeRandomTickedBlock(int $id){
|
||||
unset($this->randomTickBlocks[$id]);
|
||||
}
|
||||
|
||||
private function tickChunks(){
|
||||
if($this->chunksPerTick <= 0 or count($this->loaders) === 0){
|
||||
$this->chunkTickList = [];
|
||||
|
Reference in New Issue
Block a user