Пример #1
0
 /** Called to update the entity's position/logic. */
 public void onUpdate() {
   onEntityUpdate();
 }
  public void onEntityUpdate() {
    prevSwingProgress = swingProgress;
    super.onEntityUpdate();
    if (rand.nextInt(1000) < field_4121_a++) {
      field_4121_a = -func_421_b();
      func_22050_O();
    }
    if (isEntityAlive() && func_345_I()) {
      attackEntityFrom(null, 1);
    }
    if (isImmuneToFire || worldObj.multiplayerWorld) {
      fire = 0;
    }
    if (isEntityAlive() && isInsideOfMaterial(Material.water) && !canBreatheUnderwater()) {
      air--;
      if (air == -20) {
        air = 0;
        for (int i = 0; i < 8; i++) {
          float f = rand.nextFloat() - rand.nextFloat();
          float f1 = rand.nextFloat() - rand.nextFloat();
          float f2 = rand.nextFloat() - rand.nextFloat();
          worldObj.spawnParticle(
              "bubble",
              posX + (double) f,
              posY + (double) f1,
              posZ + (double) f2,
              motionX,
              motionY,
              motionZ);
        }

        attackEntityFrom(null, 2);
      }
      fire = 0;
    } else {
      air = maxAir;
    }
    field_9329_Q = field_9328_R;
    if (attackTime > 0) {
      attackTime--;
    }
    if (hurtTime > 0) {
      hurtTime--;
    }
    if (field_9306_bj > 0) {
      field_9306_bj--;
    }
    if (health <= 0) {
      deathTime++;
      if (deathTime > 20) {
        func_6392_F();
        setEntityDead();
        for (int j = 0; j < 20; j++) {
          double d = rand.nextGaussian() * 0.02D;
          double d1 = rand.nextGaussian() * 0.02D;
          double d2 = rand.nextGaussian() * 0.02D;
          worldObj.spawnParticle(
              "explode",
              (posX + (double) (rand.nextFloat() * width * 2.0F)) - (double) width,
              posY + (double) (rand.nextFloat() * height),
              (posZ + (double) (rand.nextFloat() * width * 2.0F)) - (double) width,
              d,
              d1,
              d2);
        }
      }
    }
    field_9359_x = field_9360_w;
    prevRenderYawOffset = renderYawOffset;
    prevRotationYaw = rotationYaw;
    prevRotationPitch = rotationPitch;
  }