mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-12 00:39: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.
|
* The serialization format **is not intended for permanent storage** and may change without warning.
|
||||||
*/
|
*/
|
||||||
final class FastChunkSerializer{
|
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(){
|
private function __construct(){
|
||||||
//NOOP
|
//NOOP
|
||||||
@ -60,7 +63,11 @@ final class FastChunkSerializer{
|
|||||||
$stream = new BinaryStream();
|
$stream = new BinaryStream();
|
||||||
$stream->putInt($chunk->getX());
|
$stream->putInt($chunk->getX());
|
||||||
$stream->putInt($chunk->getZ());
|
$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()){
|
if($chunk->isGenerated()){
|
||||||
//subchunks
|
//subchunks
|
||||||
$subChunks = $chunk->getSubChunks();
|
$subChunks = $chunk->getSubChunks();
|
||||||
@ -107,9 +114,9 @@ final class FastChunkSerializer{
|
|||||||
$x = $stream->getInt();
|
$x = $stream->getInt();
|
||||||
$z = $stream->getInt();
|
$z = $stream->getInt();
|
||||||
$flags = $stream->getByte();
|
$flags = $stream->getByte();
|
||||||
$lightPopulated = (bool) ($flags & 4);
|
$lightPopulated = (bool) ($flags & self::FLAG_HAS_LIGHT);
|
||||||
$terrainPopulated = (bool) ($flags & 2);
|
$terrainPopulated = (bool) ($flags & self::FLAG_POPULATED);
|
||||||
$terrainGenerated = (bool) ($flags & 1);
|
$terrainGenerated = (bool) ($flags & self::FLAG_GENERATED);
|
||||||
|
|
||||||
$subChunks = [];
|
$subChunks = [];
|
||||||
$biomeIds = null;
|
$biomeIds = null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user