Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/stable' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
dries-c committed Oct 27, 2024
2 parents 2cc2e80 + 8ef5e73 commit e5ed50a
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 7 deletions.
2 changes: 1 addition & 1 deletion changelogs/5.19.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# 5.19.0
Released 21tst September 2024.
Released 21st September 2024.

**For Minecraft: Bedrock Edition 1.21.30**

Expand Down
19 changes: 19 additions & 0 deletions changelogs/5.20.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 5.20.0
Released 26th October 2024.

**For Minecraft: Bedrock Edition 1.21.40**

This is a support release for Minecraft: Bedrock Edition 1.21.40.

**Plugin compatibility:** Plugins for previous 5.x versions will run unchanged on this release, unless they use internal APIs, reflection, or packages like the `pocketmine\network\mcpe` or `pocketmine\data` namespace.
Do not update plugin minimum API versions unless you need new features added in this release.

**WARNING: If your plugin uses the `pocketmine\network\mcpe` namespace, you're not shielded by API change constraints.**
Consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you're using packets directly.

## General
- Added support for Minecraft: Bedrock Edition 1.21.40.
- Removed support for earlier versions.

## Fixes
- Fixed a bug in `tools/generate-blockstate-upgrade-schema.php` that caused it to fail on 1.21.40 with the new mushroom block changes.
2 changes: 1 addition & 1 deletion src/VersionInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

