mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Require ext-chunkutils ^0.3.0
This commit is contained in:
@ -32,8 +32,10 @@ use pocketmine\network\mcpe\protocol\serializer\PacketSerializerContext;
|
||||
use pocketmine\utils\Binary;
|
||||
use pocketmine\utils\BinaryStream;
|
||||
use pocketmine\world\format\Chunk;
|
||||
use pocketmine\world\format\PalettedBlockArray;
|
||||
use pocketmine\world\format\SubChunk;
|
||||
use function count;
|
||||
use function str_repeat;
|
||||
|
||||
final class ChunkSerializer{
|
||||
|
||||
@ -81,8 +83,17 @@ final class ChunkSerializer{
|
||||
$stream->putByte(count($layers));
|
||||
|
||||
foreach($layers as $blocks){
|
||||
$stream->putByte(($blocks->getBitsPerBlock() << 1) | ($persistentBlockStates ? 0 : 1));
|
||||
$stream->put($blocks->getWordArray());
|
||||
if($blocks->getBitsPerBlock() === 0){
|
||||
//TODO: we use these in memory, but the game doesn't support them yet
|
||||
//polyfill them with 1-bpb instead
|
||||
$bitsPerBlock = 1;
|
||||
$words = str_repeat("\x00", PalettedBlockArray::getExpectedWordArraySize(1));
|
||||
}else{
|
||||
$bitsPerBlock = $blocks->getBitsPerBlock();
|
||||
$words = $blocks->getWordArray();
|
||||
}
|
||||
$stream->putByte(($bitsPerBlock << 1) | ($persistentBlockStates ? 0 : 1));
|
||||
$stream->put($words);
|
||||
$palette = $blocks->getPalette();
|
||||
|
||||
//these LSHIFT by 1 uvarints are optimizations: the client expects zigzag varints here
|
||||
|
Reference in New Issue
Block a user