private EntityNPCInterface getNearbyNPC() { List list = this.entity.worldObj.getEntitiesWithinAABBExcludingEntity( this.entity, this.entity.boundingBox.expand( (double) this.entity.ai.walkingRange, this.entity.ai.walkingRange > 7 ? 7.0D : (double) this.entity.ai.walkingRange, (double) this.entity.ai.walkingRange), this.selector); Iterator ita = list.iterator(); while (ita.hasNext()) { EntityNPCInterface npc = (EntityNPCInterface) ita.next(); if (!npc.ai.stopAndInteract || npc.isAttacking() || !npc.isEntityAlive() || this.entity.faction.isAggressiveToNpc(npc)) { ita.remove(); } } if (list.isEmpty()) { return null; } else { return (EntityNPCInterface) list.get(this.entity.getRNG().nextInt(list.size())); } }