mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-16 19:59:11 +00:00
WorldProvider: allow loadChunk() to return additional information about the loaded chunk data
this will be needed for dealing with #5733. I don't plan to fix that before 5.0, but we need to make the appropriate BC breaks now, before release.
This commit is contained in:
@@ -36,6 +36,7 @@ use pocketmine\world\format\Chunk;
|
||||
use pocketmine\world\format\io\ChunkData;
|
||||
use pocketmine\world\format\io\ChunkUtils;
|
||||
use pocketmine\world\format\io\exception\CorruptedChunkException;
|
||||
use pocketmine\world\format\io\LoadedChunkData;
|
||||
use pocketmine\world\format\PalettedBlockArray;
|
||||
use pocketmine\world\format\SubChunk;
|
||||
use function strlen;
|
||||
@@ -54,7 +55,7 @@ trait LegacyAnvilChunkTrait{
|
||||
/**
|
||||
* @throws CorruptedChunkException
|
||||
*/
|
||||
protected function deserializeChunk(string $data) : ?ChunkData{
|
||||
protected function deserializeChunk(string $data) : ?LoadedChunkData{
|
||||
$decompressed = @zlib_decode($data);
|
||||
if($decompressed === false){
|
||||
throw new CorruptedChunkException("Failed to decompress chunk NBT");
|
||||
@@ -99,13 +100,17 @@ trait LegacyAnvilChunkTrait{
|
||||
}
|
||||
}
|
||||
|
||||
return new ChunkData(
|
||||
new Chunk(
|
||||
$subChunks,
|
||||
$chunk->getByte("TerrainPopulated", 0) !== 0
|
||||
return new LoadedChunkData(
|
||||
data: new ChunkData(
|
||||
new Chunk(
|
||||
$subChunks,
|
||||
$chunk->getByte("TerrainPopulated", 0) !== 0
|
||||
),
|
||||
($entitiesTag = $chunk->getTag("Entities")) instanceof ListTag ? self::getCompoundList("Entities", $entitiesTag) : [],
|
||||
($tilesTag = $chunk->getTag("TileEntities")) instanceof ListTag ? self::getCompoundList("TileEntities", $tilesTag) : [],
|
||||
),
|
||||
($entitiesTag = $chunk->getTag("Entities")) instanceof ListTag ? self::getCompoundList("Entities", $entitiesTag) : [],
|
||||
($tilesTag = $chunk->getTag("TileEntities")) instanceof ListTag ? self::getCompoundList("TileEntities", $tilesTag) : [],
|
||||
upgraded: true,
|
||||
fixerFlags: LoadedChunkData::FIXER_FLAG_ALL
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user