mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 02:42:58 +00:00
BlockStateData: introduce and use current()
This commit is contained in:
@ -58,6 +58,14 @@ final class BlockStateData{
|
||||
private int $version
|
||||
){}
|
||||
|
||||
/**
|
||||
* @param Tag[] $states
|
||||
* @phpstan-param array<string, Tag> $states
|
||||
*/
|
||||
public static function current(string $name, array $states) : self{
|
||||
return new self($name, $states, self::CURRENT_VERSION);
|
||||
}
|
||||
|
||||
public function getName() : string{ return $this->name; }
|
||||
|
||||
/**
|
||||
|
@ -281,6 +281,6 @@ final class BlockStateWriter{
|
||||
}
|
||||
|
||||
public function getBlockStateData() : BlockStateData{
|
||||
return new BlockStateData($this->id, $this->states, BlockStateData::CURRENT_VERSION);
|
||||
return BlockStateData::current($this->id, $this->states);
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ final class BlockDataUpgrader{
|
||||
$blockStateData = $this->upgradeStringIdMeta($id, $data);
|
||||
if($blockStateData === null){
|
||||
//unknown block, invalid ID
|
||||
$blockStateData = new BlockStateData(BlockTypeNames::INFO_UPDATE, [], BlockStateData::CURRENT_VERSION);
|
||||
$blockStateData = BlockStateData::current(BlockTypeNames::INFO_UPDATE, []);
|
||||
}
|
||||
}else{
|
||||
//Modern (post-1.13) blockstate
|
||||
|
Reference in New Issue
Block a user