forked from Ad5001/BetterGen
Make Generation max height depend on the actual maxheight, fix PHPstorm namespaces
This commit is contained in:
parent
8311298fbc
commit
38f9faecd8
15 changed files with 55 additions and 20 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
.idea/*
|
|
@ -15,6 +15,7 @@
|
||||||
namespace Ad5001\BetterGen\generator;
|
namespace Ad5001\BetterGen\generator;
|
||||||
|
|
||||||
use pocketmine\level\ChunkManager;
|
use pocketmine\level\ChunkManager;
|
||||||
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
use pocketmine\level\generator\biome\Biome;
|
use pocketmine\level\generator\biome\Biome;
|
||||||
use pocketmine\level\generator\Generator;
|
use pocketmine\level\generator\Generator;
|
||||||
|
@ -61,6 +62,7 @@ class BetterNormal extends Generator {
|
||||||
Block::STILL_WATER
|
Block::STILL_WATER
|
||||||
];
|
];
|
||||||
protected $selector;
|
protected $selector;
|
||||||
|
/** @var Level */
|
||||||
protected $level;
|
protected $level;
|
||||||
protected $random;
|
protected $random;
|
||||||
protected $populators = [ ];
|
protected $populators = [ ];
|
||||||
|
@ -434,7 +436,7 @@ class BetterNormal extends Generator {
|
||||||
* @param $z int
|
* @param $z int
|
||||||
*/
|
*/
|
||||||
protected function getHighestWorkableBlock($x, $z) {
|
protected function getHighestWorkableBlock($x, $z) {
|
||||||
for($y = 127; $y > 0; -- $y) {
|
for($y = Level::Y_MAX; $y > 0; -- $y) {
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
|
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\populator;
|
namespace Ad5001\BetterGen\populator;
|
||||||
|
|
||||||
|
use pocketmine\level\Level;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\level\ChunkManager;
|
use pocketmine\level\ChunkManager;
|
||||||
|
@ -22,6 +23,7 @@ use Ad5001\BetterGen\populator\AmountPopulator;
|
||||||
use Ad5001\BetterGen\structure\Bush;
|
use Ad5001\BetterGen\structure\Bush;
|
||||||
|
|
||||||
class BushPopulator extends AmountPopulator {
|
class BushPopulator extends AmountPopulator {
|
||||||
|
/** @var ChunkManager */
|
||||||
protected $level;
|
protected $level;
|
||||||
protected $type;
|
protected $type;
|
||||||
|
|
||||||
|
@ -62,7 +64,7 @@ class BushPopulator extends AmountPopulator {
|
||||||
* @param $z int
|
* @param $z int
|
||||||
*/
|
*/
|
||||||
protected function getHighestWorkableBlock($x, $z) {
|
protected function getHighestWorkableBlock($x, $z) {
|
||||||
for($y = 127; $y > 0; -- $y) {
|
for($y = Level::Y_MAX; $y > 0; -- $y) {
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
|
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -17,11 +17,13 @@ namespace Ad5001\BetterGen\populator;
|
||||||
|
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\level\ChunkManager;
|
use pocketmine\level\ChunkManager;
|
||||||
|
use pocketmine\level\Level;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
use Ad5001\BetterGen\structure\Cactus;
|
use Ad5001\BetterGen\structure\Cactus;
|
||||||
use Ad5001\BetterGen\populator\AmountPopulator;
|
use Ad5001\BetterGen\populator\AmountPopulator;
|
||||||
|
|
||||||
class CactusPopulator extends AmountPopulator {
|
class CactusPopulator extends AmountPopulator {
|
||||||
|
/** @var ChunkManager */
|
||||||
protected $level;
|
protected $level;
|
||||||
/*
|
/*
|
||||||
* Constructs the class
|
* Constructs the class
|
||||||
|
@ -58,7 +60,7 @@ class CactusPopulator extends AmountPopulator {
|
||||||
* @param $z int
|
* @param $z int
|
||||||
*/
|
*/
|
||||||
protected function getHighestWorkableBlock($x, $z) {
|
protected function getHighestWorkableBlock($x, $z) {
|
||||||
for($y = 127; $y >= 0; -- $y) {
|
for($y = Level::Y_MAX; $y >= 0; -- $y) {
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) {
|
if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\populator;
|
namespace Ad5001\BetterGen\populator;
|
||||||
|
|
||||||
|
use pocketmine\level\Level;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\level\ChunkManager;
|
use pocketmine\level\ChunkManager;
|
||||||
|
@ -22,6 +23,7 @@ use Ad5001\BetterGen\utils\BuildingUtils;
|
||||||
use Ad5001\BetterGen\populator\AmountPopulator;
|
use Ad5001\BetterGen\populator\AmountPopulator;
|
||||||
|
|
||||||
class CavePopulator extends AmountPopulator {
|
class CavePopulator extends AmountPopulator {
|
||||||
|
/** @var ChunkManager */
|
||||||
protected $level;
|
protected $level;
|
||||||
const STOP = false;
|
const STOP = false;
|
||||||
const CONTINUE = true;
|
const CONTINUE = true;
|
||||||
|
@ -65,7 +67,7 @@ class CavePopulator extends AmountPopulator {
|
||||||
* @param $z int
|
* @param $z int
|
||||||
*/
|
*/
|
||||||
protected function getHighestWorkableBlock($x, $z) {
|
protected function getHighestWorkableBlock($x, $z) {
|
||||||
for($y = 127; $y > 0; -- $y) {
|
for($y = Level::Y_MAX; $y > 0; -- $y) {
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL or $b === Block::SAND or $b === Block::SNOW_BLOCK or $b === Block::SANDSTONE) {
|
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL or $b === Block::SAND or $b === Block::SNOW_BLOCK or $b === Block::SANDSTONE) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -16,10 +16,12 @@ namespace Ad5001\BetterGen\populator;
|
||||||
|
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\level\ChunkManager;
|
use pocketmine\level\ChunkManager;
|
||||||
|
use pocketmine\level\Level;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
use Ad5001\BetterGen\populator\AmountPopulator;
|
use Ad5001\BetterGen\populator\AmountPopulator;
|
||||||
|
|
||||||
class DeadbushPopulator extends AmountPopulator {
|
class DeadbushPopulator extends AmountPopulator {
|
||||||
|
/** @var ChunkManager */
|
||||||
protected $level;
|
protected $level;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -49,7 +51,7 @@ class DeadbushPopulator extends AmountPopulator {
|
||||||
* @param $z int
|
* @param $z int
|
||||||
*/
|
*/
|
||||||
protected function getHighestWorkableBlock($x, $z) {
|
protected function getHighestWorkableBlock($x, $z) {
|
||||||
for($y = 127; $y >= 0; -- $y) {
|
for($y = Level::Y_MAX; $y >= 0; -- $y) {
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) {
|
if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -16,12 +16,14 @@ namespace Ad5001\BetterGen\populator;
|
||||||
|
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\level\ChunkManager;
|
use pocketmine\level\ChunkManager;
|
||||||
|
use pocketmine\level\Level;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
use Ad5001\BetterGen\structure\FallenTree;
|
use Ad5001\BetterGen\structure\FallenTree;
|
||||||
use Ad5001\BetterGen\populator\AmountPopulator;
|
use Ad5001\BetterGen\populator\AmountPopulator;
|
||||||
|
|
||||||
|
|
||||||
class FallenTreePopulator extends AmountPopulator {
|
class FallenTreePopulator extends AmountPopulator {
|
||||||
|
/** @var ChunkManager */
|
||||||
protected $level;
|
protected $level;
|
||||||
protected $type;
|
protected $type;
|
||||||
/*
|
/*
|
||||||
|
@ -51,7 +53,7 @@ class FallenTreePopulator extends AmountPopulator {
|
||||||
$z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15);
|
$z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15);
|
||||||
$y = $this->getHighestWorkableBlock($x, $z);
|
$y = $this->getHighestWorkableBlock($x, $z);
|
||||||
if ($y !== -1 and $fallenTree->canPlaceObject($level, $x, $y + 1, $z, $random )) {
|
if ($y !== -1 and $fallenTree->canPlaceObject($level, $x, $y + 1, $z, $random )) {
|
||||||
$fallenTree->placeObject($level, $x, $y + 1, $z, $random);
|
$fallenTree->placeObject($level, $x, $y + 1, $z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +64,7 @@ class FallenTreePopulator extends AmountPopulator {
|
||||||
* @param $z int
|
* @param $z int
|
||||||
*/
|
*/
|
||||||
protected function getHighestWorkableBlock($x, $z) {
|
protected function getHighestWorkableBlock($x, $z) {
|
||||||
for($y = 127; $y >= 0; -- $y) {
|
for($y = Level::Y_MAX; $y >= 0; -- $y) {
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) {
|
if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
namespace Ad5001\BetterGen\populator;
|
namespace Ad5001\BetterGen\populator;
|
||||||
|
|
||||||
use pocketmine\level\ChunkManager;
|
use pocketmine\level\ChunkManager;
|
||||||
|
use pocketmine\level\format\Chunk;
|
||||||
|
use pocketmine\level\Level;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
use Ad5001\BetterGen\generator\BetterNormal;
|
use Ad5001\BetterGen\generator\BetterNormal;
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
|
@ -39,6 +41,9 @@ class FloatingIslandPopulator extends AmountPopulator {
|
||||||
* @param $chunkZ int
|
* @param $chunkZ int
|
||||||
* @param $random pocketmine\utils\Random
|
* @param $random pocketmine\utils\Random
|
||||||
*/
|
*/
|
||||||
|
/** @var ChunkManager */
|
||||||
|
private $level;
|
||||||
|
|
||||||
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
|
||||||
$this->level = $level;
|
$this->level = $level;
|
||||||
if($this->getAmount($random) > 130) {
|
if($this->getAmount($random) > 130) {
|
||||||
|
@ -49,7 +54,7 @@ class FloatingIslandPopulator extends AmountPopulator {
|
||||||
$height = $this->buildIslandBottomShape($level, new Vector3($x, $y, $z), $radius, $random);
|
$height = $this->buildIslandBottomShape($level, new Vector3($x, $y, $z), $radius, $random);
|
||||||
$this->populateOres($level, new Vector3($x, $y - 1, $z), $radius * 2, $height, $random);
|
$this->populateOres($level, new Vector3($x, $y - 1, $z), $radius * 2, $height, $random);
|
||||||
$chunk = $level->getChunk($chunkX, $chunkZ);
|
$chunk = $level->getChunk($chunkX, $chunkZ);
|
||||||
$biome = BetterNormal::getBiomeById($chunk->getBiomeId($x % 16, $z % 16));
|
$biome = BetterNormal::getBiomeById($chunk->getBiomeId($x % 16, $z % 16));//static call
|
||||||
$populators = $biome->getPopulators();
|
$populators = $biome->getPopulators();
|
||||||
foreach($populators as $populator) {
|
foreach($populators as $populator) {
|
||||||
$populator->populate($level, $chunkX, $chunkZ, $random);
|
$populator->populate($level, $chunkX, $chunkZ, $random);
|
||||||
|
@ -65,7 +70,7 @@ class FloatingIslandPopulator extends AmountPopulator {
|
||||||
* @param $z int
|
* @param $z int
|
||||||
*/
|
*/
|
||||||
protected function getHighestWorkableBlock($x, $z) {
|
protected function getHighestWorkableBlock($x, $z) {
|
||||||
for($y = 127; $y > 0; -- $y) {
|
for($y = Level::Y_MAX; $y > 0; -- $y) {
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL or $b === Block::SAND) {
|
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL or $b === Block::SAND) {
|
||||||
break;
|
break;
|
||||||
|
@ -90,7 +95,7 @@ class FloatingIslandPopulator extends AmountPopulator {
|
||||||
public function buildIslandBottomShape(ChunkManager $level, Vector3 $pos, int $radius, Random $random) {
|
public function buildIslandBottomShape(ChunkManager $level, Vector3 $pos, int $radius, Random $random) {
|
||||||
$pos = $pos->round();
|
$pos = $pos->round();
|
||||||
$xx = $pos->x;
|
$xx = $pos->x;
|
||||||
$zz = $z;
|
$zz = $z; //undefined
|
||||||
$currentLen = 1;
|
$currentLen = 1;
|
||||||
$isEdge = false;
|
$isEdge = false;
|
||||||
$hBound = 0;
|
$hBound = 0;
|
||||||
|
@ -105,7 +110,7 @@ class FloatingIslandPopulator extends AmountPopulator {
|
||||||
}
|
}
|
||||||
if(abs(abs($x - $pos->x) ** 2) + abs(abs($z - $pos->z) ** 2) <= ($radius ** 2) * 0.67 && $y < 128) {
|
if(abs(abs($x - $pos->x) ** 2) + abs(abs($z - $pos->z) ** 2) <= ($radius ** 2) * 0.67 && $y < 128) {
|
||||||
if($chunk = $level->getChunk($x >> 4, $z >> 4)) {
|
if($chunk = $level->getChunk($x >> 4, $z >> 4)) {
|
||||||
$biome = BetterNormal::getBiomeById($chunk->getBiomeId($x % 16, $z % 16));
|
$biome = BetterNormal::getBiomeById($chunk->getBiomeId($x % 16, $z % 16));//static call
|
||||||
$block = $biome->getGroundCover()[$pos->y - $y - 1] ?? Block::get(Block::STONE);
|
$block = $biome->getGroundCover()[$pos->y - $y - 1] ?? Block::get(Block::STONE);
|
||||||
$block = $block->getId();
|
$block = $block->getId();
|
||||||
} elseif($random->nextBoundedInt(5) == 0 && $isEdge) {
|
} elseif($random->nextBoundedInt(5) == 0 && $isEdge) {
|
||||||
|
@ -160,6 +165,6 @@ class FloatingIslandPopulator extends AmountPopulator {
|
||||||
new OreType(new GoldOre (), 2, 8, $pos->y - $height, $pos->y - round($height / 2)),
|
new OreType(new GoldOre (), 2, 8, $pos->y - $height, $pos->y - round($height / 2)),
|
||||||
new OreType(new DiamondOre (), 1, 7, $pos->y - $height, $pos->y - round($height / 4))
|
new OreType(new DiamondOre (), 1, 7, $pos->y - $height, $pos->y - round($height / 4))
|
||||||
]);
|
]);
|
||||||
$ores->populate($level, $x >> 4, $z >> 4, $random);
|
$ores->populate($level, $x >> 4, $z >> 4, $random);//x z undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\populator;
|
namespace Ad5001\BetterGen\populator;
|
||||||
|
|
||||||
|
use pocketmine\level\Level;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\level\ChunkManager;
|
use pocketmine\level\ChunkManager;
|
||||||
|
@ -21,6 +22,7 @@ use Ad5001\BetterGen\populator\AmountPopulator;
|
||||||
use Ad5001\BetterGen\structure\Igloo;
|
use Ad5001\BetterGen\structure\Igloo;
|
||||||
|
|
||||||
class IglooPopulator extends AmountPopulator {
|
class IglooPopulator extends AmountPopulator {
|
||||||
|
/** @var ChunkManager */
|
||||||
protected $level;
|
protected $level;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -48,7 +50,7 @@ class IglooPopulator extends AmountPopulator {
|
||||||
* @param $z int
|
* @param $z int
|
||||||
*/
|
*/
|
||||||
protected function getHighestWorkableBlock($x, $z) {
|
protected function getHighestWorkableBlock($x, $z) {
|
||||||
for($y = 127; $y > 0; -- $y) {
|
for($y = Level::Y_MAX; $y > 0; -- $y) {
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
|
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\populator;
|
namespace Ad5001\BetterGen\populator;
|
||||||
|
|
||||||
|
use pocketmine\level\Level;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\level\ChunkManager;
|
use pocketmine\level\ChunkManager;
|
||||||
|
@ -22,6 +23,7 @@ use Ad5001\BetterGen\utils\BuildingUtils;
|
||||||
use Ad5001\BetterGen\populator\AmountPopulator;
|
use Ad5001\BetterGen\populator\AmountPopulator;
|
||||||
|
|
||||||
class LakePopulator extends AmountPopulator {
|
class LakePopulator extends AmountPopulator {
|
||||||
|
/** @var ChunkManager */
|
||||||
protected $level;
|
protected $level;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -57,7 +59,7 @@ class LakePopulator extends AmountPopulator {
|
||||||
* @param $z int
|
* @param $z int
|
||||||
*/
|
*/
|
||||||
protected function getHighestWorkableBlock($x, $z) {
|
protected function getHighestWorkableBlock($x, $z) {
|
||||||
for($y = 127; $y > 0; -- $y) {
|
for($y = Level::Y_MAX; $y > 0; -- $y) {
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
|
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\populator;
|
namespace Ad5001\BetterGen\populator;
|
||||||
|
|
||||||
|
use pocketmine\level\Level;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\level\ChunkManager;
|
use pocketmine\level\ChunkManager;
|
||||||
|
@ -21,6 +22,7 @@ use Ad5001\BetterGen\populator\AmountPopulator;
|
||||||
use Ad5001\BetterGen\utils\BuildingUtils;
|
use Ad5001\BetterGen\utils\BuildingUtils;
|
||||||
|
|
||||||
class RavinePopulator extends AmountPopulator {
|
class RavinePopulator extends AmountPopulator {
|
||||||
|
/** @var ChunkManager */
|
||||||
protected $level;
|
protected $level;
|
||||||
const NOISE = 250;
|
const NOISE = 250;
|
||||||
|
|
||||||
|
@ -74,7 +76,7 @@ class RavinePopulator extends AmountPopulator {
|
||||||
* @param $z int
|
* @param $z int
|
||||||
*/
|
*/
|
||||||
protected function getHighestWorkableBlock($x, $z) {
|
protected function getHighestWorkableBlock($x, $z) {
|
||||||
for($y = 127; $y > 0; -- $y) {
|
for($y = Level::Y_MAX; $y > 0; -- $y) {
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL or $b === Block::SAND or $b === Block::SNOW_BLOCK or $b === Block::SANDSTONE) {
|
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL or $b === Block::SAND or $b === Block::SNOW_BLOCK or $b === Block::SANDSTONE) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -16,11 +16,13 @@ namespace Ad5001\BetterGen\populator;
|
||||||
|
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\level\ChunkManager;
|
use pocketmine\level\ChunkManager;
|
||||||
|
use pocketmine\level\Level;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
use Ad5001\BetterGen\structure\SugarCane;
|
use Ad5001\BetterGen\structure\SugarCane;
|
||||||
use Ad5001\BetterGen\populator\AmountPopulator;
|
use Ad5001\BetterGen\populator\AmountPopulator;
|
||||||
|
|
||||||
class SugarCanePopulator extends AmountPopulator {
|
class SugarCanePopulator extends AmountPopulator {
|
||||||
|
/** @var ChunkManager */
|
||||||
protected $level;
|
protected $level;
|
||||||
/*
|
/*
|
||||||
* Constructs the class
|
* Constructs the class
|
||||||
|
@ -57,7 +59,7 @@ class SugarCanePopulator extends AmountPopulator {
|
||||||
* @param $z int
|
* @param $z int
|
||||||
*/
|
*/
|
||||||
protected function getHighestWorkableBlock($x, $z) {
|
protected function getHighestWorkableBlock($x, $z) {
|
||||||
for($y = 127; $y >= 0; -- $y) {
|
for($y = Level::Y_MAX; $y >= 0; -- $y) {
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) {
|
if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\populator;
|
namespace Ad5001\BetterGen\populator;
|
||||||
|
|
||||||
|
use pocketmine\level\Level;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\level\ChunkManager;
|
use pocketmine\level\ChunkManager;
|
||||||
|
@ -21,6 +22,7 @@ use Ad5001\BetterGen\structure\Temple;
|
||||||
use Ad5001\BetterGen\populator\AmountPopulator;
|
use Ad5001\BetterGen\populator\AmountPopulator;
|
||||||
|
|
||||||
class TemplePopulator extends AmountPopulator {
|
class TemplePopulator extends AmountPopulator {
|
||||||
|
/** @var Level */
|
||||||
protected $level;
|
protected $level;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -48,7 +50,7 @@ class TemplePopulator extends AmountPopulator {
|
||||||
* @param $z int
|
* @param $z int
|
||||||
*/
|
*/
|
||||||
protected function getHighestWorkableBlock($x, $z) {
|
protected function getHighestWorkableBlock($x, $z) {
|
||||||
for($y = 127; $y > 0; -- $y) {
|
for($y = Level::Y_MAX; $y > 0; -- $y) {
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
if ($b === Block::SAND) {
|
if ($b === Block::SAND) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\populator;
|
namespace Ad5001\BetterGen\populator;
|
||||||
|
|
||||||
|
use pocketmine\level\generator\object\Tree;
|
||||||
|
use pocketmine\level\Level;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\level\ChunkManager;
|
use pocketmine\level\ChunkManager;
|
||||||
|
@ -23,11 +25,13 @@ use Ad5001\BetterGen\Main;
|
||||||
|
|
||||||
|
|
||||||
class TreePopulator extends AmountPopulator {
|
class TreePopulator extends AmountPopulator {
|
||||||
|
/** @var Tree[] */
|
||||||
static $types = [
|
static $types = [
|
||||||
"pocketmine\\level\\generator\\object\\OakTree",
|
"pocketmine\\level\\generator\\object\\OakTree",
|
||||||
"pocketmine\\level\\generator\\object\\BirchTree",
|
"pocketmine\\level\\generator\\object\\BirchTree",
|
||||||
"Ad5001\\BetterGen\\structure\\SakuraTree"
|
"Ad5001\\BetterGen\\structure\\SakuraTree"
|
||||||
];
|
];
|
||||||
|
/** @var ChunkManager */
|
||||||
protected $level;
|
protected $level;
|
||||||
protected $type;
|
protected $type;
|
||||||
|
|
||||||
|
@ -63,7 +67,8 @@ class TreePopulator extends AmountPopulator {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$treeC = self::$types [$this->type];
|
$treeC = self::$types [$this->type];
|
||||||
$tree = new $treeC();
|
/** @var Tree $tree */
|
||||||
|
$tree = new $treeC();
|
||||||
$tree->placeObject($level, $x, $y, $z, $random);
|
$tree->placeObject($level, $x, $y, $z, $random);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,7 +79,7 @@ class TreePopulator extends AmountPopulator {
|
||||||
* @param $z int
|
* @param $z int
|
||||||
*/
|
*/
|
||||||
protected function getHighestWorkableBlock($x, $z) {
|
protected function getHighestWorkableBlock($x, $z) {
|
||||||
for($y = 127; $y > 0; -- $y) {
|
for($y = Level::Y_MAX; $y > 0; -- $y) {
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
|
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
namespace Ad5001\BetterGen\populator;
|
namespace Ad5001\BetterGen\populator;
|
||||||
|
|
||||||
|
use pocketmine\level\Level;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\level\ChunkManager;
|
use pocketmine\level\ChunkManager;
|
||||||
|
@ -21,6 +22,7 @@ use Ad5001\BetterGen\structure\Well;
|
||||||
use Ad5001\BetterGen\populator\AmountPopulator;
|
use Ad5001\BetterGen\populator\AmountPopulator;
|
||||||
|
|
||||||
class WellPopulator extends AmountPopulator {
|
class WellPopulator extends AmountPopulator {
|
||||||
|
/** @var ChunkManager */
|
||||||
protected $level;
|
protected $level;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -48,7 +50,7 @@ class WellPopulator extends AmountPopulator {
|
||||||
* @param $z int
|
* @param $z int
|
||||||
*/
|
*/
|
||||||
protected function getHighestWorkableBlock($x, $z) {
|
protected function getHighestWorkableBlock($x, $z) {
|
||||||
for($y = 127; $y > 0; -- $y) {
|
for($y = Level::Y_MAX; $y > 0; -- $y) {
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
if ($b === Block::SAND) {
|
if ($b === Block::SAND) {
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue