protected void a(Entity entity, float f) {
    if (this.attackTicks <= 0
        && f < 2.0F
        && entity.boundingBox.e > this.boundingBox.b
        && entity.boundingBox.b < this.boundingBox.e) {
      this.attackTicks = 20;
      this.a(entity);
    } else if (f < 30.0F) {
      double d0 = entity.locX - this.locX;
      double d1 =
          entity.boundingBox.b
              + (double) (entity.length / 2.0F)
              - (this.locY + (double) (this.length / 2.0F));
      double d2 = entity.locZ - this.locZ;

      if (this.attackTicks == 0) {
        ++this.g;
        if (this.g == 1) {
          this.attackTicks = 60;
          this.a(true);
        } else if (this.g <= 4) {
          this.attackTicks = 6;
        } else {
          this.attackTicks = 100;
          this.g = 0;
          this.a(false);
        }

        if (this.g > 1) {
          float f1 = MathHelper.c(f) * 0.5F;

          this.world.a(
              (EntityHuman) null, 1009, (int) this.locX, (int) this.locY, (int) this.locZ, 0);

          for (int i = 0; i < 1; ++i) {
            EntitySmallFireball entitysmallfireball =
                new EntitySmallFireball(
                    this.world,
                    this,
                    d0 + this.random.nextGaussian() * (double) f1,
                    d1,
                    d2 + this.random.nextGaussian() * (double) f1);

            entitysmallfireball.locY = this.locY + (double) (this.length / 2.0F) + 0.5D;
            this.world.addEntity(entitysmallfireball);
          }
        }
      }

      this.yaw = (float) (Math.atan2(d2, d0) * 180.0D / 3.1415927410125732D) - 90.0F;
      this.e = true;
    }
  }
Example #2
0
  /**
   * Basic mob attack. Default to touch of death in EntityCreature. Overridden by each mob to define
   * their attack.
   */
  protected void attackEntity(Entity par1Entity, float par2) {
    if (this.attackTime <= 0
        && par2 < 2.0F
        && par1Entity.boundingBox.maxY > this.boundingBox.minY
        && par1Entity.boundingBox.minY < this.boundingBox.maxY) {
      this.attackTime = 20;
      this.attackEntityAsMob(par1Entity);
    } else if (par2 < 30.0F) {
      double var3 = par1Entity.posX - this.posX;
      double var5 =
          par1Entity.boundingBox.minY
              + (double) (par1Entity.height / 2.0F)
              - (this.posY + (double) (this.height / 2.0F));
      double var7 = par1Entity.posZ - this.posZ;

      if (this.attackTime == 0) {
        ++this.field_70846_g;

        if (this.field_70846_g == 1) {
          this.attackTime = 60;
          this.func_70844_e(true);
        } else if (this.field_70846_g <= 4) {
          this.attackTime = 6;
        } else {
          this.attackTime = 100;
          this.field_70846_g = 0;
          this.func_70844_e(false);
        }

        if (this.field_70846_g > 1) {
          float var9 = MathHelper.sqrt_float(par2) * 0.5F;
          this.worldObj.playAuxSFXAtEntity(
              (EntityPlayer) null, 1009, (int) this.posX, (int) this.posY, (int) this.posZ, 0);

          for (int var10 = 0; var10 < 1; ++var10) {
            EntitySmallFireball var11 =
                new EntitySmallFireball(
                    this.worldObj,
                    this,
                    var3 + this.rand.nextGaussian() * (double) var9,
                    var5,
                    var7 + this.rand.nextGaussian() * (double) var9);
            var11.posY = this.posY + (double) (this.height / 2.0F) + 0.5D;
            this.worldObj.spawnEntityInWorld(var11);
          }
        }
      }

      this.rotationYaw = (float) (Math.atan2(var7, var3) * 180.0D / Math.PI) - 90.0F;
      this.hasAttacked = true;
    }
  }
  /**
   * Basic mob attack. Default to touch of death in EntityCreature. Overridden by each mob to define
   * their attack.
   */
  protected void attackEntity(Entity par1Entity, float par2) {
    if (attackTime <= 0
        && par2 < 2.0F
        && par1Entity.boundingBox.maxY > boundingBox.minY
        && par1Entity.boundingBox.minY < boundingBox.maxY) {
      attackTime = 20;
      attackEntityAsMob(par1Entity);
    } else if (par2 < 30F) {
      double d = par1Entity.posX - posX;
      double d1 =
          (par1Entity.boundingBox.minY + (double) (par1Entity.height / 2.0F))
              - (posY + (double) (height / 2.0F));
      double d2 = par1Entity.posZ - posZ;

      if (attackTime == 0) {
        field_70846_g++;

        if (field_70846_g == 1) {
          attackTime = 60;
          func_70844_e(true);
        } else if (field_70846_g <= 4) {
          attackTime = 6;
        } else {
          attackTime = 100;
          field_70846_g = 0;
          func_70844_e(false);
        }

        if (field_70846_g > 1) {
          float f = MathHelper.sqrt_float(par2) * 0.5F;
          worldObj.playAuxSFXAtEntity(null, 1009, (int) posX, (int) posY, (int) posZ, 0);

          for (int i = 0; i < 1; i++) {
            EntitySmallFireball entitysmallfireball =
                new EntitySmallFireball(
                    worldObj,
                    this,
                    d + rand.nextGaussian() * (double) f,
                    d1,
                    d2 + rand.nextGaussian() * (double) f);
            entitysmallfireball.posY = posY + (double) (height / 2.0F) + 0.5D;
            worldObj.spawnEntityInWorld(entitysmallfireball);
          }
        }
      }

      rotationYaw = (float) ((Math.atan2(d2, d) * 180D) / Math.PI) - 90F;
      hasAttacked = true;
    }
  }
Example #4
0
 public void t_() {
   try {
     super.t_();
     if (deathCounter-- <= 0) {
       die();
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }