worksUnderwater = $r->readBool(); } protected function encodeType(BlockDataWriter $w) : void{ $w->writeBool($this->worksUnderwater); } public function getRequiredStateDataBits() : int{ return 1; } protected function decodeState(BlockDataReader $r) : void{ $this->unstable = $r->readBool(); } protected function encodeState(BlockDataWriter $w) : void{ $w->writeBool($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) : bool{ if($this->unstable){ $this->ignite(); return true; } return parent::onBreak($item, $player); } public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if($item instanceof FlintSteel || $item->hasEnchantment(VanillaEnchantments::FIRE_ASPECT())){ if($item instanceof Durable){ $item->applyDamage(1); } $this->ignite(); return true; } return false; } public function hasEntityCollision() : bool{ return true; } public function onEntityInside(Entity $entity) : bool{ if($entity instanceof Arrow && $entity->isOnFire()){ $this->ignite(); return false; } return true; } public function ignite(int $fuse = 80) : void{ $this->position->getWorld()->setBlock($this->position, VanillaBlocks::AIR()); $mot = (new Random())->nextSignedFloat() * M_PI * 2; $tnt = new PrimedTNT(Location::fromObject($this->position->add(0.5, 0, 0.5), $this->position->getWorld())); $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(); } }