bool($this->lit); } public function getLightLevel() : int{ return $this->lit ? 3 : 0; } public function isLit() : bool{ return $this->lit; } /** @return $this */ public function setLit(bool $lit) : self{ $this->lit = $lit; return $this; } /** @see Block::onInteract() */ public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{ if($item->getTypeId() === ItemTypeIds::FLINT_AND_STEEL || $item->hasEnchantment(VanillaEnchantments::FIRE_ASPECT())){ if($this->lit){ return true; } if($item instanceof Durable){ $item->applyDamage(1); } $this->position->getWorld()->addSound($this->position, new FlintSteelSound()); $this->position->getWorld()->setBlock($this->position, $this->setLit(true)); return true; } if($item->isNull()){ //candle can only be extinguished with an empty hand if(!$this->lit){ return true; } $this->position->getWorld()->addSound($this->position, new FireExtinguishSound()); $this->position->getWorld()->setBlock($this->position, $this->setLit(false)); return true; } //yes, this is intentional! in vanilla, if the candle is not interacted with, a block is placed. return false; } /** @see Block::onProjectileHit() */ public function onProjectileHit(Projectile $projectile, RayTraceResult $hitResult) : void{ if(!$this->lit && $projectile->isOnFire()){ $this->position->getWorld()->setBlock($this->position, $this->setLit(true)); } } }