diff --git a/src/player/Player.php b/src/player/Player.php index bffee7087..2350c3863 100644 --- a/src/player/Player.php +++ b/src/player/Player.php @@ -733,6 +733,13 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ if(!$this->isConnected() || !isset($this->usedChunks[$index]) || $world !== $this->getWorld()){ return; } + if(!$this->usedChunks[$index]->equals(UsedChunkStatus::NEEDED())){ + //TODO: make this an error + //we may have added multiple completion handlers, since the Player keeps re-requesting chunks + //it doesn't have yet (a relic from the old system, but also currently relied on for chunk resends). + //in this event, make sure we don't try to send the chunk multiple times. + return; + } unset($this->loadQueue[$index]); $this->usedChunks[$index] = UsedChunkStatus::REQUESTED(); @@ -741,6 +748,13 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ $this->logger->debug("Tried to send no-longer-active chunk $X $Z in world " . $world->getFolderName()); return; } + if(!$this->usedChunks[$index]->equals(UsedChunkStatus::REQUESTED())){ + //TODO: make this an error + //this could be triggered due to the shitty way that chunk resends are handled + //right now - not because of the spammy re-requesting, but because the chunk status reverts + //to NEEDED if they want to be resent. + return; + } $this->usedChunks[$index] = UsedChunkStatus::SENT(); if($this->spawnChunkLoadCount === -1){ $this->spawnEntitiesOnChunk($X, $Z);