Program: 34732
Project: 34732
Buggy source:
@Override public boolean attackEntityFrom(DamageSource source,float amount){
  if (isEntityInvulnerable())   return false;
  attackedRecentlyTimer=120;
  if (worldObj.difficultySetting == EnumDifficulty.PEACEFUL && source.getEntity() instanceof EntityPlayer) {
    if (super.attackEntityFrom(DamageSource.generic,amount)) {
      double diffX=source.getEntity().posX - posX, diffZ=source.getEntity().posZ - posZ;
      while (diffX * diffX + diffZ * diffZ < 1E-4D) {
        diffX=(Math.random() - Math.random()) * 0.01D;
        diffZ=(Math.random() - Math.random()) * 0.01D;
      }
      attackedAtYaw=(float)(Math.atan2(diffZ,diffX) * 180D / Math.PI) - rotationYaw;
      knockBack(source.getEntity(),amount,diffX,diffZ);
      if (homelandRole == HomelandRole.ISLAND_LEADERS || homelandRole == HomelandRole.GUARD || rand.nextInt(3) == 0) {
        for (int attempt=0; attempt < 10; attempt++) {
          if (teleportRandomly())           break;
        }
      }
      return true;
    }
 else     return false;
  }
  if (source.getEntity() instanceof EntityPlayer || source.getEntity() instanceof EntityMobHomelandEnderman) {
    boolean callGuards=entityToAttack == null || rand.nextInt(4) == 0;
    setTarget(source.getEntity());
    setScreaming(true);
    if (callGuards) {
      float guardPerc=0F, guardDist=0F;
switch (homelandRole) {
case ISLAND_LEADERS:
        guardPerc=0.95F;
      guardDist=260F;
    break;
case GUARD:
  guardPerc=0.4F;
guardDist=100F;
break;
case WORKER:
guardPerc=rand.nextFloat() * 0.2F;
guardDist=30F;
break;
case BUSINESSMAN:
case INTELLIGENCE:
guardPerc=0.1F + rand.nextFloat() * 0.15F;
guardDist=60F;
break;
case COLLECTOR:
case OVERWORLD_EXPLORER:
guardPerc=0.2F + rand.nextFloat() * 0.1F;
guardDist=80F;
break;
default :
}
guardPerc*=0.7F + rand.nextFloat() * 0.3F;
List<EntityMobHomelandEnderman> list=worldObj.getEntitiesWithinAABB(EntityMobHomelandEnderman.class,boundingBox.expand(guardDist,128D,guardDist));
for (Iterator<EntityMobHomelandEnderman> iter=list.iterator(); iter.hasNext(); ) {
if (iter.next().homelandRole != HomelandRole.GUARD) iter.remove();
}
for (int a=0, amt=Math.max(2,Math.round(list.size() * guardPerc)); a < amt && !list.isEmpty(); a++) {
EntityMobHomelandEnderman guard=list.remove(rand.nextInt(list.size()));
guard.setTarget(source.getEntity());
guard.setScreaming(true);
PacketPipeline.sendToAllAround(this,256D,new C22EffectLine(FXType.Line.HOMELAND_ENDERMAN_GUARD_CALL,this,guard));
}
}
}
 else if (source instanceof EntityDamageSourceIndirect) {
for (int attempt=0; attempt < 64; attempt++) {
if (teleportRandomly()) {
setTarget(null);
setScreaming(false);
return true;
}
}
}
return super.attackEntityFrom(source,amount);
}

Fixed version (ground truth):
@Override public boolean attackEntityFrom(DamageSource source,float amount){
  if (isEntityInvulnerable())   return false;
  attackedRecentlyTimer=120;
  if (worldObj.isRemote)   return super.attackEntityFrom(source,amount);
  if (worldObj.difficultySetting == EnumDifficulty.PEACEFUL && source.getEntity() instanceof EntityPlayer) {
    if (super.attackEntityFrom(DamageSource.generic,amount)) {
      double diffX=source.getEntity().posX - posX, diffZ=source.getEntity().posZ - posZ;
      while (diffX * diffX + diffZ * diffZ < 1E-4D) {
        diffX=(Math.random() - Math.random()) * 0.01D;
        diffZ=(Math.random() - Math.random()) * 0.01D;
      }
      attackedAtYaw=(float)(Math.atan2(diffZ,diffX) * 180D / Math.PI) - rotationYaw;
      knockBack(source.getEntity(),amount,diffX,diffZ);
      if (homelandRole == HomelandRole.ISLAND_LEADERS || homelandRole == HomelandRole.GUARD || rand.nextInt(3) == 0) {
        for (int attempt=0; attempt < 10; attempt++) {
          if (teleportRandomly())           break;
        }
      }
      return true;
    }
 else     return false;
  }
  if (source.getEntity() instanceof EntityPlayer || source.getEntity() instanceof EntityMobHomelandEnderman) {
    boolean callGuards=entityToAttack == null || rand.nextInt(4) == 0;
    setTarget(source.getEntity());
    setScreaming(true);
    if (callGuards) {
      float guardPerc=0F, guardDist=0F;
switch (homelandRole) {
case ISLAND_LEADERS:
        guardPerc=0.95F;
      guardDist=260F;
    break;
case GUARD:
  guardPerc=0.4F;
guardDist=100F;
break;
case WORKER:
guardPerc=rand.nextFloat() * 0.2F;
guardDist=30F;
break;
case BUSINESSMAN:
case INTELLIGENCE:
guardPerc=0.1F + rand.nextFloat() * 0.15F;
guardDist=60F;
break;
case COLLECTOR:
case OVERWORLD_EXPLORER:
guardPerc=0.2F + rand.nextFloat() * 0.1F;
guardDist=80F;
break;
default :
}
guardPerc*=0.7F + rand.nextFloat() * 0.3F;
List<EntityMobHomelandEnderman> list=worldObj.getEntitiesWithinAABB(EntityMobHomelandEnderman.class,boundingBox.expand(guardDist,128D,guardDist));
for (Iterator<EntityMobHomelandEnderman> iter=list.iterator(); iter.hasNext(); ) {
if (iter.next().homelandRole != HomelandRole.GUARD) iter.remove();
}
for (int a=0, amt=Math.max(2,Math.round(list.size() * guardPerc)); a < amt && !list.isEmpty(); a++) {
EntityMobHomelandEnderman guard=list.remove(rand.nextInt(list.size()));
guard.teleportToEntity(source.getEntity());
guard.setTarget(source.getEntity());
guard.setScreaming(true);
PacketPipeline.sendToAllAround(this,256D,new C22EffectLine(FXType.Line.HOMELAND_ENDERMAN_GUARD_CALL,this,guard));
}
}
}
 else if (source instanceof EntityDamageSourceIndirect) {
for (int attempt=0; attempt < 64; attempt++) {
if (teleportRandomly()) {
setTarget(null);
setScreaming(false);
return true;
}
}
}
return super.attackEntityFrom(source,amount);
}