PHP: // We have $x, $z// Example:$x = $player->getX() >> 4; // take 'X' chunk coordinate$z = $player->getZ() >> 4; // take 'Z' chunk coordinate$radius = 15;for ($chunkX = -$radius; $chunkX <= $radius; $chunkX++){ for ($chunkZ = -$radius; $chunkZ <= $radius; $chunkZ++){ // if distance <= raduis than load chunk if (sqrt($chunkX*$chunkX + $chunkZ*$chunkZ) <= $radius) $level->loadChunk($chunkX + $x, $chunkZ + $z); }}
https://en.wikipedia.org/wiki/Euclidean_distance PHP: // We have $p - Player and $b - Block$distance = sqrt(($p->x - $b->x)*($p->x - $b->x) + ($p->y - $b->y)*($p->y - $b->y) + ($p->z -$b->z)*($p->z - $b->z));if ($distance <= 5) { // todo}
Ok thanks. Now I tried to knockback the player from $b ($b is a sign) How can I do it? I tried this: PHP: $direction = $player->getDirectionVector(); $x = $direction->getX(); $y = $direction->getY(); $z = $direction->getZ(); for ($i = 1; $i <= 10; $i++) { $player->knockBack($player, 0, $x, $z, -1); }