mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 08:44:01 +00:00
LevelProvider: Remove redundant method requestChunkTask()
This removes one more dependency that LevelProvider has on Level.
This commit is contained in:
parent
7264ce43ae
commit
8a3f8b4706
@ -47,8 +47,10 @@ use pocketmine\event\Timings;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemFactory;
|
||||
use pocketmine\level\format\Chunk;
|
||||
use pocketmine\level\format\ChunkException;
|
||||
use pocketmine\level\format\EmptySubChunk;
|
||||
use pocketmine\level\format\io\BaseLevelProvider;
|
||||
use pocketmine\level\format\io\ChunkRequestTask;
|
||||
use pocketmine\level\format\io\LevelProvider;
|
||||
use pocketmine\level\generator\GenerationTask;
|
||||
use pocketmine\level\generator\Generator;
|
||||
@ -2544,8 +2546,12 @@ class Level implements ChunkManager, Metadatable{
|
||||
}
|
||||
$this->timings->syncChunkSendPrepareTimer->startTiming();
|
||||
|
||||
$task = $this->provider->requestChunkTask($x, $z);
|
||||
$this->server->getScheduler()->scheduleAsyncTask($task);
|
||||
$chunk = $this->provider->getChunk($x, $z, false);
|
||||
if(!($chunk instanceof Chunk)){
|
||||
throw new ChunkException("Invalid Chunk sent");
|
||||
}
|
||||
|
||||
$this->server->getScheduler()->scheduleAsyncTask(new ChunkRequestTask($this, $chunk));
|
||||
|
||||
$this->timings->syncChunkSendPrepareTimer->stopTiming();
|
||||
}
|
||||
|
@ -23,8 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level\format\io;
|
||||
|
||||
use pocketmine\level\format\Chunk;
|
||||
use pocketmine\level\format\ChunkException;
|
||||
use pocketmine\level\generator\Generator;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\level\LevelException;
|
||||
@ -32,7 +30,6 @@ use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\BigEndianNBTStream;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\scheduler\AsyncTask;
|
||||
|
||||
abstract class BaseLevelProvider implements LevelProvider{
|
||||
/** @var Level */
|
||||
@ -127,13 +124,4 @@ abstract class BaseLevelProvider implements LevelProvider{
|
||||
$buffer = $nbt->writeCompressed();
|
||||
file_put_contents($this->getPath() . "level.dat", $buffer);
|
||||
}
|
||||
|
||||
public function requestChunkTask(int $x, int $z) : AsyncTask{
|
||||
$chunk = $this->getChunk($x, $z, false);
|
||||
if(!($chunk instanceof Chunk)){
|
||||
throw new ChunkException("Invalid Chunk sent");
|
||||
}
|
||||
|
||||
return new ChunkRequestTask($this->level, $chunk);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ namespace pocketmine\level\format\io;
|
||||
use pocketmine\level\format\Chunk;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\scheduler\AsyncTask;
|
||||
|
||||
interface LevelProvider{
|
||||
|
||||
@ -161,16 +160,6 @@ interface LevelProvider{
|
||||
*/
|
||||
public function isChunkPopulated(int $chunkX, int $chunkZ) : bool;
|
||||
|
||||
/**
|
||||
* Requests a MC: PE network chunk to be sent
|
||||
*
|
||||
* @param int $x
|
||||
* @param int $z
|
||||
*
|
||||
* @return AsyncTask
|
||||
*/
|
||||
public function requestChunkTask(int $x, int $z) : AsyncTask;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user