Create LightableTrait and remove repetitive code (#6111)

This commit is contained in:
Hugo_
2023-12-20 16:21:11 +01:00
committed by GitHub
parent 80125f9b19
commit c51b1b2812
5 changed files with 58 additions and 59 deletions

View File

@ -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;
}