Program: 34746
Project: 34746
Buggy source:
@Override public void onLivingUpdate(){
  if (worldObj.isRemote) {
    refreshRoles();
    int chance=1 + (int)Math.floor(HardcoreEnderExpansion.proxy.getClientSidePlayer().getDistanceToEntity(this) / 12F);
    if (rand.nextInt(chance) == 0) {
      float colFactor=rand.nextFloat() * 0.6F + 0.4F;
      HardcoreEnderExpansion.fx.portalColor(worldObj,posX + (rand.nextDouble() - 0.5D) * width,posY + rand.nextDouble() * height - 0.25D,posZ + (rand.nextDouble() - 0.5D) * width,(rand.nextDouble() - 0.5D) * 2D,-rand.nextDouble(),(rand.nextDouble() - 0.5D) * 2D,colFactor * 0.9F,colFactor * 0.3F,colFactor);
      if (homelandRole != null && rand.nextInt(3) == 0) {
        HardcoreEnderExpansion.fx.portalColor(worldObj,posX + (rand.nextDouble() - 0.5D) * width,posY + rand.nextDouble() * height - 0.25D,posZ + (rand.nextDouble() - 0.5D) * width,(rand.nextDouble() - 0.5D) * 2D,-rand.nextDouble(),(rand.nextDouble() - 0.5D) * 2D,homelandRole.red,homelandRole.green,homelandRole.blue);
      }
      if (overtakeGroupRole != null && rand.nextInt(7) == 0) {
        HardcoreEnderExpansion.fx.portalColor(worldObj,posX + (rand.nextDouble() - 0.5D) * width,posY + rand.nextDouble() * height - 0.25D,posZ + (rand.nextDouble() - 0.5D) * width,(rand.nextDouble() - 0.5D) * 2D,-rand.nextDouble(),(rand.nextDouble() - 0.5D) * 2D,0.3F,0.3F,0.3F);
      }
    }
  }
 else   if (isEntityAlive()) {
    if (isWet())     attackEntityFrom(DamageSource.drown,1F);
    if (isWet() || isBurning()) {
      setTarget(null);
      setScreaming(false);
    }
    if (!onGround && ++fallTimer > 11 + rand.nextInt(10)) {
      fallTimer=0;
      for (int attempt=0; attempt < 500; attempt++) {
        if (teleportRandomly(92D)) {
          resetTask();
          System.out.println("String_Node_Str");
          break;
        }
      }
    }
    long overtakeGroup=HomelandEndermen.getOvertakeGroup(this);
    if (currentTask == EndermanTask.WAIT || currentTask == EndermanTask.GET_TNT) {
      moveForward=moveStrafing=0F;
      fallDistance=0F;
      posY=10000D;
      if (--currentTaskTimer == 0) {
        int tpX, tpY, tpZ;
        for (int attempt=0; attempt < 100; attempt++) {
          tpX=(int)Math.floor(posX) + rand.nextInt(40) - 20;
          tpZ=(int)Math.floor(posZ) + rand.nextInt(40) - 20;
          tpY=worldObj.getTopSolidOrLiquidBlock(tpX,tpZ) - 1;
          if (worldObj.getBlock(tpX,tpY,tpZ) == BlockList.end_terrain) {
            teleportTo(tpX + 0.3D + rand.nextDouble() * 0.4D,tpY + 1D,tpZ + 0.3D + rand.nextDouble() * 0.4D,true);
            if (overtakeGroupRole == OvertakeGroupRole.CHAOSMAKER) {
              setCarrying(new ItemStack(Blocks.tnt));
            }
 else             if (homelandRole == HomelandRole.COLLECTOR && rand.nextInt(4) != 0) {
              setCarrying(new ItemStack(StructureEndermanStash.getRandomBlock(rand)));
            }
            break;
          }
        }
        resetTask();
      }
    }
    if (overtakeGroup == -1) {
      if (currentTask != EndermanTask.NONE && currentTask != EndermanTask.WAIT) {
        --currentTaskTimer;
        if (currentTask == EndermanTask.LISTEN_TO_RECRUITER || currentTask == EndermanTask.RECRUIT_TO_GROUP) {
          moveForward=moveStrafing=0F;
          System.out.println("String_Node_Str" + currentTaskTimer);
          if (currentTaskTimer == 0 && currentTask == EndermanTask.RECRUIT_TO_GROUP) {
            int chance=50, reportChance=10;
            EntityMobHomelandEnderman target=(EntityMobHomelandEnderman)currentTaskData;
switch (target.homelandRole) {
case WORKER:
              chance=30;
            break;
case GUARD:
          chance=15;
        reportChance=35;
      break;
case INTELLIGENCE:
    chance=80;
  reportChance=22;
break;
case BUSINESSMAN:
chance=40;
reportChance=14;
break;
default :
}
if (rand.nextInt(100) < chance) {
target.setGroupMember(groupId,OvertakeGroupRole.getRandomMember(rand));
for (int attempt=0; attempt < 50; attempt++) {
if (teleportRandomly()) break;
}
System.out.println("String_Node_Str");
}
 else if (rand.nextInt(100) < reportChance) {
boolean escaped=false;
double oldX=posX, oldY=posY, oldZ=posZ;
if (rand.nextInt(5) != 0) {
for (int attempt=0; attempt < 20; attempt++) {
if (teleportRandomly()) {
escaped=true;
break;
}
}
}
List<EntityMobHomelandEnderman> guards=HomelandEndermen.getByHomelandRole(this,HomelandRole.GUARD);
System.out.println("String_Node_Str");
for (int a=0, amt=Math.max(3,(int)Math.round(guards.size() * 0.3D)); a < amt; a++) {
EntityMobHomelandEnderman guard=guards.get(rand.nextInt(guards.size()));
guard.setScreaming(true);
if (!escaped) guard.setTarget(this);
 else if (rand.nextBoolean()) guard.teleportTo(oldX + 4D * (rand.nextDouble() - 0.5D),oldY + 2D + rand.nextDouble() * 4D,oldZ + 4D * (rand.nextDouble() - 0.5D));
}
}
}
}
 else if (currentTask == EndermanTask.STROLL) {
if (currentTaskTimer > 0 && currentTaskTimer < 20 && rand.nextInt(3) == 0) {
Vec3 obj=(Vec3)currentTaskData;
if (obj.distanceTo(Vec3.createVectorHelper(posX,posY,posZ)) <= 0.5D || rand.nextInt(10) == 0) {
for (int attempt=0; attempt < 30; attempt++) {
if (teleportRandomly(48D)) {
currentTaskData=Vec3.createVectorHelper(posX,posY,posZ);
break;
}
}
}
}
if (currentTaskTimer == 0 && rand.nextInt(5) == 0) {
currentTaskTimer=10 + rand.nextInt(60);
System.out.println("String_Node_Str");
}
}
 else if (currentTask == EndermanTask.WALK) {
ChunkPosition pos=(ChunkPosition)currentTaskData;
if (MathUtil.distance(posX - pos.chunkPosX,posY - pos.chunkPosY,posZ - pos.chunkPosZ) < 3D) resetTask();
}
 else if (currentTask == EndermanTask.COMMUNICATE) {
moveForward=moveStrafing=0F;
}
if (currentTaskTimer <= 0) resetTask();
}
 else if (entityToAttack == null) {
if (groupId != -1 && rand.nextInt(400) == 0) {
List<EntityMobHomelandEnderman> total=HomelandEndermen.getAll(this);
int groupAmt=HomelandEndermen.getInSameGroup(this).size();
int totalAmt=total.size();
if (totalAmt > 8 && (rand.nextInt(5) <= 2 || groupAmt < (totalAmt >> 2) + rand.nextInt(totalAmt >> 3) - rand.nextInt(4))) {
for (int attempt=0; attempt < 5; attempt++) {
EntityMobHomelandEnderman enderman=total.get(rand.nextInt(totalAmt));
if (enderman == this || enderman.groupId != -1 || !enderman.onGround || enderman.homelandRole == HomelandRole.ISLAND_LEADERS || enderman.getDistanceToEntity(this) > 80D) continue;
if (groupAmt > 3 && ((enderman.homelandRole == HomelandRole.GUARD || enderman.homelandRole == HomelandRole.WORKER) && rand.nextInt(5) != 0)) continue;
boolean tp=false;
for (int tpAttempt=0; tpAttempt < 30; tpAttempt++) {
if (teleportTo(enderman.posX + (rand.nextDouble() - 0.5D) * 2D,enderman.posY,enderman.posZ + (rand.nextDouble() - 0.5D) * 2D)) {
tp=true;
break;
}
}
if (!tp) continue;
currentTask=EndermanTask.RECRUIT_TO_GROUP;
currentTaskData=enderman;
enderman.currentTask=EndermanTask.LISTEN_TO_RECRUITER;
enderman.currentTaskTimer=currentTaskTimer=20 + rand.nextInt(60);
System.out.println("String_Node_Str" + posX + "String_Node_Str"+ posY+ "String_Node_Str"+ posZ);
break;
}
}
}
if (currentTask == EndermanTask.NONE && rand.nextInt(80) == 0) {
switch (homelandRole) {
case ISLAND_LEADERS:
if (rand.nextInt(10) == 0) {
teleportRandomly();
}
 else {
Vec3 look=getLookVec();
for (int attempt=0, pathX, pathY, pathZ; attempt < 12; attempt++) {
if (attempt > 8 || rand.nextInt(6) == 0) look=Vec3.createVectorHelper(rand.nextDouble() - 0.5D,0D,rand.nextDouble() - 0.5D).normalize();
pathX=(int)(posX + look.xCoord * 16D + (rand.nextDouble() - 0.5D) * 5D);
pathZ=(int)(posZ + look.zCoord * 16D + (rand.nextDouble() - 0.5D) * 5D);
pathY=worldObj.getTopSolidOrLiquidBlock(pathX,pathZ) - 1;
if (worldObj.getBlock(pathX,pathY,pathZ) == BlockList.end_terrain && MathUtil.distance(posX - pathX,posY - pathY,posZ - pathZ) > 5D) {
setPathToEntity(worldObj.getEntityPathToXYZ(this,pathX,pathY + 1,pathZ,30F,true,false,false,true));
currentTask=EndermanTask.STROLL;
currentTaskTimer=45 + rand.nextInt(70);
currentTaskData=Vec3.createVectorHelper(posX,posY,posZ);
System.out.println("String_Node_Str" + pathX + "String_Node_Str"+ pathY+ "String_Node_Str"+ pathZ);
break;
}
}
}
break;
case BUSINESSMAN:
if (rand.nextInt(18) == 0) {
List<EntityMobHomelandEnderman> businessmen=HomelandEndermen.getByHomelandRole(this,HomelandRole.BUSINESSMAN);
if (!businessmen.isEmpty()) {
EntityMobHomelandEnderman enderman=businessmen.get(rand.nextInt(businessmen.size()));
if (enderman.currentTask == EndermanTask.NONE) {
currentTask=enderman.currentTask=EndermanTask.COMMUNICATE;
currentTaskTimer=enderman.currentTaskTimer=30 + rand.nextInt(50 + rand.nextInt(80));
System.out.println("String_Node_Str" + posX + "String_Node_Str"+ posY+ "String_Node_Str"+ posZ);
}
}
}
 else if (rand.nextInt(10) == 0) {
int walkToX, walkToY, walkToZ;
for (int attempt=0; attempt < 10; attempt++) {
walkToX=(int)posX + rand.nextInt(250) - 125;
walkToZ=(int)posZ + rand.nextInt(250) - 125;
walkToY=worldObj.getTopSolidOrLiquidBlock(walkToX,walkToZ) - 1;
if (worldObj.getBlock(walkToX,walkToY,walkToZ) == BlockList.end_terrain) {
setPathToEntity(worldObj.getEntityPathToXYZ(this,walkToX,walkToY + 1,walkToZ,100F,true,false,false,true));
currentTask=EndermanTask.WALK;
currentTaskTimer=200 + rand.nextInt(100);
currentTaskData=new ChunkPosition(walkToX,walkToY,walkToZ);
System.out.println("String_Node_Str" + walkToX + "String_Node_Str"+ walkToY+ "String_Node_Str"+ walkToZ);
break;
}
}
}
break;
case WORKER:
if (rand.nextInt(270) == 0 && worldObj.getBlock((int)Math.floor(posX),(int)Math.floor(posY) + 1,(int)Math.floor(posZ)) != BlockList.ender_goo) {
for (int attempt=0, tpX, tpY, tpZ; attempt < 50; attempt++) {
tpX=(int)posX + rand.nextInt(70) - 35;
tpZ=(int)posZ + rand.nextInt(70) - 35;
tpY=worldObj.getTopSolidOrLiquidBlock(tpX,tpZ) - 1;
if (worldObj.getBlock(tpX,tpY,tpZ) == BlockList.ender_goo) {
teleportTo(tpX + 0.5D + (rand.nextDouble() - 0.5D) * 0.3D,tpY + 1D,tpZ + 0.5D + (rand.nextDouble() - 0.5D) * 0.3D,true);
System.out.println("String_Node_Str" + tpX + "String_Node_Str"+ tpY+ "String_Node_Str"+ tpZ);
break;
}
}
}
break;
case COLLECTOR:
if (rand.nextInt(50) == 0 && (!isCarrying() || rand.nextInt(4) == 0)) {
currentTask=EndermanTask.WAIT;
currentTaskTimer=150 + rand.nextInt(600 + rand.nextInt(1800));
setCarrying(null);
teleportTo(posX,10000D,posZ,true);
System.out.println("String_Node_Str");
}
break;
case OVERWORLD_EXPLORER:
if (rand.nextInt(200) == 0) {
currentTask=EndermanTask.WAIT;
currentTaskTimer=500 + rand.nextInt(800) + rand.nextInt(1000) * (1 + rand.nextInt(4));
List<EntityMobHomelandEnderman> explorers=HomelandEndermen.getByHomelandRole(this,HomelandRole.OVERWORLD_EXPLORER);
for (int a=0; a < 1 + rand.nextInt(7) && !explorers.isEmpty(); a++) {
if (rand.nextInt(3) == 0) break;
EntityMobHomelandEnderman enderman=explorers.remove(rand.nextInt(explorers.size()));
if (enderman == this) continue;
enderman.currentTask=EndermanTask.WAIT;
enderman.currentTaskTimer=currentTaskTimer + rand.nextInt(500);
enderman.teleportTo(enderman.posX,10000D,enderman.posZ,true);
System.out.println("String_Node_Str");
}
teleportTo(posX,10000D,posZ,true);
System.out.println("String_Node_Str");
}
break;
default :
}
}
}
}
if (overtakeGroup != -1) {
if (overtakeGroup == groupId) {
if (currentTask == EndermanTask.NONE) {
switch (overtakeGroupRole) {
case TELEPORTER:
if (rand.nextInt(8) == 0) teleportRandomly(12D);
break;
case CHAOSMAKER:
if (isCarrying() && getCarrying().getItem() == Item.getItemFromBlock(Blocks.tnt)) {
if (rand.nextInt(50) == 0) {
for (int attempt=0, xx, yy, zz; attempt < 30; attempt++) {
xx=(int)Math.floor(posX) + rand.nextInt(6) - 3;
yy=(int)Math.floor(posY) + rand.nextInt(3) - 1;
zz=(int)Math.floor(posZ) + rand.nextInt(6) - 3;
if (worldObj.getBlock(xx,yy,zz) == BlockList.end_terrain && worldObj.isAirBlock(xx,yy + 1,zz)) {
worldObj.spawnEntityInWorld(new EntityTNTPrimed(worldObj,xx + 0.5D,yy + 1.5D,zz + 0.5D,this));
setCarrying(null);
break;
}
}
}
}
 else {
currentTask=EndermanTask.GET_TNT;
currentTaskTimer=30 + rand.nextInt(80);
setPosition(posX,10000D,posZ);
}
break;
case LEADER:
case FIGHTER:
if (!(entityToAttack instanceof EntityMobHomelandEnderman)) {
EntityMobHomelandEnderman target=null;
if (overtakeGroupRole == OvertakeGroupRole.LEADER || rand.nextInt(4) == 0) {
List<EntityMobHomelandEnderman> list=HomelandEndermen.getByHomelandRole(this,HomelandRole.ISLAND_LEADERS);
if (!list.isEmpty()) target=list.get(rand.nextInt(list.size()));
}
if (target == null) {
List<EntityMobHomelandEnderman> other=HomelandEndermen.getAll(this);
for (int attempt=0, size=other.size(); attempt < 10; attempt++) {
EntityMobHomelandEnderman potentialTarget=other.get(rand.nextInt(size));
if (potentialTarget == this || potentialTarget.isInSameGroup(this)) continue;
HomelandRole role=potentialTarget.homelandRole;
if (role == HomelandRole.GUARD && rand.nextInt(3) != 0) target=potentialTarget;
 else if (role != HomelandRole.WORKER || rand.nextInt(5) <= 1) target=potentialTarget;
break;
}
}
setAttackTarget(target);
}
break;
default :
}
}
if (!worldObj.getEntitiesWithinAABB(EntityTNTPrimed.class,boundingBox.expand(5D,3D,5D)).isEmpty()) teleportRandomly();
}
 else if (groupId != -1) {
if (rand.nextInt(3) == 0) setGroupMember(overtakeGroup,OvertakeGroupRole.getRandomMember(rand));
 else setGroupMember(-1,null);
}
}
if (entityToAttack != null) {
++attackTpTimer;
if (((attackTpTimer > 50 + rand.nextInt(30) && rand.nextInt(20) == 0) || attackTpTimer > 120) && entityToAttack.getDistanceSqToEntity(this) < 16D) {
teleportRandomly(16D);
attackTpTimer=-80;
}
 else if (entityToAttack.getDistanceSqToEntity(this) > 256D && attackTpTimer > 30 && teleportToEntity(entityToAttack)) {
attackTpTimer=-80;
}
}
 else {
attackTpTimer=-80;
if (currentTask == EndermanTask.NONE && entityToAttack == null && ++randomTpTimer > 50 + rand.nextInt(70)) {
if (rand.nextInt(18) == 0) {
for (int attempt=0; attempt < 5; attempt++) {
if (teleportRandomly(16D)) break;
}
}
randomTpTimer-=80 + rand.nextInt(40);
}
if (screamTimer > 0 && --screamTimer == 0 && isScreaming()) setScreaming(false);
}
}
isJumping=false;
if (entityToAttack != null) faceEntity(entityToAttack,100F,100F);
super.onLivingUpdate();
}

