fuse; } public function setFuse(int $fuse) : void{ if($fuse < 0 or $fuse > 32767){ throw new \InvalidArgumentException("Fuse must be in the range 0-32767"); } $this->fuse = $fuse; } public function attack(EntityDamageEvent $source) : void{ if($source->getCause() === EntityDamageEvent::CAUSE_VOID){ parent::attack($source); } } protected function initEntity(CompoundTag $nbt) : void{ parent::initEntity($nbt); $this->fuse = $nbt->getShort("Fuse", 80); $this->getWorld()->addSound($this->location, new IgniteSound()); } public function canCollideWith(Entity $entity) : bool{ return false; } public function saveNBT() : CompoundTag{ $nbt = parent::saveNBT(); $nbt->setShort("Fuse", $this->fuse); return $nbt; } protected function entityBaseTick(int $tickDiff = 1) : bool{ if($this->closed){ return false; } $hasUpdate = parent::entityBaseTick($tickDiff); if(!$this->isFlaggedForDespawn()){ $this->fuse -= $tickDiff; if($this->fuse <= 0){ $this->flagForDespawn(); $this->explode(); } } return $hasUpdate or $this->fuse >= 0; } public function explode() : void{ $ev = new ExplosionPrimeEvent($this, 4); $ev->call(); if(!$ev->isCancelled()){ $explosion = new Explosion(Position::fromObject($this->location->add(0, $this->height / 2, 0), $this->getWorld()), $ev->getForce(), $this); if($ev->isBlockBreaking()){ $explosion->explodeA(); } $explosion->explodeB(); } } protected function syncNetworkData(EntityMetadataCollection $properties) : void{ parent::syncNetworkData($properties); $properties->setGenericFlag(EntityMetadataFlags::IGNITED, true); $properties->setInt(EntityMetadataProperties::FUSE_LENGTH, $this->fuse); } public function getOffsetPosition(Vector3 $vector3) : Vector3{ return $vector3->add(0, 0.49, 0); } }