I have a big mistake that I could not be fixing. // Code $border = 500; $x = mt_rand(-$border, $border); $z = mt_rand(-$border, $border); $y = $this->getLevel()->getHighestBlockAt($x,$z); $vector = new Vector3($x, $y, $z); $this->getLevel()->loadChunk($x >> 4, $z >> 4); $player->teleport($vector); print_r([$x, $y, $z]); what happens here is that "y" returns -1. I tried loading the Chunk but it doesn't work.
You're taking the tallest block without loading the chunk PHP: $border = 500;$x = mt_rand(-$border, $border);$z = mt_rand(-$border, $border);$this->getLevel()->loadChunk($x >> 4, $z >> 4);$y = $this->getLevel()->getHighestBlockAt($x,$z);$vector = new Vector3($x, $y, $z);$player->teleport($vector);
I believe you are trying to load a chunk that has not yet been generated. https://github.com/pmmp/PocketMine-...c58b79fa/src/pocketmine/level/Level.php#L2332