mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 02:42:58 +00:00
Catch corrupted chunk data errors
This commit is contained in:
@ -133,14 +133,19 @@ class Chunk extends BaseChunk{
|
||||
*/
|
||||
public static function fromBinary($data, LevelProvider $provider = null){
|
||||
$nbt = new NBT(NBT::BIG_ENDIAN);
|
||||
$nbt->readCompressed($data, ZLIB_ENCODING_DEFLATE);
|
||||
$chunk = $nbt->getData();
|
||||
|
||||
try{
|
||||
$nbt->readCompressed($data, ZLIB_ENCODING_DEFLATE);
|
||||
$chunk = $nbt->getData();
|
||||
|
||||
if(!isset($chunk->Level) or !($chunk->Level instanceof Compound)){
|
||||
if(!isset($chunk->Level) or !($chunk->Level instanceof Compound)){
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Chunk($provider instanceof LevelProvider ? $provider : Anvil::class, $chunk->Level);
|
||||
}catch (\Exception $e){
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Chunk($provider instanceof LevelProvider ? $provider : Anvil::class, $chunk->Level);
|
||||
}
|
||||
|
||||
public function toBinary(){
|
||||
|
Reference in New Issue
Block a user