mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-16 19:59:11 +00:00
Eliminate usages of BaseNbtSerializer->readCompressed() and BaseNbtSerializer->writeCompressed()
This commit is contained in:
@@ -34,6 +34,7 @@ use pocketmine\world\format\Chunk;
|
||||
use pocketmine\world\format\io\ChunkUtils;
|
||||
use pocketmine\world\format\io\exception\CorruptedChunkException;
|
||||
use pocketmine\world\format\SubChunk;
|
||||
use function zlib_decode;
|
||||
|
||||
/**
|
||||
* Trait containing I/O methods for handling legacy Anvil-style chunks.
|
||||
@@ -54,9 +55,13 @@ trait LegacyAnvilChunkTrait{
|
||||
* @throws CorruptedChunkException
|
||||
*/
|
||||
protected function deserializeChunk(string $data) : Chunk{
|
||||
$decompressed = @zlib_decode($data);
|
||||
if($decompressed === false){
|
||||
throw new CorruptedChunkException("Failed to decompress chunk NBT");
|
||||
}
|
||||
$nbt = new BigEndianNbtSerializer();
|
||||
try{
|
||||
$chunk = $nbt->readCompressed($data)->mustGetCompoundTag();
|
||||
$chunk = $nbt->read($decompressed)->mustGetCompoundTag();
|
||||
}catch(NbtDataException $e){
|
||||
throw new CorruptedChunkException($e->getMessage(), 0, $e);
|
||||
}
|
||||
|
Reference in New Issue
Block a user