Be less dependent on AsyncTask->onCompletion() Server parameter

this is going to get removed soon.
This commit is contained in:
Dylan K. Taylor
2018-08-04 15:56:14 +01:00
parent 779d92c656
commit 20f3b82d52
6 changed files with 27 additions and 26 deletions

View File

@ -30,11 +30,10 @@ use pocketmine\Server;
class LightPopulationTask extends AsyncTask{
public $levelId;
public $chunk;
public function __construct(Level $level, Chunk $chunk){
$this->levelId = $level->getId();
$this->storeLocal($level);
$this->chunk = $chunk->fastSerialize();
}
@ -50,8 +49,9 @@ class LightPopulationTask extends AsyncTask{
}
public function onCompletion(Server $server){
$level = $server->getLevel($this->levelId);
if($level !== null){
/** @var Level $level */
$level = $this->fetchLocal();
if(!$level->isClosed()){
/** @var Chunk $chunk */
$chunk = Chunk::fastDeserialize($this->chunk);
$level->generateChunkCallback($chunk->getX(), $chunk->getZ(), $chunk);