public function attack($damage, EntityDamageEvent $source)
{
parent::attack($damage, $source);
if ($source->isCancelled()) {
return;
}
if ($source instanceof EntityDamageByEntityEvent) {
$this->swimSpeed = mt_rand(150, 350) / 2000;
$e = $source->getDamager();
$this->swimDirection = (new Vector3($this->x - $e->x, $this->y - $e->y, $this->z - $e->z))->normalize();
$pk = new EntityEventPacket();
$pk->eid = $this->getId();
$pk->event = EntityEventPacket::SQUID_INK_CLOUD;
Server::broadcastPacket($this->hasSpawned, $pk);
}
}