World: fixed original promise not getting fulfilled if the chunk became populated=true after a promise was already made (but not fulfilled) to populate it

this could happen if a plugin calls setPopulated(true) on a chunk after a request for its population landed in the queue, but before it actually got processed. In that case, the promise would never get fulfilled.
This commit is contained in:
Dylan K. Taylor 2021-10-31 22:54:37 +00:00
parent 2fa0a914ff
commit 96cfdc79b8
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -2869,9 +2869,9 @@ class World implements ChunkManager{
$this->unregisterChunkLoader($temporaryChunkLoader, $x, $z);
//chunk is already populated; return a pre-resolved promise that will directly fire callbacks assigned
$result = new PromiseResolver();
$result->resolve($chunk);
return $result->getPromise();
$resolver ??= new PromiseResolver();
$resolver->resolve($chunk);
return $resolver->getPromise();
}
/**