boundedInt(4, self::MIN_LIGHT_LEVEL, self::MAX_LIGHT_LEVEL, $this->level); } public function getLightLevel() : int{ return $this->level; } /** @return $this */ public function setLightLevel(int $level) : self{ if($level < self::MIN_LIGHT_LEVEL || $level > self::MAX_LIGHT_LEVEL){ throw new \InvalidArgumentException("Light level must be in the range " . self::MIN_LIGHT_LEVEL . " ... " . self::MAX_LIGHT_LEVEL); } $this->level = $level; return $this; } public function canBeReplaced() : bool{ return true; } public function canBePlacedAt(Block $blockReplace, Vector3 $clickVector, int $face, bool $isClickedBlock) : bool{ //light blocks behave like solid blocks when placing them on another light block return $blockReplace->canBeReplaced() && $blockReplace->getTypeId() !== $this->getTypeId(); } public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : 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; } }