if you hurt pigmen then anger other pigmen. if pigmen is angry and has no target then target nearest human.
The code (as of 1.11.2) seems to mean more than that:
If a living entity (including player) attacks a zombie pigmen (via AIHurtByAggressor):
Trigger aggro towards the attacker on the attacked pigmen and nearby pigmen
Trigger anger towards the attacker on nearby pigmen, excluding the attacked pigmen
If a player attacks a zombie pigmen (via attackEntityFrom):
Trigger anger towards the attacker on the attacked pigmen
If a zombie pigmen is angry (positive anger timer):
Receives an attacking speed boost unless it is a baby pigmen (via updateAITasks)
Decrease anger timer (via updateAITasks)
Trigger aggro towards the player (but not other entities) it has anger towards (via updateAITasks) - I think this is to ensure a resumed chasing when the player reenter the pigmen's search range
Trigger aggro towards nearest player (via AITargetAggressor) - the direct cause of this issue
I'm not sure if all of the above are intended; there may be some unnecessary inconsistencies / redundancies.
In any case, as others have already mentioned, nether raiding in hard difficulty is unnecessarily difficult with this bug, especially in nether fortresses where it is difficult to avoid blazes and skeletons hitting zombie pigmen.
The code (as of 1.11.2) seems to mean more than that:
If a living entity (including player) attacks a zombie pigmen (via AIHurtByAggressor):
Trigger aggro towards the attacker on the attacked pigmen and nearby pigmen
Trigger anger towards the attacker on nearby pigmen, excluding the attacked pigmen
If a player attacks a zombie pigmen (via attackEntityFrom):
Trigger anger towards the attacker on the attacked pigmen
If a zombie pigmen is angry (positive anger timer):
Receives an attacking speed boost unless it is a baby pigmen (via updateAITasks)
Decrease anger timer (via updateAITasks)
Trigger aggro towards the player (but not other entities) it has anger towards (via updateAITasks) - I think this is to ensure a resumed chasing when the player reenter the pigmen's search range
Trigger aggro towards nearest player (via AITargetAggressor) - the direct cause of this issue
I'm not sure if all of the above are intended; there may be some unnecessary inconsistencies / redundancies.
In any case, as others have already mentioned, nether raiding in hard difficulty is unnecessarily difficult with this bug, especially in nether fortresses where it is difficult to avoid blazes and skeletons hitting zombie pigmen.