If you give the object that follows a reference to the object that it follows, you can use
if (followed.getWorld() != null) setLocation(followed.getX()+0, followed.getY()-30);
I gave it an offset of (0, -30) from where the followed object is location (which would be a little above the object), but you can make it whatever you want.