Player: return from callback if used chunk status is not REQUESTED_GENERATION()

this can happen especially on large render distances when flying fast and changing direction - we decide we don't want the chunk, then, after changing direction and re-ordering chunks, we decide we do want it again, and end up registering a second callback. In this case, we need to ensure that only one of the callbacks gets executed (it doesn't matter which one).
This commit is contained in:
Dylan K. Taylor 2021-11-01 01:45:49 +00:00
parent c781efcf90
commit 46b7d35cd3
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -687,7 +687,10 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
return;
}
if(!$this->usedChunks[$index]->equals(UsedChunkStatus::REQUESTED_GENERATION())){
throw new AssumptionFailedError("Used chunk status should not have changed while in REQUESTED_GENERATION mode");
//We may have previously requested this, decided we didn't want it, and then decided we did want
//it again, all before the generation request got executed. In that case, the promise would have
//multiple callbacks for this player. In that case, only the first one matters.
return;
}
$this->usedChunks[$index] = UsedChunkStatus::REQUESTED_SENDING();