getCause() === EntityDamageEvent::CAUSE_VOID){ parent::attack($source); } } protected function initEntity(CompoundTag $nbt) : void{ parent::initEntity($nbt); if($nbt->hasTag("Fuse", ShortTag::class)){ $this->fuse = $nbt->getShort("Fuse"); }else{ $this->fuse = 80; } $this->setGenericFlag(self::DATA_FLAG_IGNITED, true); $this->propertyManager->setInt(self::DATA_FUSE_LENGTH, $this->fuse); $this->level->broadcastLevelEvent($this, LevelEventPacket::EVENT_SOUND_IGNITE); } 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->fuse % 5 === 0){ //don't spam it every tick, it's not necessary $this->propertyManager->setInt(self::DATA_FUSE_LENGTH, $this->fuse); } 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($this, $ev->getForce(), $this); if($ev->isBlockBreaking()){ $explosion->explodeA(); } $explosion->explodeB(); } } }