mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 11:57:10 +00:00
BlockStateUpgrader: make sure the returned state always has an updated version ID
PM itself doesn't require this, but it's useful for tools to know whether to upgrade the schema again (e.g. in testing scenarios).
This commit is contained in:
parent
ff8301b86c
commit
e2108557ab
@ -56,8 +56,10 @@ final class BlockStateUpgrader{
|
||||
|
||||
public function upgrade(BlockStateData $blockStateData) : BlockStateData{
|
||||
$version = $blockStateData->getVersion();
|
||||
$highestVersion = $version;
|
||||
foreach($this->upgradeSchemas as $schema){
|
||||
$resultVersion = $schema->getVersionId();
|
||||
$highestVersion = max($highestVersion, $resultVersion);
|
||||
if($version > $resultVersion){
|
||||
//even if this is actually the same version, we have to apply it anyway because mojang are dumb and
|
||||
//didn't always bump the blockstate version when changing it :(
|
||||
@ -96,6 +98,11 @@ final class BlockStateUpgrader{
|
||||
}
|
||||
}
|
||||
|
||||
if($highestVersion > $version){
|
||||
//always update the version number of the blockstate, even if it didn't change - this is needed for
|
||||
//external tools
|
||||
$blockStateData = new BlockStateData($blockStateData->getName(), $blockStateData->getStates(), $highestVersion);
|
||||
}
|
||||
return $blockStateData;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user