NPC cow = npcs.closest("Cow","Cow calf");
That shouldn't be declared outside a method, remove that and remove
if(!inventory.isFull() && COW_AREA.contains(myPlayer()) && !myPlayer().isUnderAttack() && !cow.isUnderAttack() && cow != null)
{
return State.ATTACK;
}
the red part along with it
EDIT:
Also, try to debug this in onPaint(Graphics2D g)
g.drawString(getState().toString(), 15, 15);
Just to know which state you are in, it helps alot.