Ejemplo n.º 1
0
  @Override
  public void attackEntityWithRangedAttack(EntityLivingBase var1, float var2) {
    EntityArrow entityarrow =
        new EntityArrow(
            this.worldObj, this, var1, Math.max(1F, getDistanceToEntity(var1) / 10F), 1);
    entityarrow.posX = this.posX;
    entityarrow.posY = this.posY + this.getEyeHeight();
    entityarrow.posZ = this.posZ;

    int power =
        EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, this.getHeldItem());
    int punch =
        EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, this.getHeldItem());
    double damage = (double) (var2 * 3.0F) + this.rand.nextGaussian() * 0.25D;
    entityarrow.setDamage(damage);

    if (power > 0) entityarrow.setDamage(entityarrow.getDamage() + (double) power * 0.5D + 0.5D);
    if (punch > 0) entityarrow.setKnockbackStrength(punch);
    if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, this.getHeldItem()) > 0)
      entityarrow.setFire(100);

    this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
    this.worldObj.spawnEntityInWorld(entityarrow);
  }
  /**
   * Basic mob attack. Default to touch of death in EntityCreature. Overridden by each mob to define
   * their attack.
   */
  protected void attackEntity(Entity entity, float f) {
    if ((entity instanceof EntityPlayer)
        || (entity instanceof CREEPSEntityHunchback)
        || (entity instanceof CREEPSEntityHunchbackSkeleton)) {
      this.setAttackTarget(null);
      return;
    }

    if (f < 10F) {
      double d = entity.posX - posX;
      double d1 = entity.posZ - posZ;

      EntityArrow entityarrow = new EntityArrow(worldObj, this, 1.0F);
      entityarrow.posY += 1.3999999761581421D;
      double d2 = entity.posY - 0.20000000298023224D - entityarrow.posY;
      float f1 = MathHelper.sqrt_double(d * d + d1 * d1) * 0.2F;
      worldObj.playSoundAtEntity(this, "random.bow", 1.0F, 1.0F / (rand.nextFloat() * 0.4F + 0.8F));
      worldObj.spawnEntityInWorld(entityarrow);
      entityarrow.setThrowableHeading(d, d2 + (double) f1, d1, 0.6F, 12F);

      rotationYaw = (float) ((Math.atan2(d1, d) * 180D) / Math.PI) - 90F;
      hasAttacked = true;
    }
  }