mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
BlockStateUpgrader: do not apply backwards-incompatible schemas to blockstates already on the correct version
this notably led to corruption of glow_lichen and sculk_vein in 1.18.10.
This commit is contained in:
@ -64,6 +64,8 @@ final class BlockStateUpgradeSchema{
|
||||
*/
|
||||
public array $remappedStates = [];
|
||||
|
||||
private ?bool $backwardsCompatible = null;
|
||||
|
||||
public function __construct(
|
||||
public int $maxVersionMajor,
|
||||
public int $maxVersionMinor,
|
||||
@ -91,4 +93,22 @@ final class BlockStateUpgradeSchema{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isBackwardsCompatible() : bool{
|
||||
if($this->backwardsCompatible === null){
|
||||
$this->backwardsCompatible = true;
|
||||
foreach([
|
||||
$this->renamedIds,
|
||||
$this->removedProperties,
|
||||
$this->remappedPropertyValues,
|
||||
$this->remappedStates
|
||||
] as $bcBreakingRules){
|
||||
if(count($bcBreakingRules) !== 0){
|
||||
$this->backwardsCompatible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
//schemas which only add properties are backwards compatible
|
||||
return $this->backwardsCompatible;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user