mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
Merge branch 'next-minor'
This commit is contained in:
@ -85,8 +85,8 @@ trait LegacyAnvilChunkTrait{
|
||||
$chunk->getInt("xPos"),
|
||||
$chunk->getInt("zPos"),
|
||||
$subChunks,
|
||||
$chunk->hasTag("Entities", ListTag::class) ? $chunk->getListTag("Entities")->getValue() : [],
|
||||
$chunk->hasTag("TileEntities", ListTag::class) ? $chunk->getListTag("TileEntities")->getValue() : [],
|
||||
$chunk->hasTag("Entities", ListTag::class) ? self::getCompoundList("Entities", $chunk->getListTag("Entities")) : [],
|
||||
$chunk->hasTag("TileEntities", ListTag::class) ? self::getCompoundList("TileEntities", $chunk->getListTag("TileEntities")) : [],
|
||||
$biomeIds
|
||||
);
|
||||
$result->setPopulated($chunk->getByte("TerrainPopulated", 0) !== 0);
|
||||
|
@ -87,8 +87,8 @@ class McRegion extends RegionWorldProvider{
|
||||
$chunk->getInt("xPos"),
|
||||
$chunk->getInt("zPos"),
|
||||
$subChunks,
|
||||
$chunk->hasTag("Entities", ListTag::class) ? $chunk->getListTag("Entities")->getValue() : [],
|
||||
$chunk->hasTag("TileEntities", ListTag::class) ? $chunk->getListTag("TileEntities")->getValue() : [],
|
||||
$chunk->hasTag("Entities", ListTag::class) ? self::getCompoundList("Entities", $chunk->getListTag("Entities")) : [],
|
||||
$chunk->hasTag("TileEntities", ListTag::class) ? self::getCompoundList("TileEntities", $chunk->getListTag("TileEntities")) : [],
|
||||
$biomeIds
|
||||
);
|
||||
$result->setPopulated($chunk->getByte("TerrainPopulated", 0) !== 0);
|
||||
|
@ -23,6 +23,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\world\format\io\region;
|
||||
|
||||
use pocketmine\nbt\NBT;
|
||||
use pocketmine\nbt\tag\ListTag;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\utils\Utils;
|
||||
use pocketmine\world\format\Chunk;
|
||||
use pocketmine\world\format\io\BaseWorldProvider;
|
||||
@ -187,6 +190,31 @@ abstract class RegionWorldProvider extends BaseWorldProvider{
|
||||
*/
|
||||
abstract protected function deserializeChunk(string $data) : Chunk;
|
||||
|
||||
/**
|
||||
* @param string $context
|
||||
* @param ListTag $list
|
||||
*
|
||||
* @return CompoundTag[]
|
||||
* @throws CorruptedChunkException
|
||||
*/
|
||||
protected static function getCompoundList(string $context, ListTag $list) : array{
|
||||
if($list->count() === 0){ //empty lists might have wrong types, we don't care
|
||||
return [];
|
||||
}
|
||||
if($list->getTagType() !== NBT::TAG_Compound){
|
||||
throw new CorruptedChunkException("Expected TAG_List<TAG_Compound> for '$context'");
|
||||
}
|
||||
$result = [];
|
||||
foreach($list as $tag){
|
||||
if(!($tag instanceof CompoundTag)){
|
||||
//this should never happen, but it's still possible due to lack of native type safety
|
||||
throw new CorruptedChunkException("Expected TAG_List<TAG_Compound> for '$context'");
|
||||
}
|
||||
$result[] = $tag;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $chunkX
|
||||
* @param int $chunkZ
|
||||
|
Reference in New Issue
Block a user