Program: 34645
Project: 34645
Buggy source:
@Override protected void updateEntityActionState(){
  if (lastAttacker != null && (lastAttacker.isDead || !lastAttacker.playerNetServerHandler.func_147362_b().isChannelOpen()))   lastAttacker=null;
  float health=getHealth();
  if (health <= 0)   return;
  if (lightningTarget == null && --healthRegenTimer < 0 && health < getMaxHealth())   setHealth(health + 1);
  if (healthRegenTimer < 0)   healthRegenTimer=9;
  if (lightningStartCounter <= 0) {
    lightningStartCounter=40;
    lightningCounter=0;
    lightningTarget=lastAttacker == null ? worldObj.getClosestPlayerToEntity(this,512D) : lastAttacker;
  }
  if (lightningTarget != null) {
    if (ticksExisted % 18 == 0) {
      double xx=lightningTarget.posX + (rand.nextDouble() - 0.5D) * 1.5D, yy=lightningTarget.posY, zz=lightningTarget.posZ + (rand.nextDouble() - 0.5D) * 1.5D;
      lightningTarget.attackEntityFrom(new DamageSourceMobUnscaled(this),DamageSourceMobUnscaled.getDamage(ModCommonProxy.opMobs ? 7F : 4F,worldObj.difficultySetting));
      EntityWeatherEffect bolt=new EntityWeatherLightningBoltDemon(worldObj,xx,yy,zz,this,false);
      worldObj.weatherEffects.add(bolt);
      PacketPipeline.sendToAllAround(bolt,512D,new C05CustomWeather(bolt,(byte)0));
      if (++lightningCounter >= 6)       lightningTarget=null;
    }
  }
 else {
    if (--endermanSpawnTimer < -100) {
      endermanSpawnTimer=(byte)(125 - rand.nextInt(40));
      if (obsidianSpawnTimer < -105)       obsidianSpawnTimer+=20;
      for (      EntityPlayer player : (List<EntityPlayer>)worldObj.getEntitiesWithinAABB(EntityPlayer.class,boundingBox.expand(128D,64D,128D))) {
        int attempt, ix, iy, iz;
        for (attempt=0; attempt < 40; attempt++) {
          double ang=rand.nextDouble() * Math.PI * 2D, len=3.5D + rand.nextDouble() * 2D;
          ix=MathUtil.floor(player.posX + Math.cos(ang) * len);
          iz=MathUtil.floor(player.posZ + Math.sin(ang) * len);
          for (iy=MathUtil.floor(player.posY) - 2; iy < player.posY + 3; iy++) {
            if (worldObj.isAirBlock(ix,iy,iz) && worldObj.isAirBlock(ix,iy + 1,iz) && worldObj.isAirBlock(ix,iy + 2,iz)) {
              for (int a=0; a < (ModCommonProxy.opMobs ? 4 : 3); a++) {
                EntityMobAngryEnderman enderman=new EntityMobAngryEnderman(worldObj,ix + rand.nextDouble(),iy,iz + rand.nextDouble());
                enderman.rotationYaw=rand.nextFloat() * 360F;
                enderman.setTarget(player);
                enderman.addPotionEffect(endermanStrength);
                worldObj.spawnEntityInWorld(enderman);
                attempt=999;
              }
              EntityWeatherEffect bolt=new EntityWeatherLightningBoltDemon(worldObj,ix + 0.5D,iy,iz + 0.5D,this,false);
              worldObj.addWeatherEffect(bolt);
              PacketPipeline.sendToAllAround(bolt,512D,new C05CustomWeather(bolt,(byte)0));
              break;
            }
          }
        }
      }
    }
    if (--obsidianSpawnTimer < -120) {
      obsidianSpawnTimer=(byte)(20 + rand.nextInt(80));
      List<EntityPlayer> list=worldObj.getEntitiesWithinAABB(EntityPlayer.class,boundingBox.expand(128D,64D,128D));
      if (!list.isEmpty()) {
        EntityPlayer player=list.get(rand.nextInt(list.size()));
        for (int attempt=0, placed=0, xx, yy, zz; attempt < 25 && placed < 12 + worldObj.difficultySetting.getDifficultyId() * 2; attempt++) {
          xx=MathUtil.floor(player.posX) + rand.nextInt(9) - 4;
          yy=MathUtil.floor(player.posY) + 9 + rand.nextInt(6);
          zz=MathUtil.floor(player.posZ) + rand.nextInt(9) - 4;
          if (worldObj.isAirBlock(xx,yy,zz) && worldObj.isAirBlock(xx,yy - 1,zz)) {
            worldObj.setBlock(xx,yy,zz,BlockList.obsidian_falling,0,3);
            ++placed;
          }
          if (placed > 5 && rand.nextInt(15) <= 1)           break;
        }
      }
    }
  }
  if (worldObj.isRemote)   return;
  boolean hasBlockBelow=false;
  for (int ix=MathUtil.floor(posX), iz=MathUtil.floor(posZ), yy=MathUtil.floor(posY); yy > posY - 22; yy--) {
    if (!worldObj.isAirBlock(ix,yy,iz)) {
      hasBlockBelow=true;
      break;
    }
  }
  if (hasBlockBelow) {
    motionY*=0.9D;
    if (Math.abs(motionY) < 0.04D)     motionY=0D;
  }
 else {
    motionY=-0.3D;
    ++endermanSpawnTimer;
    ++obsidianSpawnTimer;
    rotationPitch=-90F;
    lastAttacker=(EntityPlayerMP)worldObj.getClosestPlayerToEntity(this,512D);
  }
  if (lastAttacker != null) {
    double diffX=posX - lastAttacker.posX;
    double diffY=posY - lastAttacker.posY;
    double diffZ=posZ - lastAttacker.posZ;
    double distance=Math.sqrt(diffX * diffX + diffZ * diffZ);
    rotationYaw=DragonUtil.rotateSmoothly(rotationYaw,(float)(Math.atan2(diffZ,diffX) * 180D / Math.PI) - 270F,2F);
    rotationPitch=DragonUtil.rotateSmoothly(rotationPitch,(float)(-(Math.atan2(diffY,distance) * 180D / Math.PI)),8F);
  }
 else   if (rotationPitch < 0F)   rotationPitch-=2F;
}

