namedtag->Fuse)){ $this->fuse = $this->namedtag["Fuse"]; }else{ $this->fuse = 80; } } public function canCollideWith(Entity $entity){ return false; } public function saveNBT(){ parent::saveNBT(); $this->namedtag->Fuse = new Byte("Fuse", $this->fuse); } public function onUpdate($currentTick){ if($this->closed){ return false; } $this->timings->startTiming(); $tickDiff = max(1, $currentTick - $this->lastUpdate); $this->lastUpdate = $currentTick; $hasUpdate = $this->entityBaseTick($tickDiff); if(!$this->dead){ $this->motionY -= $this->gravity; $this->move($this->motionX, $this->motionY, $this->motionZ); $friction = 1 - $this->drag; $this->motionX *= $friction; $this->motionY *= $friction; $this->motionZ *= $friction; $this->updateMovement(); if($this->onGround){ $this->motionY *= -0.5; $this->motionX *= 0.7; $this->motionZ *= 0.7; } $this->fuse -= $tickDiff; if($this->fuse <= 0){ $this->kill(); $this->explode(); } } return $hasUpdate or $this->fuse >= 0 or $this->motionX != 0 or $this->motionY != 0 or $this->motionZ != 0; } public function explode(){ $this->server->getPluginManager()->callEvent($ev = new ExplosionPrimeEvent($this, 4)); if(!$ev->isCancelled()){ $explosion = new Explosion($this, $ev->getForce(), $this); if($ev->isBlockBreaking()){ $explosion->explodeA(); } $explosion->explodeB(); } } public function spawnTo(Player $player){ $pk = new AddEntityPacket(); $pk->type = PrimedTNT::NETWORK_ID; $pk->eid = $this->getId(); $pk->x = $this->x; $pk->y = $this->y; $pk->z = $this->z; $pk->speedX = $this->motionX; $pk->speedY = $this->motionY; $pk->speedZ = $this->motionZ; $pk->metadata = $this->dataProperties; $player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); parent::spawnTo($player); } }