mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Convert BlockFactory to singleton
This commit is contained in:
@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\world\generator;
|
||||
|
||||
use pocketmine\block\BlockFactory;
|
||||
use pocketmine\scheduler\AsyncTask;
|
||||
use pocketmine\world\biome\Biome;
|
||||
use pocketmine\world\World;
|
||||
@ -56,7 +55,6 @@ class GeneratorRegisterTask extends AsyncTask{
|
||||
}
|
||||
|
||||
public function onRun() : void{
|
||||
BlockFactory::init();
|
||||
Biome::init();
|
||||
$manager = new GeneratorChunkManager($this->worldHeight);
|
||||
$this->worker->saveToThreadStore("generation.world{$this->worldId}.manager", $manager);
|
||||
|
@ -119,8 +119,9 @@ class PopulationTask extends AsyncTask{
|
||||
$chunk = $manager->getChunk($chunk->getX(), $chunk->getZ());
|
||||
$chunk->setPopulated();
|
||||
|
||||
$chunk->recalculateHeightMap(BlockFactory::$lightFilter, BlockFactory::$diffusesSkyLight);
|
||||
$chunk->populateSkyLight(BlockFactory::$lightFilter);
|
||||
$blockFactory = BlockFactory::getInstance();
|
||||
$chunk->recalculateHeightMap($blockFactory->lightFilter, $blockFactory->diffusesSkyLight);
|
||||
$chunk->populateSkyLight($blockFactory->lightFilter);
|
||||
$chunk->setLightPopulated();
|
||||
|
||||
$this->chunk = FastChunkSerializer::serialize($chunk);
|
||||
|
@ -36,6 +36,7 @@ class GroundCover extends Populator{
|
||||
|
||||
public function populate(ChunkManager $world, int $chunkX, int $chunkZ, Random $random) : void{
|
||||
$chunk = $world->getChunk($chunkX, $chunkZ);
|
||||
$factory = BlockFactory::getInstance();
|
||||
for($x = 0; $x < 16; ++$x){
|
||||
for($z = 0; $z < 16; ++$z){
|
||||
$biome = Biome::getBiome($chunk->getBiomeId($x, $z));
|
||||
@ -48,7 +49,7 @@ class GroundCover extends Populator{
|
||||
|
||||
$startY = 127;
|
||||
for(; $startY > 0; --$startY){
|
||||
if(!BlockFactory::fromFullBlock($chunk->getFullBlock($x, $startY, $z))->isTransparent()){
|
||||
if(!$factory->fromFullBlock($chunk->getFullBlock($x, $startY, $z))->isTransparent()){
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -56,7 +57,7 @@ class GroundCover extends Populator{
|
||||
$endY = $startY - count($cover);
|
||||
for($y = $startY; $y > $endY and $y >= 0; --$y){
|
||||
$b = $cover[$startY - $y];
|
||||
$id = BlockFactory::fromFullBlock($chunk->getFullBlock($x, $y, $z));
|
||||
$id = $factory->fromFullBlock($chunk->getFullBlock($x, $y, $z));
|
||||
if($id->getId() === BlockLegacyIds::AIR and $b->isSolid()){
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user