diff --git a/resources/pocketmine.yml b/resources/pocketmine.yml index 2e8492624..7d0a337a7 100644 --- a/resources/pocketmine.yml +++ b/resources/pocketmine.yml @@ -128,7 +128,9 @@ chunk-ticking: blocks-per-subchunk-per-tick: 3 #IDs of blocks not to perform random ticking on. disable-block-ticking: - #- 2 # grass + #- grass + #- ice + #- fire chunk-generation: #Max. amount of chunks in the waiting queue to be populated diff --git a/src/world/World.php b/src/world/World.php index 777a2e1f4..19709e3ac 100644 --- a/src/world/World.php +++ b/src/world/World.php @@ -54,6 +54,7 @@ use pocketmine\event\world\WorldSaveEvent; use pocketmine\item\Item; use pocketmine\item\ItemUseResult; use pocketmine\item\LegacyStringToItemParser; +use pocketmine\item\StringToItemParser; use pocketmine\item\VanillaItems; use pocketmine\lang\KnownTranslationFactory; use pocketmine\math\AxisAlignedBB; @@ -95,7 +96,6 @@ use pocketmine\world\sound\BlockPlaceSound; use pocketmine\world\sound\Sound; use pocketmine\world\utils\SubChunkExplorer; use function abs; -use function array_fill_keys; use function array_filter; use function array_key_exists; use function array_map; @@ -118,6 +118,7 @@ use function morton2d_encode; use function morton3d_decode; use function morton3d_encode; use function mt_rand; +use function preg_match; use function spl_object_id; use function strtolower; use function trim; @@ -453,10 +454,28 @@ class World implements ChunkManager{ $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); - $dontTickBlocks = array_fill_keys($cfg->getProperty("chunk-ticking.disable-block-ticking", []), true); + $dontTickBlocks = []; + $parser = StringToItemParser::getInstance(); + foreach($cfg->getProperty("chunk-ticking.disable-block-ticking", []) as $name){ + $name = (string) $name; + $item = $parser->parse($name); + if($item !== null){ + $block = $item->getBlock(); + }elseif(preg_match("/^-?\d+$/", $name) === 1){ + $block = BlockFactory::getInstance()->get((int) $name, 0); + }else{ + //TODO: we probably ought to log an error here + continue; + } + + if($block->getId() !== BlockLegacyIds::AIR){ + $dontTickBlocks[$block->getTypeId()] = $name; + } + } foreach(BlockFactory::getInstance()->getAllKnownStates() as $state){ - if(!isset($dontTickBlocks[$state->getId()]) and $state->ticksRandomly()){ + $dontTickName = $dontTickBlocks[$state->getTypeId()] ?? null; + if($dontTickName === null && !$state->ticksRandomly()){ $this->randomTickBlocks[$state->getFullId()] = true; } }