BlockStateData: use array<Tag> instead of CompoundTag to store state properties

this reduces the footprint of RuntimeBlockMapping by a further 1 MB, as well as simplifying various parts of the code, and solidifying the immutability guarantee of BlockStateData.
This commit is contained in:
Dylan K. Taylor
2022-07-09 16:03:51 +01:00
parent 151f2c3f3a
commit ccb3c3cb05
17 changed files with 148 additions and 110 deletions

View File

@ -23,15 +23,9 @@ declare(strict_types=1);
namespace pocketmine\data\bedrock\block\upgrade;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\Tag;
use pocketmine\utils\Utils;
final class BlockStateUpgradeSchemaBlockRemap{
public CompoundTag $oldState;
public CompoundTag $newState;
/**
* @param Tag[] $oldState
* @param Tag[] $newState
@ -39,17 +33,8 @@ final class BlockStateUpgradeSchemaBlockRemap{
* @phpstan-param array<string, Tag> $newState
*/
public function __construct(
array $oldState,
public array $oldState,
public string $newName,
array $newState
){
$this->oldState = CompoundTag::create();
$this->newState = CompoundTag::create();
foreach(Utils::stringifyKeys($oldState) as $k => $v){
$this->oldState->setTag($k, $v);
}
foreach(Utils::stringifyKeys($newState) as $k => $v){
$this->newState->setTag($k, $v);
}
}
public array $newState
){}
}