mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 20:07:09 +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
|
blocks-per-subchunk-per-tick: 3
|
||||||
#IDs of blocks not to perform random ticking on.
|
#IDs of blocks not to perform random ticking on.
|
||||||
disable-block-ticking:
|
disable-block-ticking:
|
||||||
#- 2 # grass
|
#- grass
|
||||||
|
#- ice
|
||||||
|
#- fire
|
||||||
|
|
||||||
chunk-generation:
|
chunk-generation:
|
||||||
#Max. amount of chunks in the waiting queue to be populated
|
#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\Item;
|
||||||
use pocketmine\item\ItemUseResult;
|
use pocketmine\item\ItemUseResult;
|
||||||
use pocketmine\item\LegacyStringToItemParser;
|
use pocketmine\item\LegacyStringToItemParser;
|
||||||
|
use pocketmine\item\StringToItemParser;
|
||||||
use pocketmine\item\VanillaItems;
|
use pocketmine\item\VanillaItems;
|
||||||
use pocketmine\lang\KnownTranslationFactory;
|
use pocketmine\lang\KnownTranslationFactory;
|
||||||
use pocketmine\math\AxisAlignedBB;
|
use pocketmine\math\AxisAlignedBB;
|
||||||
@ -95,7 +96,6 @@ use pocketmine\world\sound\BlockPlaceSound;
|
|||||||
use pocketmine\world\sound\Sound;
|
use pocketmine\world\sound\Sound;
|
||||||
use pocketmine\world\utils\SubChunkExplorer;
|
use pocketmine\world\utils\SubChunkExplorer;
|
||||||
use function abs;
|
use function abs;
|
||||||
use function array_fill_keys;
|
|
||||||
use function array_filter;
|
use function array_filter;
|
||||||
use function array_key_exists;
|
use function array_key_exists;
|
||||||
use function array_map;
|
use function array_map;
|
||||||
@ -118,6 +118,7 @@ use function morton2d_encode;
|
|||||||
use function morton3d_decode;
|
use function morton3d_decode;
|
||||||
use function morton3d_encode;
|
use function morton3d_encode;
|
||||||
use function mt_rand;
|
use function mt_rand;
|
||||||
|
use function preg_match;
|
||||||
use function spl_object_id;
|
use function spl_object_id;
|
||||||
use function strtolower;
|
use function strtolower;
|
||||||
use function trim;
|
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->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);
|
$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){
|
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;
|
$this->randomTickBlocks[$state->getFullId()] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user