Light block brightness can be changed by right-clicking on it

This commit is contained in:
Dylan K. Taylor 2022-07-02 22:48:10 +01:00
parent 2a0fade893
commit 0d0296d535
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -25,6 +25,9 @@ namespace pocketmine\block;
use pocketmine\data\runtime\block\BlockDataReader;
use pocketmine\data\runtime\block\BlockDataWriter;
use pocketmine\item\Item;
use pocketmine\math\Vector3;
use pocketmine\player\Player;
final class Light extends Flowable{
public const MIN_LIGHT_LEVEL = 0;
@ -54,4 +57,14 @@ final class Light extends Flowable{
}
public function canBeReplaced() : bool{ return true; }
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
$this->level = $this->level === self::MAX_LIGHT_LEVEL ?
self::MIN_LIGHT_LEVEL :
$this->level + 1;
$this->position->getWorld()->setBlock($this->position, $this);
return true;
}
}