mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 10:22:56 +00:00
Async chunk compression and serialization is now non-optional
This commit is contained in:
@ -2409,13 +2409,13 @@ class Level implements ChunkManager, Metadatable{
|
||||
}
|
||||
}
|
||||
|
||||
public function chunkRequestCallback(int $x, int $z, string $payload){
|
||||
public function chunkRequestCallback(int $x, int $z, BatchPacket $payload){
|
||||
$this->timings->syncChunkSendTimer->startTiming();
|
||||
|
||||
$index = Level::chunkHash($x, $z);
|
||||
|
||||
if(!isset($this->chunkCache[$index]) and $this->cacheChunks and $this->server->getMemoryManager()->canUseChunkCache()){
|
||||
$this->chunkCache[$index] = Level::getChunkCacheFromData($x, $z, $payload);
|
||||
$this->chunkCache[$index] = $payload;
|
||||
$this->sendChunkFromCache($x, $z);
|
||||
$this->timings->syncChunkSendTimer->stopTiming();
|
||||
return;
|
||||
@ -2886,28 +2886,6 @@ class Level implements ChunkManager, Metadatable{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $chunkX
|
||||
* @param int $chunkZ
|
||||
* @param string $payload
|
||||
*
|
||||
* @return DataPacket
|
||||
*/
|
||||
public static function getChunkCacheFromData($chunkX, $chunkZ, $payload){
|
||||
$pk = new FullChunkDataPacket();
|
||||
$pk->chunkX = $chunkX;
|
||||
$pk->chunkZ = $chunkZ;
|
||||
$pk->data = $payload;
|
||||
$pk->encode();
|
||||
|
||||
$batch = new BatchPacket();
|
||||
$batch->payload = zlib_encode(Binary::writeUnsignedVarInt(strlen($pk->getBuffer())) . $pk->getBuffer(), ZLIB_ENCODING_DEFLATE, Server::getInstance()->networkCompressionLevel);
|
||||
|
||||
$batch->encode();
|
||||
$batch->isEncoded = true;
|
||||
return $batch;
|
||||
}
|
||||
|
||||
public function setMetadata($metadataKey, MetadataValue $metadataValue){
|
||||
$this->server->getLevelMetadata()->setMetadata($this, $metadataKey, $metadataValue);
|
||||
}
|
||||
|
Reference in New Issue
Block a user