I am making a plugin that needs to detect if an entity is a certain distance (0.1 blocks away, practically up against) from a player. Also this includes if it is near the players head or the players feet, because I don't think that the players coordinates/position refers to the whole body, just the feet/block that they are standing on. Also, I need to detect if a specified entity is in or a block, because if it is I need to get rid of it. Thanks for any help.
So do you want to calculate the exact distance or just run a function on close proximity between two players?
Hmm...I'm not sure how to do that most efficiently. You could loop through players and check if a->z == b->z and a->x is within 0.1 of b->x and then check if a->y is within 0.1 of b->z. Oh and you need to check a->level == b->level. Coordinates are part of the entity object so you access them via $player->entity->[x/y/z/level]. Life would be so much easier if PocketMine had a built in distance function to calculate the distance between two entities.
Jr wants to find the closest player. If you simply want to compare distance, using distanceSquared is faster.