final class VersionInfo{
public const NAME = "PocketMine-MP";
public const BASE_VERSION = "5.19.1";
public const BASE_VERSION = "5.20.1";
public const IS_DEVELOPMENT_BUILD = true;
public const BUILD_CHANNEL = "stable";

Expand Down
15 changes: 15 additions & 0 deletions src/data/bedrock/item/upgrade/ItemDataUpgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

use pocketmine\data\bedrock\block\BlockStateDeserializeException;
use pocketmine\data\bedrock\block\upgrade\BlockDataUpgrader;
use pocketmine\data\bedrock\item\BlockItemIdMap;
use pocketmine\data\bedrock\item\SavedItemData;
use pocketmine\data\bedrock\item\SavedItemStackData;
use pocketmine\data\SavedDataLoadingException;
Expand All @@ -35,6 +36,7 @@
use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\ShortTag;
use pocketmine\nbt\tag\StringTag;
use pocketmine\network\mcpe\convert\BlockStateDictionary;
use pocketmine\utils\Binary;
use function assert;

Expand All @@ -46,6 +48,8 @@ public function __construct(
private LegacyItemIdToStringIdMap $legacyIntToStringIdMap,
private R12ItemIdToBlockIdMap $r12ItemIdToBlockIdMap,
private BlockDataUpgrader $blockDataUpgrader,
private BlockItemIdMap $blockItemIdMap,
private BlockStateDictionary $blockStateDictionary
){}

/**
Expand Down Expand Up @@ -148,6 +152,17 @@ private function upgradeItemTypeNbt(CompoundTag $tag) : ?SavedItemData{

[$newNameId, $newMeta] = $this->idMetaUpgrader->upgrade($rawNameId, $meta);

//TODO: Dirty hack to load old skulls from disk: Put this into item upgrade schema's before Mojang makes something with a non 0 default state
if($blockStateData === null && ($blockId = $this->blockItemIdMap->lookupBlockId($newNameId)) !== null){
$networkRuntimeId = $this->blockStateDictionary->lookupStateIdFromIdMeta($blockId, 0);

if($networkRuntimeId === null){
throw new SavedDataLoadingException("Failed to find blockstate for blockitem $newNameId");
}

$blockStateData = $this->blockStateDictionary->generateDataFromStateId($networkRuntimeId);
}

//TODO: this won't account for spawn eggs from before 1.16.100 - perhaps we're lucky and they just left the meta in there anyway?
//TODO: read version from VersionInfo::TAG_WORLD_DATA_VERSION - we may need it to fix up old items

Expand Down
6 changes: 5 additions & 1 deletion src/world/format/io/GlobalItemDataHandlers.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@

namespace pocketmine\world\format\io;

use pocketmine\data\bedrock\item\BlockItemIdMap;
use pocketmine\data\bedrock\item\ItemDeserializer;
use pocketmine\data\bedrock\item\ItemSerializer;
use pocketmine\data\bedrock\item\upgrade\ItemDataUpgrader;
use pocketmine\data\bedrock\item\upgrade\ItemIdMetaUpgrader;
use pocketmine\data\bedrock\item\upgrade\ItemIdMetaUpgradeSchemaUtils;
use pocketmine\data\bedrock\item\upgrade\LegacyItemIdToStringIdMap;
use pocketmine\data\bedrock\item\upgrade\R12ItemIdToBlockIdMap;
use pocketmine\network\mcpe\convert\TypeConverter;
use Symfony\Component\Filesystem\Path;
use const PHP_INT_MAX;
use const pocketmine\BEDROCK_ITEM_UPGRADE_SCHEMA_PATH;
Expand All @@ -54,7 +56,9 @@ public static function getUpgrader() : ItemDataUpgrader{
new ItemIdMetaUpgrader(ItemIdMetaUpgradeSchemaUtils::loadSchemas(Path::join(BEDROCK_ITEM_UPGRADE_SCHEMA_PATH, 'id_meta_upgrade_schema'), PHP_INT_MAX)),
LegacyItemIdToStringIdMap::getInstance(),
R12ItemIdToBlockIdMap::getInstance(),
GlobalBlockStateHandlers::getUpgrader()
GlobalBlockStateHandlers::getUpgrader(),
BlockItemIdMap::getInstance(),
TypeConverter::getInstance()->getBlockTranslator()->getBlockStateDictionary()
);
}
}
6 changes: 3 additions & 3 deletions src/world/format/io/data/BedrockWorldData.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@
class BedrockWorldData extends BaseNbtWorldData{

public const CURRENT_STORAGE_VERSION = 10;
public const CURRENT_STORAGE_NETWORK_VERSION = 729;
public const CURRENT_STORAGE_NETWORK_VERSION = 748;
public const CURRENT_CLIENT_VERSION_TARGET = [
1, //major
21, //minor
30, //patch
3, //revision
40, //patch
1, //revision
0 //is beta
];

Expand Down
1 change: 1 addition & 0 deletions src/world/format/io/leveldb/ChunkVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,5 @@ private function __construct(){
public const v1_18_0_24_unused = 38;
public const v1_18_0_25_beta = 39;
public const v1_18_30 = 40;
public const v1_21_40 = 41;
}
4 changes: 3 additions & 1 deletion src/world/format/io/leveldb/LevelDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{

protected const ENTRY_FLAT_WORLD_LAYERS = "game_flatworldlayers";

protected const CURRENT_LEVEL_CHUNK_VERSION = ChunkVersion::v1_18_30;
protected const CURRENT_LEVEL_CHUNK_VERSION = ChunkVersion::v1_21_40;
protected const CURRENT_LEVEL_SUBCHUNK_VERSION = SubChunkVersion::PALETTED_MULTI;

private const CAVES_CLIFFS_EXPERIMENTAL_SUBCHUNK_KEY_OFFSET = 4;
Expand Down Expand Up @@ -654,6 +654,8 @@ public function loadChunk(int $chunkX, int $chunkZ) : ?LoadedChunkData{
$hasBeenUpgraded = $chunkVersion < self::CURRENT_LEVEL_CHUNK_VERSION;

switch($chunkVersion){
case ChunkVersion::v1_21_40:
//TODO: BiomeStates became shorts instead of bytes
case ChunkVersion::v1_18_30:
case ChunkVersion::v1_18_0_25_beta:
case ChunkVersion::v1_18_0_24_unused:
Expand Down

0 comments on commit e5ed50a

Please sign in to comment.