mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
ÂInsert PM data version into blockstates, chunks, entities, tiles and level.dat
this information will allow us to correct for any bugs introduced by past versions. however, we still need to propagate this information to permit actually using it when loading data.
This commit is contained in:
@ -33,6 +33,7 @@ use pocketmine\nbt\TreeRoot;
|
||||
use pocketmine\utils\Binary;
|
||||
use pocketmine\utils\Filesystem;
|
||||
use pocketmine\utils\Limits;
|
||||
use pocketmine\VersionInfo;
|
||||
use pocketmine\world\format\io\exception\CorruptedWorldException;
|
||||
use pocketmine\world\format\io\exception\UnsupportedWorldFormatException;
|
||||
use pocketmine\world\generator\Flat;
|
||||
@ -201,6 +202,7 @@ class BedrockWorldData extends BaseNbtWorldData{
|
||||
$this->compoundTag->setInt(self::TAG_NETWORK_VERSION, self::CURRENT_STORAGE_NETWORK_VERSION);
|
||||
$this->compoundTag->setInt(self::TAG_STORAGE_VERSION, self::CURRENT_STORAGE_VERSION);
|
||||
$this->compoundTag->setTag(self::TAG_LAST_OPENED_WITH_VERSION, new ListTag(array_map(fn(int $v) => new IntTag($v), self::CURRENT_CLIENT_VERSION_TARGET)));
|
||||
$this->compoundTag->setLong(VersionInfo::TAG_WORLD_DATA_VERSION, VersionInfo::WORLD_DATA_VERSION);
|
||||
|
||||
$nbt = new LittleEndianNbtSerializer();
|
||||
$buffer = $nbt->write(new TreeRoot($this->compoundTag));
|
||||
|
@ -30,6 +30,7 @@ use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\nbt\TreeRoot;
|
||||
use pocketmine\utils\Filesystem;
|
||||
use pocketmine\utils\Utils;
|
||||
use pocketmine\VersionInfo;
|
||||
use pocketmine\world\format\io\exception\CorruptedWorldException;
|
||||
use pocketmine\world\generator\GeneratorManager;
|
||||
use pocketmine\world\World;
|
||||
@ -126,6 +127,8 @@ class JavaWorldData extends BaseNbtWorldData{
|
||||
}
|
||||
|
||||
public function save() : void{
|
||||
$this->compoundTag->setLong(VersionInfo::TAG_WORLD_DATA_VERSION, VersionInfo::WORLD_DATA_VERSION);
|
||||
|
||||
$nbt = new BigEndianNbtSerializer();
|
||||
$buffer = Utils::assumeNotFalse(zlib_encode($nbt->write(new TreeRoot(CompoundTag::create()->setTag(self::TAG_ROOT_DATA, $this->compoundTag))), ZLIB_ENCODING_GZIP));
|
||||
Filesystem::safeFilePutContents($this->dataPath, $buffer);
|
||||
|
@ -23,6 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\world\format\io\leveldb;
|
||||
|
||||
use pocketmine\VersionInfo;
|
||||
|
||||
final class ChunkDataKey{
|
||||
private function __construct(){
|
||||
//NOOP
|
||||
@ -50,4 +52,6 @@ final class ChunkDataKey{
|
||||
|
||||
public const OLD_VERSION = "\x76";
|
||||
|
||||
public const PM_DATA_VERSION = VersionInfo::TAG_WORLD_DATA_VERSION;
|
||||
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ use pocketmine\nbt\TreeRoot;
|
||||
use pocketmine\utils\Binary;
|
||||
use pocketmine\utils\BinaryDataException;
|
||||
use pocketmine\utils\BinaryStream;
|
||||
use pocketmine\VersionInfo;
|
||||
use pocketmine\world\format\Chunk;
|
||||
use pocketmine\world\format\io\BaseWorldProvider;
|
||||
use pocketmine\world\format\io\ChunkData;
|
||||
@ -601,6 +602,8 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{
|
||||
return null;
|
||||
}
|
||||
|
||||
//TODO: read PM_DATA_VERSION - we'll need it to fix up old chunks
|
||||
|
||||
$logger = new \PrefixedLogger($this->logger, "Loading chunk x=$chunkX z=$chunkZ v$chunkVersion");
|
||||
|
||||
$hasBeenUpgraded = $chunkVersion < self::CURRENT_LEVEL_CHUNK_VERSION;
|
||||
@ -710,6 +713,7 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{
|
||||
$write = new \LevelDBWriteBatch();
|
||||
|
||||
$write->put($index . ChunkDataKey::NEW_VERSION, chr(self::CURRENT_LEVEL_CHUNK_VERSION));
|
||||
$write->put($index . ChunkDataKey::PM_DATA_VERSION, Binary::writeLLong(VersionInfo::WORLD_DATA_VERSION));
|
||||
|
||||
$chunk = $chunkData->getChunk();
|
||||
|
||||
|
Reference in New Issue
Block a user