updated pocketmine/nbt dependency

this is going to need work on exception handling, but right now it's so inconsistent that it doesn't matter anyway.
This commit is contained in:
Dylan K. Taylor
2020-03-04 17:53:37 +00:00
parent 6e39e34c1e
commit 995309424e
16 changed files with 45 additions and 32 deletions

View File

@@ -33,6 +33,8 @@ use pocketmine\block\tile\TileFactory;
use pocketmine\entity\Entity;
use pocketmine\entity\EntityFactory;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\StringTag;
use pocketmine\player\Player;
use pocketmine\world\World;
use function array_fill;
@@ -498,7 +500,14 @@ class Chunk{
try{
$entity = EntityFactory::createFromData($world, $nbt);
if(!($entity instanceof Entity)){
$world->getLogger()->warning("Chunk $this->x $this->z: Deleted unknown entity type " . $nbt->getString("id", $nbt->getString("identifier", "<unknown>", true), true));
$saveIdTag = $nbt->getTag("id") ?? $nbt->getTag("identifier");
$saveId = "<unknown>";
if($saveIdTag instanceof StringTag){
$saveId = $saveIdTag->getValue();
}elseif($saveIdTag instanceof IntTag){ //legacy MCPE format
$saveId = "legacy(" . $saveIdTag->getValue() . ")";
}
$world->getLogger()->warning("Chunk $this->x $this->z: Deleted unknown entity type $saveId");
continue;
}
}catch(\Exception $t){ //TODO: this shouldn't be here
@@ -517,7 +526,7 @@ class Chunk{
if(($tile = TileFactory::createFromData($world, $nbt)) !== null){
$world->addTile($tile);
}else{
$world->getLogger()->warning("Chunk $this->x $this->z: Deleted unknown tile entity type " . $nbt->getString("id", "<unknown>", true));
$world->getLogger()->warning("Chunk $this->x $this->z: Deleted unknown tile entity type " . $nbt->getString("id", "<unknown>"));
continue;
}
}

View File

@@ -25,6 +25,7 @@ namespace pocketmine\world\format\io\data;
use pocketmine\math\Vector3;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\IntTag;
use pocketmine\world\format\io\exception\CorruptedWorldException;
use pocketmine\world\format\io\exception\UnsupportedWorldFormatException;
use pocketmine\world\format\io\WorldData;
@@ -124,11 +125,14 @@ abstract class BaseNbtWorldData implements WorldData{
}
public function getTime() : int{
return $this->compoundTag->getLong("Time", 0, true);
if($this->compoundTag->hasTag("Time", IntTag::class)){ //some older PM worlds had this in the wrong format
return $this->compoundTag->getInt("Time");
}
return $this->compoundTag->getLong("Time", 0);
}
public function setTime(int $value) : void{
$this->compoundTag->setLong("Time", $value, true); //some older PM worlds had this in the wrong format
$this->compoundTag->setLong("Time", $value);
}
public function getSpawn() : Vector3{

View File

@@ -122,7 +122,7 @@ class BedrockWorldData extends BaseNbtWorldData{
throw new CorruptedWorldException($e->getMessage(), 0, $e);
}
$version = $worldData->getInt("StorageVersion", Limits::INT32_MAX, true);
$version = $worldData->getInt("StorageVersion", Limits::INT32_MAX);
if($version > self::CURRENT_STORAGE_VERSION){
throw new UnsupportedWorldFormatException("LevelDB world format version $version is currently unsupported");
}

View File

@@ -90,7 +90,7 @@ class JavaWorldData extends BaseNbtWorldData{
protected function fix() : void{
if(!$this->compoundTag->hasTag("generatorName", StringTag::class)){
$this->compoundTag->setString("generatorName", "default", true);
$this->compoundTag->setString("generatorName", "default");
}elseif(($generatorName = self::hackyFixForGeneratorClasspathInLevelDat($this->compoundTag->getString("generatorName"))) !== null){
$this->compoundTag->setString("generatorName", $generatorName);
}

View File

@@ -75,7 +75,7 @@ trait LegacyAnvilChunkTrait{
if($chunk->hasTag("BiomeColors", IntArrayTag::class)){
$biomeIds = ChunkUtils::convertBiomeColors($chunk->getIntArray("BiomeColors")); //Convert back to original format
}else{
$biomeIds = $chunk->getByteArray("Biomes", "", true);
$biomeIds = $chunk->getByteArray("Biomes", "");
}
$result = new Chunk(