mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 11:57:10 +00:00
disable-block-ticking directive now supports names a la /give
This commit is contained in:
parent
0bc578b8fc
commit
3faeb5a556
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user