mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 17:29:44 +00:00
FastChunkSerializer: remove legacy code, simplify encoding
this is also faster than the old technique (theoretically).
This commit is contained in:
parent
02ff8d671b
commit
dddc3e8407
@ -60,32 +60,30 @@ final class FastChunkSerializer{
|
|||||||
$stream->putByte(($chunk->isLightPopulated() ? 4 : 0) | ($chunk->isPopulated() ? 2 : 0) | ($chunk->isGenerated() ? 1 : 0));
|
$stream->putByte(($chunk->isLightPopulated() ? 4 : 0) | ($chunk->isPopulated() ? 2 : 0) | ($chunk->isGenerated() ? 1 : 0));
|
||||||
if($chunk->isGenerated()){
|
if($chunk->isGenerated()){
|
||||||
//subchunks
|
//subchunks
|
||||||
$count = 0;
|
$subChunks = $chunk->getSubChunks();
|
||||||
$subStream = new BinaryStream();
|
$count = $subChunks->count();
|
||||||
foreach($chunk->getSubChunks() as $y => $subChunk){
|
$stream->putByte($count);
|
||||||
++$count;
|
|
||||||
|
|
||||||
$subStream->putByte($y);
|
foreach($subChunks as $y => $subChunk){
|
||||||
|
$stream->putByte($y);
|
||||||
$layers = $subChunk->getBlockLayers();
|
$layers = $subChunk->getBlockLayers();
|
||||||
$subStream->putByte(count($subChunk->getBlockLayers()));
|
$stream->putByte(count($layers));
|
||||||
foreach($layers as $blocks){
|
foreach($layers as $blocks){
|
||||||
$wordArray = $blocks->getWordArray();
|
$wordArray = $blocks->getWordArray();
|
||||||
$palette = $blocks->getPalette();
|
$palette = $blocks->getPalette();
|
||||||
|
|
||||||
$subStream->putByte($blocks->getBitsPerBlock());
|
$stream->putByte($blocks->getBitsPerBlock());
|
||||||
$subStream->put($wordArray);
|
$stream->put($wordArray);
|
||||||
$serialPalette = pack("N*", ...$palette);
|
$serialPalette = pack("N*", ...$palette);
|
||||||
$subStream->putInt(strlen($serialPalette));
|
$stream->putInt(strlen($serialPalette));
|
||||||
$subStream->put($serialPalette);
|
$stream->put($serialPalette);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($chunk->isLightPopulated()){
|
if($chunk->isLightPopulated()){
|
||||||
$subStream->put($subChunk->getBlockSkyLightArray()->getData());
|
$stream->put($subChunk->getBlockSkyLightArray()->getData());
|
||||||
$subStream->put($subChunk->getBlockLightArray()->getData());
|
$stream->put($subChunk->getBlockLightArray()->getData());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$stream->putByte($count);
|
|
||||||
$stream->put($subStream->getBuffer());
|
|
||||||
|
|
||||||
//biomes
|
//biomes
|
||||||
$stream->put($chunk->getBiomeIdArray());
|
$stream->put($chunk->getBiomeIdArray());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user