mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 18:32:55 +00:00
Separate block legacy data upgrading from block deserialization
this commit provides a central place where all block data can go to be upgraded to the latest version (currently 1.19), irrespective of how old it is. Previously I had issues during debugging, because it wasn't possible to just upgrade a block without deserializing it into a Block object, which isn't currently supported for many blocks. This commit solves that problem by separating the upgrading from the deserialization.
This commit is contained in:
@ -56,11 +56,11 @@ abstract class BaseWorldProvider implements WorldProvider{
|
||||
|
||||
//TODO: this should be dependency-injected so it can be replaced, but that would break BC
|
||||
//also, we want it to be lazy-loaded ...
|
||||
$legacyBlockStateMapper = GlobalBlockStateHandlers::getLegacyBlockStateMapper();
|
||||
$blockDataUpgrader = GlobalBlockStateHandlers::getUpgrader();
|
||||
$blockStateDeserializer = GlobalBlockStateHandlers::getDeserializer();
|
||||
$newPalette = [];
|
||||
foreach($palette as $k => $legacyIdMeta){
|
||||
$newStateData = $legacyBlockStateMapper->fromIntIdMeta($legacyIdMeta >> 4, $legacyIdMeta & 0xf);
|
||||
$newStateData = $blockDataUpgrader->upgradeIntIdMeta($legacyIdMeta >> 4, $legacyIdMeta & 0xf);
|
||||
if($newStateData === null){
|
||||
//TODO: remember data for unknown states so we can implement them later
|
||||
$newStateData = new BlockStateData(BlockTypeNames::INFO_UPDATE, CompoundTag::create(), BlockStateData::CURRENT_VERSION);
|
||||
|
Reference in New Issue
Block a user