Fixed version (ground truth):
@Override public void onLivingUpdate(){
  if (worldObj.isRemote) {
    refreshRoles();
    int chance=1 + (int)Math.floor(HardcoreEnderExpansion.proxy.getClientSidePlayer().getDistanceToEntity(this) / 20F);
    if (rand.nextInt(chance) == 0) {
      float colFactor=rand.nextFloat() * 0.6F + 0.4F;
      HardcoreEnderExpansion.fx.portalColor(worldObj,posX + (rand.nextDouble() - 0.5D) * width,posY + rand.nextDouble() * height - 0.25D,posZ + (rand.nextDouble() - 0.5D) * width,(rand.nextDouble() - 0.5D) * 2D,-rand.nextDouble(),(rand.nextDouble() - 0.5D) * 2D,colFactor * 0.9F,colFactor * 0.3F,colFactor);
      if (homelandRole != null && rand.nextInt(3) == 0) {
        HardcoreEnderExpansion.fx.portalColor(worldObj,posX + (rand.nextDouble() - 0.5D) * width,posY + rand.nextDouble() * height - 0.25D,posZ + (rand.nextDouble() - 0.5D) * width,(rand.nextDouble() - 0.5D) * 2D,-rand.nextDouble(),(rand.nextDouble() - 0.5D) * 2D,homelandRole.red,homelandRole.green,homelandRole.blue);
      }
      if (overtakeGroupRole != null && rand.nextInt(7) == 0) {
        HardcoreEnderExpansion.fx.portalColor(worldObj,posX + (rand.nextDouble() - 0.5D) * width,posY + rand.nextDouble() * height - 0.25D,posZ + (rand.nextDouble() - 0.5D) * width,(rand.nextDouble() - 0.5D) * 2D,-rand.nextDouble(),(rand.nextDouble() - 0.5D) * 2D,0.3F,0.3F,0.3F);
      }
    }
  }
 else   if (isEntityAlive()) {
    setCustomNameTag(homelandRole.name() + "String_Node_Str" + (overtakeGroupRole == null ? "String_Node_Str" : overtakeGroupRole.name())+ "String_Node_Str"+ currentTask+ "String_Node_Str"+ currentTaskTimer+ "String_Node_Str"+ entityToAttack);
    if (isWet())     attackEntityFrom(DamageSource.drown,1F);
    if (isWet() || isBurning()) {
      setTarget(null);
      setScreaming(false);
    }
    if (!onGround && ++fallTimer > 17 + rand.nextInt(15)) {
      fallTimer=0;
      for (int attempt=0; attempt < 500; attempt++) {
        if (teleportRandomly(48D)) {
          resetTask();
          System.out.println("String_Node_Str" + homelandRole);
          break;
        }
      }
    }
    long overtakeGroup=HomelandEndermen.getOvertakeGroup(this);
    if (currentTask == EndermanTask.WAIT || currentTask == EndermanTask.GET_TNT) {
      moveForward=moveStrafing=0F;
      fallDistance=0F;
      fallTimer=0;
      posY=10000D;
      if (--currentTaskTimer == 0) {
        int tpX, tpY, tpZ;
        for (int attempt=0; attempt < 100; attempt++) {
          tpX=(int)Math.floor(posX) + rand.nextInt(40) - 20;
          tpZ=(int)Math.floor(posZ) + rand.nextInt(40) - 20;
          tpY=worldObj.getTopSolidOrLiquidBlock(tpX,tpZ) - 1;
          if (worldObj.getBlock(tpX,tpY,tpZ) == BlockList.end_terrain) {
            teleportTo(tpX + 0.3D + rand.nextDouble() * 0.4D,tpY + 1D,tpZ + 0.3D + rand.nextDouble() * 0.4D,true);
            if (overtakeGroupRole == OvertakeGroupRole.CHAOSMAKER) {
              setCarrying(new ItemStack(Blocks.tnt));
            }
 else             if (homelandRole == HomelandRole.COLLECTOR && rand.nextInt(4) != 0) {
              setCarrying(new ItemStack(StructureEndermanStash.getRandomBlock(rand)));
            }
            break;
          }
        }
        resetTask();
      }
    }
    if (overtakeGroup == -1) {
      if (currentTask != EndermanTask.NONE && currentTask != EndermanTask.WAIT) {
        --currentTaskTimer;
        if (currentTask == EndermanTask.LISTEN_TO_RECRUITER || currentTask == EndermanTask.RECRUIT_TO_GROUP) {
          moveForward=moveStrafing=0F;
          if (currentTaskTimer == 0 && currentTask == EndermanTask.RECRUIT_TO_GROUP) {
            int chance=50, reportChance=10;
            EntityMobHomelandEnderman target=(EntityMobHomelandEnderman)currentTaskData;
switch (target.homelandRole) {
case WORKER:
              chance=30;
            break;
case GUARD:
          chance=15;
        reportChance=35;
      break;
case INTELLIGENCE:
    chance=80;
  reportChance=22;
break;
case BUSINESSMAN:
chance=40;
reportChance=14;
break;
default :
}
if (rand.nextInt(100) < chance) {
target.setGroupMember(groupId,OvertakeGroupRole.getRandomMember(rand));
for (int attempt=0; attempt < 50; attempt++) {
if (teleportRandomly()) break;
}
System.out.println("String_Node_Str");
}
 else if (rand.nextInt(100) < reportChance) {
boolean escaped=false;
double oldX=posX, oldY=posY, oldZ=posZ;
if (rand.nextInt(5) != 0) {
for (int attempt=0; attempt < 20; attempt++) {
if (teleportRandomly()) {
escaped=true;
break;
}
}
}
List<EntityMobHomelandEnderman> guards=HomelandEndermen.getByHomelandRole(this,HomelandRole.GUARD);
System.out.println("String_Node_Str");
for (int a=0, amt=Math.max(3,(int)Math.round(guards.size() * 0.3D)); a < amt; a++) {
EntityMobHomelandEnderman guard=guards.get(rand.nextInt(guards.size()));
guard.setScreaming(true);
if (!escaped) guard.setTarget(this);
 else if (rand.nextInt(4) != 0) guard.teleportTo(oldX + 4D * (rand.nextDouble() - 0.5D),oldY + 2D + rand.nextDouble() * 4D,oldZ + 4D * (rand.nextDouble() - 0.5D));
}
}
recruitCooldown=120;
}
}
 else if (currentTask == EndermanTask.STROLL) {
if (currentTaskTimer > 0 && currentTaskTimer < 20 && rand.nextInt(3) == 0) {
Vec3 obj=(Vec3)currentTaskData;
if ((obj.distanceTo(Vec3.createVectorHelper(posX,posY,posZ)) <= 0.5D || rand.nextInt(10) == 0) && randomTpTimer > 30) {
double d=obj.distanceTo(Vec3.createVectorHelper(posX,posY,posZ));
for (int attempt=0; attempt < 30; attempt++) {
if (teleportRandomly(48D)) {
System.out.println("String_Node_Str" + d);
currentTaskData=Vec3.createVectorHelper(posX,posY,posZ);
randomTpTimer-=40 + rand.nextInt(30);
break;
}
}
}
}
if (currentTaskTimer == 0 && rand.nextInt(5) == 0) {
currentTaskTimer=10 + rand.nextInt(60);
System.out.println("String_Node_Str");
}
}
 else if (currentTask == EndermanTask.WALK) {
ChunkPosition pos=(ChunkPosition)currentTaskData;
if (MathUtil.distance(posX - pos.chunkPosX,posY - pos.chunkPosY,posZ - pos.chunkPosZ) < 3D) resetTask();
}
 else if (currentTask == EndermanTask.COMMUNICATE) {
moveForward=moveStrafing=0F;
}
if (currentTaskTimer <= 0) resetTask();
}
 else if (entityToAttack == null) {
if (groupId != -1 && rand.nextInt(400) == 0 && (recruitCooldown < -120 || --recruitCooldown < -120)) {
List<EntityMobHomelandEnderman> total=HomelandEndermen.getAll(this);
int groupAmt=HomelandEndermen.getInSameGroup(this).size();
int totalAmt=total.size();
if (totalAmt > 8 && (rand.nextInt(5) <= 2 || groupAmt < (totalAmt >> 2) + rand.nextInt(totalAmt >> 3) - rand.nextInt(4))) {
for (int attempt=0; attempt < 5; attempt++) {
EntityMobHomelandEnderman enderman=total.get(rand.nextInt(totalAmt));
if (enderman == this || enderman.groupId != -1 || !enderman.onGround || enderman.homelandRole == HomelandRole.ISLAND_LEADERS || enderman.getDistanceToEntity(this) > 80D) continue;
if (groupAmt > 3 && ((enderman.homelandRole == HomelandRole.GUARD || enderman.homelandRole == HomelandRole.WORKER) && rand.nextInt(5) != 0)) continue;
boolean tp=false;
for (int tpAttempt=0; tpAttempt < 30; tpAttempt++) {
if (teleportTo(enderman.posX + (rand.nextDouble() - 0.5D) * 2D,enderman.posY,enderman.posZ + (rand.nextDouble() - 0.5D) * 2D)) {
tp=true;
break;
}
}
if (!tp) continue;
currentTask=EndermanTask.RECRUIT_TO_GROUP;
currentTaskData=enderman;
enderman.currentTask=EndermanTask.LISTEN_TO_RECRUITER;
enderman.currentTaskTimer=currentTaskTimer=20 + rand.nextInt(60);
System.out.println("String_Node_Str" + posX + "String_Node_Str"+ posY+ "String_Node_Str"+ posZ);
break;
}
}
}
if (currentTask == EndermanTask.NONE && rand.nextInt(80) == 0) {
switch (homelandRole) {
case ISLAND_LEADERS:
if (rand.nextInt(10) == 0) {
teleportRandomly();
}
 else {
Vec3 look=getLookVec();
for (int attempt=0, pathX, pathY, pathZ; attempt < 12; attempt++) {
if (attempt > 8 || rand.nextInt(6) == 0) look=Vec3.createVectorHelper(rand.nextDouble() - 0.5D,0D,rand.nextDouble() - 0.5D).normalize();
pathX=(int)(posX + look.xCoord * 16D + (rand.nextDouble() - 0.5D) * 5D);
pathZ=(int)(posZ + look.zCoord * 16D + (rand.nextDouble() - 0.5D) * 5D);
pathY=worldObj.getTopSolidOrLiquidBlock(pathX,pathZ) - 1;
if (worldObj.getBlock(pathX,pathY,pathZ) == BlockList.end_terrain && MathUtil.distance(posX - pathX,posY - pathY,posZ - pathZ) > 5D) {
setPathToEntity(worldObj.getEntityPathToXYZ(this,pathX,pathY + 1,pathZ,30F,true,false,false,true));
currentTask=EndermanTask.STROLL;
currentTaskTimer=65 + rand.nextInt(60);
currentTaskData=Vec3.createVectorHelper(posX,posY,posZ);
System.out.println("String_Node_Str" + pathX + "String_Node_Str"+ pathY+ "String_Node_Str"+ pathZ);
break;
}
}
}
break;
case BUSINESSMAN:
if (rand.nextInt(18) == 0) {
List<EntityMobHomelandEnderman> businessmen=HomelandEndermen.getByHomelandRole(this,HomelandRole.BUSINESSMAN);
if (!businessmen.isEmpty()) {
EntityMobHomelandEnderman enderman=businessmen.get(rand.nextInt(businessmen.size()));
if (enderman.currentTask == EndermanTask.NONE) {
currentTask=enderman.currentTask=EndermanTask.COMMUNICATE;
currentTaskTimer=enderman.currentTaskTimer=30 + rand.nextInt(50 + rand.nextInt(80));
System.out.println("String_Node_Str" + posX + "String_Node_Str"+ posY+ "String_Node_Str"+ posZ);
}
}
}
 else if (rand.nextInt(10) == 0) {
int walkToX, walkToY, walkToZ;
for (int attempt=0; attempt < 10; attempt++) {
walkToX=(int)posX + rand.nextInt(250) - 125;
walkToZ=(int)posZ + rand.nextInt(250) - 125;
walkToY=worldObj.getTopSolidOrLiquidBlock(walkToX,walkToZ) - 1;
if (worldObj.getBlock(walkToX,walkToY,walkToZ) == BlockList.end_terrain) {
setPathToEntity(worldObj.getEntityPathToXYZ(this,walkToX,walkToY + 1,walkToZ,100F,true,false,false,true));
currentTask=EndermanTask.WALK;
currentTaskTimer=200 + rand.nextInt(100);
currentTaskData=new ChunkPosition(walkToX,walkToY,walkToZ);
System.out.println("String_Node_Str" + walkToX + "String_Node_Str"+ walkToY+ "String_Node_Str"+ walkToZ);
break;
}
}
}
break;
case WORKER:
if (rand.nextInt(270) == 0 && worldObj.getBlock((int)Math.floor(posX),(int)Math.floor(posY) + 1,(int)Math.floor(posZ)) != BlockList.ender_goo) {
for (int attempt=0, tpX, tpY, tpZ; attempt < 50; attempt++) {
tpX=(int)posX + rand.nextInt(70) - 35;
tpZ=(int)posZ + rand.nextInt(70) - 35;
tpY=worldObj.getTopSolidOrLiquidBlock(tpX,tpZ) - 1;
if (worldObj.getBlock(tpX,tpY,tpZ) == BlockList.ender_goo) {
teleportTo(tpX + 0.5D + (rand.nextDouble() - 0.5D) * 0.3D,tpY + 1D,tpZ + 0.5D + (rand.nextDouble() - 0.5D) * 0.3D,true);
System.out.println("String_Node_Str" + tpX + "String_Node_Str"+ tpY+ "String_Node_Str"+ tpZ);
break;
}
}
}
break;
case COLLECTOR:
if (rand.nextInt(50) == 0 && (!isCarrying() || rand.nextInt(4) == 0)) {
currentTask=EndermanTask.WAIT;
currentTaskTimer=150 + rand.nextInt(600 + rand.nextInt(1800));
setCarrying(null);
teleportTo(posX,10000D,posZ,true);
System.out.println("String_Node_Str");
}
break;
case OVERWORLD_EXPLORER:
if (rand.nextInt(200) == 0) {
currentTask=EndermanTask.WAIT;
currentTaskTimer=500 + rand.nextInt(800) + rand.nextInt(1000) * (1 + rand.nextInt(4));
List<EntityMobHomelandEnderman> explorers=HomelandEndermen.getByHomelandRole(this,HomelandRole.OVERWORLD_EXPLORER);
for (int a=0; a < 1 + rand.nextInt(7) && !explorers.isEmpty(); a++) {
if (rand.nextInt(3) == 0) break;
EntityMobHomelandEnderman enderman=explorers.remove(rand.nextInt(explorers.size()));
if (enderman == this) continue;
enderman.currentTask=EndermanTask.WAIT;
enderman.currentTaskTimer=currentTaskTimer + rand.nextInt(500);
enderman.teleportTo(enderman.posX,10000D,enderman.posZ,true);
System.out.println("String_Node_Str");
}
teleportTo(posX,10000D,posZ,true);
System.out.println("String_Node_Str");
}
break;
default :
}
}
}
}
if (overtakeGroup != -1) {
if (overtakeGroup == groupId) {
if (currentTask == EndermanTask.NONE) {
switch (overtakeGroupRole) {
case TELEPORTER:
if (rand.nextInt(8) == 0) teleportRandomly(12D);
break;
case CHAOSMAKER:
if (isCarrying() && getCarrying().getItem() == Item.getItemFromBlock(Blocks.tnt)) {
if (rand.nextInt(50) == 0) {
for (int attempt=0, xx, yy, zz; attempt < 30; attempt++) {
xx=(int)Math.floor(posX) + rand.nextInt(6) - 3;
yy=(int)Math.floor(posY) + rand.nextInt(3) - 1;
zz=(int)Math.floor(posZ) + rand.nextInt(6) - 3;
if (worldObj.getBlock(xx,yy,zz) == BlockList.end_terrain && worldObj.isAirBlock(xx,yy + 1,zz)) {
worldObj.spawnEntityInWorld(new EntityTNTPrimed(worldObj,xx + 0.5D,yy + 1.5D,zz + 0.5D,this));
setCarrying(null);
break;
}
}
}
}
 else {
currentTask=EndermanTask.GET_TNT;
currentTaskTimer=30 + rand.nextInt(80);
setPosition(posX,10000D,posZ);
}
break;
case LEADER:
case FIGHTER:
if (!(entityToAttack instanceof EntityMobHomelandEnderman)) {
EntityMobHomelandEnderman target=null;
if (overtakeGroupRole == OvertakeGroupRole.LEADER || rand.nextInt(4) == 0) {
List<EntityMobHomelandEnderman> list=HomelandEndermen.getByHomelandRole(this,HomelandRole.ISLAND_LEADERS);
if (!list.isEmpty()) target=list.get(rand.nextInt(list.size()));
}
if (target == null) {
List<EntityMobHomelandEnderman> other=HomelandEndermen.getAll(this);
for (int attempt=0, size=other.size(); attempt < 10; attempt++) {
EntityMobHomelandEnderman potentialTarget=other.get(rand.nextInt(size));
if (potentialTarget == this || potentialTarget.isInSameGroup(this)) continue;
HomelandRole role=potentialTarget.homelandRole;
if (role == HomelandRole.GUARD && rand.nextInt(3) != 0) target=potentialTarget;
 else if (role != HomelandRole.WORKER || rand.nextInt(5) <= 1) target=potentialTarget;
break;
}
}
setAttackTarget(target);
}
break;
default :
}
}
if (!worldObj.getEntitiesWithinAABB(EntityTNTPrimed.class,boundingBox.expand(5D,3D,5D)).isEmpty()) teleportRandomly();
}
 else if (groupId != -1) {
if (rand.nextInt(3) == 0) setGroupMember(overtakeGroup,OvertakeGroupRole.getRandomMember(rand));
 else setGroupMember(-1,null);
}
}
if (entityToAttack != null) {
++attackTpTimer;
if (((attackTpTimer > 50 + rand.nextInt(30) && rand.nextInt(20) == 0) || attackTpTimer > 120) && entityToAttack.getDistanceSqToEntity(this) < 16D) {
teleportRandomly(16D);
attackTpTimer=-80;
}
 else if (entityToAttack.getDistanceSqToEntity(this) > 256D && attackTpTimer > 30 && teleportToEntity(entityToAttack)) {
attackTpTimer=-80;
}
}
 else {
attackTpTimer=-80;
if (currentTask == EndermanTask.NONE && entityToAttack == null && ++randomTpTimer > 50 + rand.nextInt(70)) {
if (rand.nextInt(18) == 0) {
for (int attempt=0; attempt < 5; attempt++) {
if (teleportRandomly(10D)) break;
}
}
randomTpTimer-=80 + rand.nextInt(40);
}
if (screamTimer > 0 && --screamTimer == 0 && isScreaming()) setScreaming(false);
}
}
isJumping=false;
if (entityToAttack != null) faceEntity(entityToAttack,100F,100F);
super.onLivingUpdate();
}