C2 point 93 in the category of PAST in the English Grammar Profile:
past perfect simple negative form after ‘if only’ to express regret.
It is an extremely rare structure with only 1 of each occurrence with nouns and only a few more with pronouns:
1 IF ONLY I HADN’T BEEN 14
2 IF ONLY HE HADN’T BEEN 11
3 IF ONLY IT HADN’T BEEN 7
4 IF ONLY THEY HADN’T BEEN 6
5 IF ONLY I HADN’T DONE 4
It is not always regret. It can be imagined past.
But fate turns on a moment, dear one’s, and the pig was about to learn the meaning of those two cruel words of regret: ” if only “. – If only he hadn’t been so careless. – Whoa! if only the weight of the pig and the pump did not exceed the weight of the farmer, if only the farmer did not connect with the platform on the way up… or jam his fingers at the top, if only the pump hadn’t fallen off at the bottom, and if only the poor farmer had the presence of mind… to hold onto the rope. Boss? Boss! At no other time in his short life… had the pig wished more that his words could be understood by humans, if only to say, ” Sorry, Boss “.