bool($this->worksUnderwater); } protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{ $w->bool($this->unstable); } public function isUnstable() : bool{ return $this->unstable; } /** @return $this */ public function setUnstable(bool $unstable) : self{ $this->unstable = $unstable; return $this; } public function worksUnderwater() : bool{ return $this->worksUnderwater; } /** @return $this */ public function setWorksUnderwater(bool $worksUnderwater) : self{ $this->worksUnderwater = $worksUnderwater; return $this; } public function onBreak(Item $item, ?Player $player = null, array &$returnedItems = []) : bool{ if($this->unstable){ $this->ignite(); return true; } return parent::onBreak($item, $player, $returnedItems); } public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{ if($item->getTypeId() === ItemTypeIds::FIRE_CHARGE){ $item->pop(); $this->ignite(); return true; } if($item instanceof FlintSteel || $item->hasEnchantment(VanillaEnchantments::FIRE_ASPECT())){ if($item instanceof Durable){ $item->applyDamage(1); } $this->ignite(); return true; } return false; } public function ignite(int $fuse = 80) : void{ $world = $this->position->getWorld(); $world->setBlock($this->position, VanillaBlocks::AIR()); $mot = (new Random())->nextSignedFloat() * M_PI * 2; $tnt = new PrimedTNT(Location::fromObject($this->position->asVector3()->add(0.5, 0, 0.5), $world)); $tnt->setFuse($fuse); $tnt->setWorksUnderwater($this->worksUnderwater); $tnt->setMotion(new Vector3(-sin($mot) * 0.02, 0.2, -cos($mot) * 0.02)); $tnt->spawnToAll(); $tnt->broadcastSound(new IgniteSound()); } public function getFlameEncouragement() : int{ return 15; } public function getFlammability() : int{ return 100; } public function onIncinerate() : void{ $this->ignite(); } public function onProjectileHit(Projectile $projectile, RayTraceResult $hitResult) : void{ if($projectile->isOnFire()){ $this->ignite(); } } }