mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
FastChunkSerializer no longer encodes chunk coordinates
in cases like PopulationTask it makes more sense to store the coordinates separately where they can be stored more efficiently (once instead of 9 times) In addition, PopulationTask shouldn't need to serialize an empty chunk just to copy coordinates. I've made changes like this in other areas already in preparation for the day when chunks no longer contain their coordinates, so this brings us one step closer to that goal.
This commit is contained in:
@ -61,8 +61,6 @@ final class FastChunkSerializer{
|
||||
$includeLight = $includeLight && $chunk->isLightPopulated() === true;
|
||||
|
||||
$stream = new BinaryStream();
|
||||
$stream->putInt($chunk->getX());
|
||||
$stream->putInt($chunk->getZ());
|
||||
$stream->putByte(
|
||||
($includeLight ? self::FLAG_HAS_LIGHT : 0) |
|
||||
($chunk->isPopulated() ? self::FLAG_POPULATED : 0) |
|
||||
@ -109,11 +107,9 @@ final class FastChunkSerializer{
|
||||
/**
|
||||
* Deserializes a fast-serialized chunk
|
||||
*/
|
||||
public static function deserialize(string $data) : Chunk{
|
||||
public static function deserialize(string $data, int $chunkX, int $chunkZ) : Chunk{
|
||||
$stream = new BinaryStream($data);
|
||||
|
||||
$x = $stream->getInt();
|
||||
$z = $stream->getInt();
|
||||
$flags = $stream->getByte();
|
||||
$lightPopulated = (bool) ($flags & self::FLAG_HAS_LIGHT);
|
||||
$terrainPopulated = (bool) ($flags & self::FLAG_POPULATED);
|
||||
@ -148,7 +144,7 @@ final class FastChunkSerializer{
|
||||
}
|
||||
}
|
||||
|
||||
$chunk = new Chunk($x, $z, $subChunks, null, null, $biomeIds, $heightMap);
|
||||
$chunk = new Chunk($chunkX, $chunkZ, $subChunks, null, null, $biomeIds, $heightMap);
|
||||
$chunk->setGenerated($terrainGenerated);
|
||||
$chunk->setPopulated($terrainPopulated);
|
||||
$chunk->setLightPopulated($lightPopulated);
|
||||
|
Reference in New Issue
Block a user