BlockStateUpgrader: fixed undefined array key when flattening a block whose new ID is the same as the old

this came up during 1.20.50 testing, where minecraft:stone[stone_type=stone] continues to have an ID minecraft:stone without the stone_type property.
This could have appeared in other ways, such as with an invalid legacy blockstate.
This commit is contained in:
Dylan K. Taylor 2023-11-08 18:52:22 +00:00
parent 8ccaf907d1
commit 5f3a2a5096
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -86,7 +86,7 @@ final class BlockStateUpgrader{
if(is_string($remap->newName)){
$newName = $remap->newName;
}else{
$flattenedValue = $oldState[$remap->newName->flattenedProperty];
$flattenedValue = $oldState[$remap->newName->flattenedProperty] ?? null;
if($flattenedValue instanceof StringTag){
$newName = sprintf("%s%s%s", $remap->newName->prefix, $flattenedValue->getValue(), $remap->newName->suffix);
unset($oldState[$remap->newName->flattenedProperty]);