Block: fixed LSP violations in blocks using BlockIdentifierFlattened

a property's type can't be changed by a subclass
This commit is contained in:
Dylan K. Taylor
2021-05-22 23:40:54 +01:00
parent 285ad25168
commit 73c229a236
11 changed files with 48 additions and 37 deletions

View File

@ -37,16 +37,17 @@ use function rad2deg;
final class FloorCoralFan extends BaseCoral{
/** @var BlockIdentifierFlattened */
protected $idInfo;
protected $idInfoFlattened;
private int $axis = Axis::X;
public function __construct(BlockIdentifierFlattened $idInfo, string $name, BlockBreakInfo $breakInfo){
$this->idInfoFlattened = $idInfo;
parent::__construct($idInfo, $name, $breakInfo);
}
public function readStateFromData(int $id, int $stateMeta) : void{
$this->dead = $id === $this->idInfo->getSecondId();
$this->dead = $id === $this->idInfoFlattened->getSecondId();
$this->axis = ($stateMeta >> 3) === BlockLegacyMetadata::CORAL_FAN_EAST_WEST ? Axis::X : Axis::Z;
$coralType = CoralTypeIdMap::getInstance()->fromId($stateMeta & BlockLegacyMetadata::CORAL_FAN_TYPE_MASK);
if($coralType === null){
@ -56,7 +57,7 @@ final class FloorCoralFan extends BaseCoral{
}
public function getId() : int{
return $this->dead ? $this->idInfo->getSecondId() : parent::getId();
return $this->dead ? $this->idInfoFlattened->getSecondId() : parent::getId();
}
public function asItem() : Item{