mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-27 05:13:46 +00:00
RedstoneLamp now uses PoweredByRedstoneTrait
This commit is contained in:
parent
5be03c3196
commit
233616aa6a
@ -23,39 +23,27 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
|
use pocketmine\block\utils\PoweredByRedstoneTrait;
|
||||||
|
|
||||||
class RedstoneLamp extends Opaque{
|
class RedstoneLamp extends Opaque{
|
||||||
|
use PoweredByRedstoneTrait;
|
||||||
|
|
||||||
/** @var BlockIdentifierFlattened */
|
/** @var BlockIdentifierFlattened */
|
||||||
protected $idInfo;
|
protected $idInfo;
|
||||||
|
|
||||||
/** @var bool */
|
|
||||||
protected $lit = false;
|
|
||||||
|
|
||||||
public function __construct(BlockIdentifierFlattened $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
|
public function __construct(BlockIdentifierFlattened $idInfo, string $name, ?BlockBreakInfo $breakInfo = null){
|
||||||
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.3));
|
parent::__construct($idInfo, $name, $breakInfo ?? new BlockBreakInfo(0.3));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getId() : int{
|
public function getId() : int{
|
||||||
return $this->lit ? $this->idInfo->getSecondId() : parent::getId();
|
return $this->powered ? $this->idInfo->getSecondId() : parent::getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||||
$this->lit = $id === $this->idInfo->getSecondId();
|
$this->powered = $id === $this->idInfo->getSecondId();
|
||||||
}
|
|
||||||
|
|
||||||
public function isLit() : bool{
|
|
||||||
return $this->lit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return $this
|
|
||||||
*/
|
|
||||||
public function setLit(bool $lit = true) : self{
|
|
||||||
$this->lit = $lit;
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLightLevel() : int{
|
public function getLightLevel() : int{
|
||||||
return $this->lit ? 15 : 0;
|
return $this->powered ? 15 : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user