Added support for compressing blockstate remaps using copiedState

this significantly reduces the size of schemas when state remaps are used (see pmmp/BedrockBlockUpgradeSchema@85b83b360e).

in addition, this will likely offer a substantial performance and memory saving when walls get flattened, which will eventually happen.
This commit is contained in:
Dylan K. Taylor
2023-04-28 20:34:06 +01:00
parent 263e1e9950
commit a1d44de487
5 changed files with 166 additions and 10 deletions

View File

@ -43,15 +43,25 @@ final class BlockStateUpgradeSchemaModelBlockRemap{
*/
public ?array $newState;
/**
* @var string[]
* @phpstan-var list<string>
* May not be present in older schemas
*/
public array $copiedState;
/**
* @param BlockStateUpgradeSchemaModelTag[] $oldState
* @param BlockStateUpgradeSchemaModelTag[] $newState
* @param string[] $copiedState
* @phpstan-param array<string, BlockStateUpgradeSchemaModelTag> $oldState
* @phpstan-param array<string, BlockStateUpgradeSchemaModelTag> $newState
* @phpstan-param list<string> $copiedState
*/
public function __construct(array $oldState, string $newName, array $newState){
public function __construct(array $oldState, string $newName, array $newState, array $copiedState){
$this->oldState = count($oldState) === 0 ? null : $oldState;
$this->newName = $newName;
$this->newState = count($newState) === 0 ? null : $newState;
$this->copiedState = $copiedState;
}
}