diff --git a/src/network/mcpe/NetworkSession.php b/src/network/mcpe/NetworkSession.php index 82f1516b6..fc46f8ae5 100644 --- a/src/network/mcpe/NetworkSession.php +++ b/src/network/mcpe/NetworkSession.php @@ -924,7 +924,7 @@ class NetworkSession{ $this->logger->debug("Tried to send no-longer-active chunk $chunkX $chunkZ in world " . $world->getFolderName()); return; } - if(!$status->equals(UsedChunkStatus::REQUESTED_SENDING())){ + if(!$status->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 diff --git a/src/player/Player.php b/src/player/Player.php index 469c025f7..2f743fea3 100644 --- a/src/player/Player.php +++ b/src/player/Player.php @@ -676,8 +676,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ ++$count; - $this->usedChunks[$index] = UsedChunkStatus::REQUESTED_GENERATION(); - unset($this->loadQueue[$index]); + $this->usedChunks[$index] = UsedChunkStatus::NEEDED(); $this->getWorld()->registerChunkLoader($this->chunkLoader, $X, $Z, true); $this->getWorld()->registerChunkListener($this, $X, $Z); @@ -686,10 +685,15 @@ 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::REQUESTED_GENERATION())){ - throw new AssumptionFailedError("Used chunk status should not have changed while in REQUESTED_GENERATION mode"); + 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; } - $this->usedChunks[$index] = UsedChunkStatus::REQUESTED_SENDING(); + unset($this->loadQueue[$index]); + $this->usedChunks[$index] = UsedChunkStatus::REQUESTED(); $this->getNetworkSession()->startUsingChunk($X, $Z, function() use ($X, $Z, $index) : void{ $this->usedChunks[$index] = UsedChunkStatus::SENT(); diff --git a/src/player/UsedChunkStatus.php b/src/player/UsedChunkStatus.php index fa8227628..bbdb9a061 100644 --- a/src/player/UsedChunkStatus.php +++ b/src/player/UsedChunkStatus.php @@ -32,8 +32,7 @@ use pocketmine\utils\EnumTrait; * @generate-registry-docblock * * @method static UsedChunkStatus NEEDED() - * @method static UsedChunkStatus REQUESTED_GENERATION() - * @method static UsedChunkStatus REQUESTED_SENDING() + * @method static UsedChunkStatus REQUESTED() * @method static UsedChunkStatus SENT() */ final class UsedChunkStatus{ @@ -42,8 +41,7 @@ final class UsedChunkStatus{ protected static function setup() : void{ self::registerAll( new self("NEEDED"), - new self("REQUESTED_GENERATION"), - new self("REQUESTED_SENDING"), + new self("REQUESTED"), new self("SENT") ); }