mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 04:17:07 +00:00
Merge branch 'release/3.3' into release/3.4
This commit is contained in:
commit
d257d36e55
@ -29,7 +29,6 @@ use pocketmine\network\mcpe\protocol\BatchPacket;
|
|||||||
use pocketmine\network\mcpe\protocol\FullChunkDataPacket;
|
use pocketmine\network\mcpe\protocol\FullChunkDataPacket;
|
||||||
use pocketmine\scheduler\AsyncTask;
|
use pocketmine\scheduler\AsyncTask;
|
||||||
use pocketmine\Server;
|
use pocketmine\Server;
|
||||||
use pocketmine\tile\Spawnable;
|
|
||||||
|
|
||||||
class ChunkRequestTask extends AsyncTask{
|
class ChunkRequestTask extends AsyncTask{
|
||||||
|
|
||||||
@ -39,36 +38,22 @@ class ChunkRequestTask extends AsyncTask{
|
|||||||
protected $chunkX;
|
protected $chunkX;
|
||||||
protected $chunkZ;
|
protected $chunkZ;
|
||||||
|
|
||||||
protected $tiles;
|
|
||||||
|
|
||||||
protected $compressionLevel;
|
protected $compressionLevel;
|
||||||
|
|
||||||
public function __construct(Level $level, int $chunkX, int $chunkZ, Chunk $chunk){
|
public function __construct(Level $level, int $chunkX, int $chunkZ, Chunk $chunk){
|
||||||
$this->levelId = $level->getId();
|
$this->levelId = $level->getId();
|
||||||
$this->compressionLevel = $level->getServer()->networkCompressionLevel;
|
$this->compressionLevel = $level->getServer()->networkCompressionLevel;
|
||||||
|
|
||||||
$this->chunk = $chunk->fastSerialize();
|
$this->chunk = $chunk->networkSerialize();
|
||||||
$this->chunkX = $chunkX;
|
$this->chunkX = $chunkX;
|
||||||
$this->chunkZ = $chunkZ;
|
$this->chunkZ = $chunkZ;
|
||||||
|
|
||||||
//TODO: serialize tiles with chunks
|
|
||||||
$tiles = "";
|
|
||||||
foreach($chunk->getTiles() as $tile){
|
|
||||||
if($tile instanceof Spawnable){
|
|
||||||
$tiles .= $tile->getSerializedSpawnCompound();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->tiles = $tiles;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onRun(){
|
public function onRun(){
|
||||||
$chunk = Chunk::fastDeserialize($this->chunk);
|
|
||||||
|
|
||||||
$pk = new FullChunkDataPacket();
|
$pk = new FullChunkDataPacket();
|
||||||
$pk->chunkX = $this->chunkX;
|
$pk->chunkX = $this->chunkX;
|
||||||
$pk->chunkZ = $this->chunkZ;
|
$pk->chunkZ = $this->chunkZ;
|
||||||
$pk->data = $chunk->networkSerialize() . $this->tiles;
|
$pk->data = $this->chunk;
|
||||||
|
|
||||||
$batch = new BatchPacket();
|
$batch = new BatchPacket();
|
||||||
$batch->addPacket($pk);
|
$batch->addPacket($pk);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user