Fixing a level error
This commit is contained in:
parent
1f6416d02e
commit
b5fb3c21ae
1 changed files with 18 additions and 1 deletions
|
@ -23,6 +23,7 @@ use pocketmine\block\Block;
|
||||||
use pocketmine\level\ChunkManager;
|
use pocketmine\level\ChunkManager;
|
||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
|
use pocketmine\level\Level;
|
||||||
|
|
||||||
class MineshaftPopulator extends AmountPopulator {
|
class MineshaftPopulator extends AmountPopulator {
|
||||||
/** var int */
|
/** var int */
|
||||||
|
@ -86,7 +87,7 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
* @param Random $random
|
* @param Random $random
|
||||||
*/
|
*/
|
||||||
public function generateMineshaftPart(int $x, int $y, int $z, int $dir, Random $random) {
|
public function generateMineshaftPart(int $x, int $y, int $z, int $dir, Random $random) {
|
||||||
if ($this->maxPath -- < 1 || $y >= $this->level->getChunk(($x - ($x % 16)) / 16, ($z - ($z % 16)) / 16)->getHighestBlockAt($x % 16, $z % 16) - 10)
|
if ($this->maxPath -- < 1 || $y >= $this->getHighestBlockAt($x, $z) - 10)
|
||||||
return;
|
return;
|
||||||
$type = $random->nextBoundedInt(3);
|
$type = $random->nextBoundedInt(3);
|
||||||
$level = $this->level;
|
$level = $this->level;
|
||||||
|
@ -425,5 +426,21 @@ class MineshaftPopulator extends AmountPopulator {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the top block (y) on an x and z axes
|
||||||
|
* @param int $x
|
||||||
|
* @param int $z
|
||||||
|
*/
|
||||||
|
protected function getHighestWorkableBlock($x, $z) {
|
||||||
|
for($y = Level::Y_MAX - 1; $y > 0; -- $y) {
|
||||||
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
|
if ($b === Block::SAND) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ++$y;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
Loading…
Reference in a new issue