private function pop(ChunkManager $level, $x, $z, $chunkX, $chunkZ, Random $random)
{
$c = $level->getChunk($x, $z);
$oC = $level->getChunk($chunkX, $chunkZ);
if ($c == null or $oC == null or $c != null and !$c->isGenerated() or $oC != null and !$oC->isGenerated()) {
return;
}
$chunk = new Vector3($x << 4, 0, $z << 4);
$originChunk = new Vector3($chunkX << 4, 0, $chunkZ << 4);
if ($random->nextBoundedInt(15) != 0) {
return;
}
$numberOfCaves = $random->nextBoundedInt($random->nextBoundedInt($random->nextBoundedInt(40) + 1) + 1);
for ($caveCount = 0; $caveCount < $numberOfCaves; $caveCount++) {
$target = new Vector3($chunk->getX() + $random->nextBoundedInt(16), $random->nextBoundedInt($random->nextBoundedInt(120) + 8), $chunk->getZ() + $random->nextBoundedInt(16));
$numberOfSmallCaves = 1;
if ($random->nextBoundedInt(4) == 0) {
$this->generateLargeCaveBranch($level, $originChunk, $target, new Random($random->nextInt()));
$numberOfSmallCaves += $random->nextBoundedInt(4);
}
for ($count = 0; $count < $numberOfSmallCaves; $count++) {
$randomHorizontalAngle = $random->nextFloat() * pi() * 2;
$randomVerticalAngle = ($random->nextFloat() - 0.5) * 2 / 8;
$horizontalScale = $random->nextFloat() * 2 + $random->nextFloat();
if ($random->nextBoundedInt(10) == 0) {
$horizontalScale *= $random->nextFloat() * $random->nextFloat() * 3 + 1;
}
$this->generateCaveBranch($level, $originChunk, $target, $horizontalScale, 1, $randomHorizontalAngle, $randomVerticalAngle, 0, 0, new Random($random->nextInt()));
}
}
}