I tried to check if there is a special block in a radius of 7 blocks from a player. I placed a sign under the block. But it only works sometimes. What is wrong? PHP: foreach ($player->getLevel()->getTiles() as $b) {if($b instanceof Sign) {$distance = sqrt(($player->x - $b->x)*($player->x - $b->x) + ($player->y - $b->y)*($player->y - $b->y) + ($player->z -$b->z)*($player->z - $b->z));if ($distance < 7) {}
You can try PHP: foreach ($player->getLevel()->getTiles() as $b) { if($b instanceof Sign) { if($b->distanceSquared($player) < 49){ //do smth } }}
you can look here: https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/math/Vector3.php#L179