Fixed version (ground truth):
@Override protected void updateEntityActionState(){
  if (lastAttacker != null && (lastAttacker.isDead || !lastAttacker.playerNetServerHandler.func_147362_b().isChannelOpen()))   lastAttacker=null;
  float health=getHealth();
  if (health <= 0)   return;
  if (lightningTarget == null && --healthRegenTimer < 0 && health < getMaxHealth())   setHealth(health + 1);
  if (healthRegenTimer < 0)   healthRegenTimer=9;
  if (lightningStartCounter <= 0) {
    lightningStartCounter=40;
    lightningCounter=0;
    lightningTarget=lastAttacker == null ? worldObj.getClosestPlayerToEntity(this,512D) : lastAttacker;
  }
  if (lightningTarget != null) {
    if (ticksExisted % 18 == 0) {
      double xx=lightningTarget.posX + (rand.nextDouble() - 0.5D) * 1.5D, yy=lightningTarget.posY, zz=lightningTarget.posZ + (rand.nextDouble() - 0.5D) * 1.5D;
      lightningTarget.attackEntityFrom(new DamageSourceMobUnscaled(this),DamageSourceMobUnscaled.getDamage(ModCommonProxy.opMobs ? 7F : 4F,worldObj.difficultySetting));
      EntityWeatherEffect bolt=new EntityWeatherLightningBoltDemon(worldObj,xx,yy,zz,this,false);
      worldObj.weatherEffects.add(bolt);
      PacketPipeline.sendToAllAround(bolt,512D,new C05CustomWeather(bolt,(byte)0));
      if (++lightningCounter >= 6)       lightningTarget=null;
    }
  }
 else {
    if (--endermanSpawnTimer < -100) {
      endermanSpawnTimer=(byte)(125 - rand.nextInt(40));
      if (obsidianSpawnTimer < -105)       obsidianSpawnTimer+=20;
      for (      EntityPlayer player : (List<EntityPlayer>)worldObj.getEntitiesWithinAABB(EntityPlayer.class,boundingBox.expand(128D,64D,128D))) {
        int attempt, ix, iy, iz;
        for (attempt=0; attempt < 40; attempt++) {
          double ang=rand.nextDouble() * Math.PI * 2D, len=3.5D + rand.nextDouble() * 2D;
          ix=MathUtil.floor(player.posX + Math.cos(ang) * len);
          iz=MathUtil.floor(player.posZ + Math.sin(ang) * len);
          for (iy=MathUtil.floor(player.posY) - 2; iy < player.posY + 3; iy++) {
            if (worldObj.isAirBlock(ix,iy,iz) && worldObj.isAirBlock(ix,iy + 1,iz) && worldObj.isAirBlock(ix,iy + 2,iz)) {
              for (int a=0; a < (ModCommonProxy.opMobs ? 4 : 3); a++) {
                EntityMobAngryEnderman enderman=new EntityMobAngryEnderman(worldObj,ix + rand.nextDouble(),iy,iz + rand.nextDouble());
                enderman.rotationYaw=rand.nextFloat() * 360F;
                enderman.setTarget(player);
                enderman.addPotionEffect(endermanStrength);
                worldObj.spawnEntityInWorld(enderman);
                attempt=999;
              }
              EntityWeatherEffect bolt=new EntityWeatherLightningBoltDemon(worldObj,ix + 0.5D,iy,iz + 0.5D,this,false);
              worldObj.addWeatherEffect(bolt);
              PacketPipeline.sendToAllAround(bolt,512D,new C05CustomWeather(bolt,(byte)0));
              break;
            }
          }
        }
      }
    }
    if (--obsidianSpawnTimer < -120) {
      obsidianSpawnTimer=(byte)(20 + rand.nextInt(80));
      EntityPlayer player=CollectionUtil.<EntityPlayer>randomOrNull(worldObj.getEntitiesWithinAABB(EntityPlayer.class,boundingBox.expand(128D,64D,128D)),rand);
      if (player != null) {
        for (int attempt=0, placed=0, xx, yy, zz; attempt < 25 && placed < 12 + worldObj.difficultySetting.getDifficultyId() * 2; attempt++) {
          xx=MathUtil.floor(player.posX) + rand.nextInt(9) - 4;
          yy=MathUtil.floor(player.posY) + 9 + rand.nextInt(6);
          zz=MathUtil.floor(player.posZ) + rand.nextInt(9) - 4;
          if (worldObj.isAirBlock(xx,yy,zz) && worldObj.isAirBlock(xx,yy - 1,zz)) {
            worldObj.setBlock(xx,yy,zz,BlockList.obsidian_falling,0,3);
            ++placed;
          }
          if (placed > 5 && rand.nextInt(15) <= 1)           break;
        }
      }
    }
  }
  if (worldObj.isRemote)   return;
  boolean hasBlockBelow=false;
  for (int ix=MathUtil.floor(posX), iz=MathUtil.floor(posZ), yy=MathUtil.floor(posY); yy > posY - 22; yy--) {
    if (!worldObj.isAirBlock(ix,yy,iz)) {
      hasBlockBelow=true;
      break;
    }
  }
  if (hasBlockBelow) {
    motionY*=0.9D;
    if (Math.abs(motionY) < 0.04D)     motionY=0D;
  }
 else {
    motionY=-0.3D;
    ++endermanSpawnTimer;
    ++obsidianSpawnTimer;
    rotationPitch=-90F;
    lastAttacker=(EntityPlayerMP)worldObj.getClosestPlayerToEntity(this,512D);
  }
  if (lastAttacker != null) {
    double diffX=posX - lastAttacker.posX;
    double diffY=posY - lastAttacker.posY;
    double diffZ=posZ - lastAttacker.posZ;
    double distance=Math.sqrt(diffX * diffX + diffZ * diffZ);
    rotationYaw=DragonUtil.rotateSmoothly(rotationYaw,(float)(Math.atan2(diffZ,diffX) * 180D / Math.PI) - 270F,2F);
    rotationPitch=DragonUtil.rotateSmoothly(rotationPitch,(float)(-(Math.atan2(diffY,distance) * 180D / Math.PI)),8F);
  }
 else   if (rotationPitch < 0F)   rotationPitch-=2F;
}