Consolidate Bedrock data version info

this ensures we don't have to go into a bunch of randomly scattered files to update version numbers.
This commit is contained in:
Dylan K. Taylor 2025-05-17 13:33:42 +01:00
parent 50f3fe2578
commit 84bb9d2ab4
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
4 changed files with 76 additions and 22 deletions

View File

@ -0,0 +1,67 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\data\bedrock;
use pocketmine\world\format\io\leveldb\ChunkVersion;
use pocketmine\world\format\io\leveldb\SubChunkVersion;
/**
* All version infos related to current Minecraft data version support
* These are mostly related to world storage but may also influence network stuff
*/
final class WorldDataVersions{
/**
* Bedrock version of the most recent backwards-incompatible change to blockstates.
*
* This is *NOT* the same as current game version. It should match the numbers in the
* newest blockstate upgrade schema used in BedrockBlockUpgradeSchema.
*/
public const BLOCK_STATES =
(1 << 24) | //major
(21 << 16) | //minor
(60 << 8) | //patch
(33); //revision
public const CHUNK = ChunkVersion::v1_21_40;
public const SUBCHUNK = SubChunkVersion::PALETTED_MULTI;
public const STORAGE = 10;
/**
* Highest NetworkVersion of Bedrock worlds currently supported by PocketMine-MP.
*
* This may be lower than the current protocol version if PocketMine-MP does not yet support features of the newer
* version. This allows the protocol to be updated independently of world format support.
*/
public const NETWORK = 800;
public const LAST_OPENED_IN = [
1, //major
21, //minor
80, //patch
3, //revision
0 //is beta
];
}

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace pocketmine\data\bedrock\block;
use pocketmine\data\bedrock\WorldDataVersions;
use pocketmine\nbt\NbtException;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\Tag;
@ -36,17 +37,7 @@ use function implode;
* Contains the common information found in a serialized blockstate.
*/
final class BlockStateData{
/**
* Bedrock version of the most recent backwards-incompatible change to blockstates.
*
* This is *not* the same as current game version. It should match the numbers in the
* newest blockstate upgrade schema used in BedrockBlockUpgradeSchema.
*/
public const CURRENT_VERSION =
(1 << 24) | //major
(21 << 16) | //minor
(60 << 8) | //patch
(33); //revision
public const CURRENT_VERSION = WorldDataVersions::BLOCK_STATES;
public const TAG_NAME = "name";
public const TAG_STATES = "states";

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace pocketmine\world\format\io\data;
use pocketmine\data\bedrock\WorldDataVersions;
use pocketmine\nbt\LittleEndianNbtSerializer;
use pocketmine\nbt\NbtDataException;
use pocketmine\nbt\tag\CompoundTag;
@ -50,15 +51,9 @@ use function time;
class BedrockWorldData extends BaseNbtWorldData{
public const CURRENT_STORAGE_VERSION = 10;
public const CURRENT_STORAGE_NETWORK_VERSION = 800;
public const CURRENT_CLIENT_VERSION_TARGET = [
1, //major
21, //minor
80, //patch
3, //revision
0 //is beta
];
public const CURRENT_STORAGE_VERSION = WorldDataVersions::STORAGE;
public const CURRENT_STORAGE_NETWORK_VERSION = WorldDataVersions::NETWORK;
public const CURRENT_CLIENT_VERSION_TARGET = WorldDataVersions::LAST_OPENED_IN;
public const GENERATOR_LIMITED = 0;
public const GENERATOR_INFINITE = 1;

View File

@ -27,6 +27,7 @@ use pocketmine\block\Block;
use pocketmine\data\bedrock\BiomeIds;
use pocketmine\data\bedrock\block\BlockStateDeserializeException;
use pocketmine\data\bedrock\block\convert\UnsupportedBlockStateException;
use pocketmine\data\bedrock\WorldDataVersions;
use pocketmine\nbt\LittleEndianNbtSerializer;
use pocketmine\nbt\NBT;
use pocketmine\nbt\NbtDataException;
@ -78,8 +79,8 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{
protected const ENTRY_FLAT_WORLD_LAYERS = "game_flatworldlayers";
protected const CURRENT_LEVEL_CHUNK_VERSION = ChunkVersion::v1_21_40;
protected const CURRENT_LEVEL_SUBCHUNK_VERSION = SubChunkVersion::PALETTED_MULTI;
protected const CURRENT_LEVEL_CHUNK_VERSION = WorldDataVersions::CHUNK;
protected const CURRENT_LEVEL_SUBCHUNK_VERSION = WorldDataVersions::SUBCHUNK;
private const CAVES_CLIFFS_EXPERIMENTAL_SUBCHUNK_KEY_OFFSET = 4;