mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-10 05:34:54 +00:00
[Network]ChunkSerializer: allow injecting RuntimeBlockMapping
this will allow the same serializer to be reused with different mapping tables (will be needed for multi version).
This commit is contained in:
parent
53a33e8c20
commit
c2857a91bd
@ -25,6 +25,7 @@ namespace pocketmine\network\mcpe;
|
||||
|
||||
use pocketmine\network\mcpe\compression\CompressBatchPromise;
|
||||
use pocketmine\network\mcpe\compression\Compressor;
|
||||
use pocketmine\network\mcpe\convert\RuntimeBlockMapping;
|
||||
use pocketmine\network\mcpe\protocol\LevelChunkPacket;
|
||||
use pocketmine\network\mcpe\protocol\serializer\PacketBatch;
|
||||
use pocketmine\network\mcpe\serializer\ChunkSerializer;
|
||||
@ -67,7 +68,7 @@ class ChunkRequestTask extends AsyncTask{
|
||||
public function onRun() : void{
|
||||
$chunk = FastChunkSerializer::deserialize($this->chunk);
|
||||
$subCount = ChunkSerializer::getSubChunkCount($chunk);
|
||||
$payload = ChunkSerializer::serialize($chunk, $this->tiles);
|
||||
$payload = ChunkSerializer::serialize($chunk, RuntimeBlockMapping::getInstance(), $this->tiles);
|
||||
$this->setResult($this->compressor->compress(PacketBatch::fromPackets(LevelChunkPacket::withoutCache($this->chunkX, $this->chunkZ, $subCount, $payload))->getBuffer()));
|
||||
}
|
||||
|
||||
|
@ -51,10 +51,9 @@ final class ChunkSerializer{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function serialize(Chunk $chunk, ?string $tiles = null) : string{
|
||||
public static function serialize(Chunk $chunk, RuntimeBlockMapping $blockMapper, ?string $tiles = null) : string{
|
||||
$stream = new NetworkBinaryStream();
|
||||
$subChunkCount = self::getSubChunkCount($chunk);
|
||||
$blockMapper = RuntimeBlockMapping::getInstance();
|
||||
for($y = 0; $y < $subChunkCount; ++$y){
|
||||
$layers = $chunk->getSubChunk($y)->getBlockLayers();
|
||||
$stream->putByte(8); //version
|
||||
|
Loading…
x
Reference in New Issue
Block a user