From 8ccaf907d1dfca4459d01a5fa7694d8938156995 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 8 Nov 2023 15:18:46 +0000 Subject: [PATCH] tools/generate-blockstate-upgrade-schema: do not optimize state remaps with unchanged IDs processRemappedStates() needs to know about the full set of states to generate reliable mappings. Without it, it may generate flattening rules or state matching criteria that unintentionally match states that it's not aware of. Sadly, this does make some schemas bigger, but it's for the best. --- tools/generate-blockstate-upgrade-schema.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/tools/generate-blockstate-upgrade-schema.php b/tools/generate-blockstate-upgrade-schema.php index f247d6112..dfb8f6066 100644 --- a/tools/generate-blockstate-upgrade-schema.php +++ b/tools/generate-blockstate-upgrade-schema.php @@ -37,7 +37,6 @@ use pocketmine\network\mcpe\protocol\serializer\NetworkNbtSerializer; use pocketmine\utils\AssumptionFailedError; use pocketmine\utils\Filesystem; use pocketmine\utils\Utils; -use function array_filter; use function array_key_first; use function array_keys; use function array_map; @@ -481,16 +480,9 @@ function generateBlockStateUpgradeSchema(array $upgradeTable) : BlockStateUpgrad throw new \RuntimeException("States with the same ID should be fully consistent"); } }else{ - if(isset($newNameFound[$oldName])){ - //some of the states stayed under the same ID - we can process these as normal states - $stateGroup = array_filter($blockStateMappings, fn(BlockStateMapping $m) => $m->new->getName() === $oldName); - if(processStateGroup($oldName, $stateGroup, $result)){ - foreach(Utils::stringifyKeys($stateGroup) as $k => $mapping){ - unset($blockStateMappings[$k]); - } - } - } //block mapped to multiple different new IDs; we can't guess these, so we just do a plain old remap + //even if some of the states stay under the same ID, the compression techniques used by this function + //implicitly rely on knowing the full set of old states and their new transformations $result->remappedStates[$oldName] = processRemappedStates($blockStateMappings); } }