Oh I'm dumb sorry about that I just realized something replace all the stuff after fEntityYaw = fEntityYaw % 360; with this : if(fEntityYaw < 0) fEntityYaw += 360; if(fMyYaw < 0) fMyYaw += 360; if(Math.abs(fMyYaw - fEntityYaw) <= 30){ //Attacking from behind }
float fMyYaw = player.getLocation().getYaw(), fEntityYaw = entity.getLocation().getYaw(); fMyYaw = fMyYaw % 360; fEntityYaw = fEntityYaw % 360; if(Math.abs(Math.abs(fMyYaw) - Math.abs(fEntityYaw)) <= 30){ //Attacking from behind } That should work I suppose, try it out.