Remove $create parameter from ChunkManager::getChunk()

this restores SimpleChunkManager's behaviour to PM3, removing the need for GeneratorChunkManager (although I'm dubious whether SubChunkExplorer makes any sense in there any more now that we have morton in the mix).
This commit is contained in:
Dylan K. Taylor
2020-10-31 21:54:51 +00:00
parent dec235abab
commit ddda2d1e64
11 changed files with 27 additions and 68 deletions

View File

@ -1,38 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\world\generator;
use pocketmine\world\format\Chunk;
use pocketmine\world\SimpleChunkManager;
use pocketmine\world\World;
class GeneratorChunkManager extends SimpleChunkManager{
public function getChunk(int $chunkX, int $chunkZ, bool $create = false) : ?Chunk{
if(!isset($this->chunks[World::chunkHash($chunkX, $chunkZ)])){
throw new \InvalidArgumentException("Chunk does not exist");
}
return parent::getChunk($chunkX, $chunkZ, $create);
}
}

View File

@ -25,6 +25,7 @@ namespace pocketmine\world\generator;
use pocketmine\scheduler\AsyncTask;
use pocketmine\world\biome\Biome;
use pocketmine\world\SimpleChunkManager;
use pocketmine\world\World;
use function igbinary_serialize;
use function igbinary_unserialize;
@ -56,7 +57,7 @@ class GeneratorRegisterTask extends AsyncTask{
public function onRun() : void{
Biome::init();
$manager = new GeneratorChunkManager($this->worldHeight);
$manager = new SimpleChunkManager($this->worldHeight);
$this->worker->saveToThreadStore("generation.world{$this->worldId}.manager", $manager);
/**

View File

@ -26,6 +26,7 @@ namespace pocketmine\world\generator;
use pocketmine\scheduler\AsyncTask;
use pocketmine\world\format\Chunk;
use pocketmine\world\format\io\FastChunkSerializer;
use pocketmine\world\SimpleChunkManager;
use pocketmine\world\World;
class PopulationTask extends AsyncTask{
@ -73,7 +74,7 @@ class PopulationTask extends AsyncTask{
public function onRun() : void{
$manager = $this->worker->getFromThreadStore("generation.world{$this->worldId}.manager");
$generator = $this->worker->getFromThreadStore("generation.world{$this->worldId}.generator");
if(!($manager instanceof GeneratorChunkManager) or !($generator instanceof Generator)){
if(!($manager instanceof SimpleChunkManager) or !($generator instanceof Generator)){
$this->state = false;
return;
}