From 21f5be27b6c9ee351cb7a91b9773dd358496954e Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 13 Dec 2016 12:03:24 +0000 Subject: [PATCH] Added options and API to enable/disable random ticking for specific block IDs --- src/pocketmine/level/Level.php | 15 +++++++++++++++ src/pocketmine/resources/pocketmine.yml | 3 +++ 2 files changed, 18 insertions(+) diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index cd38f40ea..29002aa36 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -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 = []; diff --git a/src/pocketmine/resources/pocketmine.yml b/src/pocketmine/resources/pocketmine.yml index 442258b5c..27185f79e 100644 --- a/src/pocketmine/resources/pocketmine.yml +++ b/src/pocketmine/resources/pocketmine.yml @@ -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