mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-11 08:19:45 +00:00
FastChunkSerializer: added constants for internal flags
This commit is contained in:
parent
82d361d75f
commit
a31240f60b
@ -41,6 +41,9 @@ use function unpack;
|
||||
* The serialization format **is not intended for permanent storage** and may change without warning.
|
||||
*/
|
||||
final class FastChunkSerializer{
|
||||
private const FLAG_GENERATED = 1 << 0;
|
||||
private const FLAG_POPULATED = 1 << 1;
|
||||
private const FLAG_HAS_LIGHT = 1 << 2;
|
||||
|
||||
private function __construct(){
|
||||
//NOOP
|
||||
@ -60,7 +63,11 @@ final class FastChunkSerializer{
|
||||
$stream = new BinaryStream();
|
||||
$stream->putInt($chunk->getX());
|
||||
$stream->putInt($chunk->getZ());
|
||||
$stream->putByte(($includeLight ? 4 : 0) | ($chunk->isPopulated() ? 2 : 0) | ($chunk->isGenerated() ? 1 : 0));
|
||||
$stream->putByte(
|
||||
($includeLight ? self::FLAG_HAS_LIGHT : 0) |
|
||||
($chunk->isPopulated() ? self::FLAG_POPULATED : 0) |
|
||||
($chunk->isGenerated() ? self::FLAG_GENERATED : 0)
|
||||
);
|
||||
if($chunk->isGenerated()){
|
||||
//subchunks
|
||||
$subChunks = $chunk->getSubChunks();
|
||||
@ -107,9 +114,9 @@ final class FastChunkSerializer{
|
||||
$x = $stream->getInt();
|
||||
$z = $stream->getInt();
|
||||
$flags = $stream->getByte();
|
||||
$lightPopulated = (bool) ($flags & 4);
|
||||
$terrainPopulated = (bool) ($flags & 2);
|
||||
$terrainGenerated = (bool) ($flags & 1);
|
||||
$lightPopulated = (bool) ($flags & self::FLAG_HAS_LIGHT);
|
||||
$terrainPopulated = (bool) ($flags & self::FLAG_POPULATED);
|
||||
$terrainGenerated = (bool) ($flags & self::FLAG_GENERATED);
|
||||
|
||||
$subChunks = [];
|
||||
$biomeIds = null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user