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

@ -38,23 +38,24 @@ class RedstoneRepeater extends Flowable{
use PoweredByRedstoneTrait;
/** @var BlockIdentifierFlattened */
protected $idInfo;
protected $idInfoFlattened;
/** @var int */
protected $delay = 1;
public function __construct(BlockIdentifierFlattened $idInfo, string $name, BlockBreakInfo $breakInfo){
$this->idInfoFlattened = $idInfo;
parent::__construct($idInfo, $name, $breakInfo);
}
public function getId() : int{
return $this->powered ? $this->idInfo->getSecondId() : parent::getId();
return $this->powered ? $this->idInfoFlattened->getSecondId() : parent::getId();
}
public function readStateFromData(int $id, int $stateMeta) : void{
$this->facing = BlockDataSerializer::readLegacyHorizontalFacing($stateMeta & 0x03);
$this->delay = BlockDataSerializer::readBoundedInt("delay", ($stateMeta >> 2) + 1, 1, 4);
$this->powered = $id === $this->idInfo->getSecondId();
$this->powered = $id === $this->idInfoFlattened->getSecondId();
}
public function writeStateToMeta() : int{