mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +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:
@ -1,40 +0,0 @@
|
||||
<?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\block;
|
||||
|
||||
use pocketmine\data\bedrock\block\upgrade\BlockStateUpgrader;
|
||||
|
||||
final class UpgradingBlockStateDeserializer implements BlockStateDeserializer{
|
||||
|
||||
public function __construct(
|
||||
private BlockStateUpgrader $blockStateUpgrader,
|
||||
private BlockStateDeserializer $realDeserializer
|
||||
){}
|
||||
|
||||
public function deserialize(BlockStateData $stateData) : int{
|
||||
return $this->realDeserializer->deserialize($this->blockStateUpgrader->upgrade($stateData));
|
||||
}
|
||||
|
||||
public function getRealDeserializer() : BlockStateDeserializer{ return $this->realDeserializer; }
|
||||
}
|
Reference in New Issue
Block a user