Added options and API to enable/disable random ticking for specific block IDs

This commit is contained in:
Dylan K. Taylor 2016-12-13 12:03:24 +00:00
parent 4dd0a13511
commit 21f5be27b6
2 changed files with 18 additions and 0 deletions

View File

@ -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 = [];

View File

@ -131,6 +131,9 @@ chunk-ticking:
tick-radius: 3
light-updates: false
clear-tick-list: true
#IDs of blocks not to perform random ticking on.
disable-block-ticking:
#- 2 # grass
chunk-generation:
#Max. amount of chunks in the waiting queue to be generated