mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 02:42:58 +00:00
Create LightableTrait and remove repetitive code (#6111)
This commit is contained in:
@ -23,28 +23,22 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\LightableTrait;
|
||||
use pocketmine\data\runtime\RuntimeDataDescriber;
|
||||
|
||||
class RedstoneTorch extends Torch{
|
||||
protected bool $lit = true;
|
||||
use LightableTrait;
|
||||
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
|
||||
$this->lit = true;
|
||||
parent::__construct($idInfo, $name, $typeInfo);
|
||||
}
|
||||
|
||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||
parent::describeBlockOnlyState($w);
|
||||
$w->bool($this->lit);
|
||||
}
|
||||
|
||||
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{
|
||||
return $this->lit ? 7 : 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user