diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bc8a670 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/* \ No newline at end of file diff --git a/src/Ad5001/BetterGen/generator/BetterNormal.php b/src/Ad5001/BetterGen/generator/BetterNormal.php index cc33850..5a59a19 100644 --- a/src/Ad5001/BetterGen/generator/BetterNormal.php +++ b/src/Ad5001/BetterGen/generator/BetterNormal.php @@ -15,6 +15,7 @@ namespace Ad5001\BetterGen\generator; use pocketmine\level\ChunkManager; +use pocketmine\math\Vector3; use pocketmine\utils\Random; use pocketmine\level\generator\biome\Biome; use pocketmine\level\generator\Generator; @@ -61,6 +62,7 @@ class BetterNormal extends Generator { Block::STILL_WATER ]; protected $selector; + /** @var Level */ protected $level; protected $random; protected $populators = [ ]; @@ -434,7 +436,7 @@ class BetterNormal extends Generator { * @param $z int */ 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); if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) { break; diff --git a/src/Ad5001/BetterGen/populator/BushPopulator.php b/src/Ad5001/BetterGen/populator/BushPopulator.php index 71b1bdc..3d80926 100644 --- a/src/Ad5001/BetterGen/populator/BushPopulator.php +++ b/src/Ad5001/BetterGen/populator/BushPopulator.php @@ -14,6 +14,7 @@ namespace Ad5001\BetterGen\populator; +use pocketmine\level\Level; use pocketmine\utils\Random; use pocketmine\block\Block; use pocketmine\level\ChunkManager; @@ -22,6 +23,7 @@ use Ad5001\BetterGen\populator\AmountPopulator; use Ad5001\BetterGen\structure\Bush; class BushPopulator extends AmountPopulator { + /** @var ChunkManager */ protected $level; protected $type; @@ -62,7 +64,7 @@ class BushPopulator extends AmountPopulator { * @param $z int */ 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); if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) { break; diff --git a/src/Ad5001/BetterGen/populator/CactusPopulator.php b/src/Ad5001/BetterGen/populator/CactusPopulator.php index 2edba48..f9345a2 100644 --- a/src/Ad5001/BetterGen/populator/CactusPopulator.php +++ b/src/Ad5001/BetterGen/populator/CactusPopulator.php @@ -17,11 +17,13 @@ namespace Ad5001\BetterGen\populator; use pocketmine\block\Block; use pocketmine\level\ChunkManager; +use pocketmine\level\Level; use pocketmine\utils\Random; use Ad5001\BetterGen\structure\Cactus; use Ad5001\BetterGen\populator\AmountPopulator; class CactusPopulator extends AmountPopulator { + /** @var ChunkManager */ protected $level; /* * Constructs the class @@ -58,7 +60,7 @@ class CactusPopulator extends AmountPopulator { * @param $z int */ 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); if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) { break; diff --git a/src/Ad5001/BetterGen/populator/CavePopulator.php b/src/Ad5001/BetterGen/populator/CavePopulator.php index 76510b8..943d0b4 100644 --- a/src/Ad5001/BetterGen/populator/CavePopulator.php +++ b/src/Ad5001/BetterGen/populator/CavePopulator.php @@ -14,6 +14,7 @@ namespace Ad5001\BetterGen\populator; +use pocketmine\level\Level; use pocketmine\utils\Random; use pocketmine\block\Block; use pocketmine\level\ChunkManager; @@ -22,6 +23,7 @@ use Ad5001\BetterGen\utils\BuildingUtils; use Ad5001\BetterGen\populator\AmountPopulator; class CavePopulator extends AmountPopulator { + /** @var ChunkManager */ protected $level; const STOP = false; const CONTINUE = true; @@ -65,7 +67,7 @@ class CavePopulator extends AmountPopulator { * @param $z int */ 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); 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; diff --git a/src/Ad5001/BetterGen/populator/DeadbushPopulator.php b/src/Ad5001/BetterGen/populator/DeadbushPopulator.php index fbadc13..392f66a 100644 --- a/src/Ad5001/BetterGen/populator/DeadbushPopulator.php +++ b/src/Ad5001/BetterGen/populator/DeadbushPopulator.php @@ -16,10 +16,12 @@ namespace Ad5001\BetterGen\populator; use pocketmine\block\Block; use pocketmine\level\ChunkManager; +use pocketmine\level\Level; use pocketmine\utils\Random; use Ad5001\BetterGen\populator\AmountPopulator; class DeadbushPopulator extends AmountPopulator { + /** @var ChunkManager */ protected $level; /* @@ -49,7 +51,7 @@ class DeadbushPopulator extends AmountPopulator { * @param $z int */ 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); if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) { break; diff --git a/src/Ad5001/BetterGen/populator/FallenTreePopulator.php b/src/Ad5001/BetterGen/populator/FallenTreePopulator.php index 0910ccc..890dc6f 100644 --- a/src/Ad5001/BetterGen/populator/FallenTreePopulator.php +++ b/src/Ad5001/BetterGen/populator/FallenTreePopulator.php @@ -16,12 +16,14 @@ namespace Ad5001\BetterGen\populator; use pocketmine\block\Block; use pocketmine\level\ChunkManager; +use pocketmine\level\Level; use pocketmine\utils\Random; use Ad5001\BetterGen\structure\FallenTree; use Ad5001\BetterGen\populator\AmountPopulator; class FallenTreePopulator extends AmountPopulator { + /** @var ChunkManager */ protected $level; protected $type; /* @@ -51,7 +53,7 @@ class FallenTreePopulator extends AmountPopulator { $z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15); $y = $this->getHighestWorkableBlock($x, $z); 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 */ 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); if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) { break; diff --git a/src/Ad5001/BetterGen/populator/FloatingIslandPopulator.php b/src/Ad5001/BetterGen/populator/FloatingIslandPopulator.php index 41c78e4..c58f251 100644 --- a/src/Ad5001/BetterGen/populator/FloatingIslandPopulator.php +++ b/src/Ad5001/BetterGen/populator/FloatingIslandPopulator.php @@ -15,6 +15,8 @@ namespace Ad5001\BetterGen\populator; use pocketmine\level\ChunkManager; +use pocketmine\level\format\Chunk; +use pocketmine\level\Level; use pocketmine\utils\Random; use Ad5001\BetterGen\generator\BetterNormal; use pocketmine\block\Block; @@ -39,6 +41,9 @@ class FloatingIslandPopulator extends AmountPopulator { * @param $chunkZ int * @param $random pocketmine\utils\Random */ + /** @var ChunkManager */ + private $level; + public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) { $this->level = $level; if($this->getAmount($random) > 130) { @@ -49,7 +54,7 @@ class FloatingIslandPopulator extends AmountPopulator { $height = $this->buildIslandBottomShape($level, new Vector3($x, $y, $z), $radius, $random); $this->populateOres($level, new Vector3($x, $y - 1, $z), $radius * 2, $height, $random); $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(); foreach($populators as $populator) { $populator->populate($level, $chunkX, $chunkZ, $random); @@ -65,7 +70,7 @@ class FloatingIslandPopulator extends AmountPopulator { * @param $z int */ 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); if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL or $b === Block::SAND) { break; @@ -90,7 +95,7 @@ class FloatingIslandPopulator extends AmountPopulator { public function buildIslandBottomShape(ChunkManager $level, Vector3 $pos, int $radius, Random $random) { $pos = $pos->round(); $xx = $pos->x; - $zz = $z; + $zz = $z; //undefined $currentLen = 1; $isEdge = false; $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($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 = $block->getId(); } 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 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 } } \ No newline at end of file diff --git a/src/Ad5001/BetterGen/populator/IglooPopulator.php b/src/Ad5001/BetterGen/populator/IglooPopulator.php index 9367056..292669c 100644 --- a/src/Ad5001/BetterGen/populator/IglooPopulator.php +++ b/src/Ad5001/BetterGen/populator/IglooPopulator.php @@ -14,6 +14,7 @@ namespace Ad5001\BetterGen\populator; +use pocketmine\level\Level; use pocketmine\utils\Random; use pocketmine\block\Block; use pocketmine\level\ChunkManager; @@ -21,6 +22,7 @@ use Ad5001\BetterGen\populator\AmountPopulator; use Ad5001\BetterGen\structure\Igloo; class IglooPopulator extends AmountPopulator { + /** @var ChunkManager */ protected $level; /* @@ -48,7 +50,7 @@ class IglooPopulator extends AmountPopulator { * @param $z int */ 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); if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) { break; diff --git a/src/Ad5001/BetterGen/populator/LakePopulator.php b/src/Ad5001/BetterGen/populator/LakePopulator.php index 5677da7..7957cc0 100644 --- a/src/Ad5001/BetterGen/populator/LakePopulator.php +++ b/src/Ad5001/BetterGen/populator/LakePopulator.php @@ -14,6 +14,7 @@ namespace Ad5001\BetterGen\populator; +use pocketmine\level\Level; use pocketmine\utils\Random; use pocketmine\block\Block; use pocketmine\level\ChunkManager; @@ -22,6 +23,7 @@ use Ad5001\BetterGen\utils\BuildingUtils; use Ad5001\BetterGen\populator\AmountPopulator; class LakePopulator extends AmountPopulator { + /** @var ChunkManager */ protected $level; /* @@ -57,7 +59,7 @@ class LakePopulator extends AmountPopulator { * @param $z int */ 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); if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) { break; diff --git a/src/Ad5001/BetterGen/populator/RavinePopulator.php b/src/Ad5001/BetterGen/populator/RavinePopulator.php index a689271..a15f32c 100644 --- a/src/Ad5001/BetterGen/populator/RavinePopulator.php +++ b/src/Ad5001/BetterGen/populator/RavinePopulator.php @@ -14,6 +14,7 @@ namespace Ad5001\BetterGen\populator; +use pocketmine\level\Level; use pocketmine\utils\Random; use pocketmine\block\Block; use pocketmine\level\ChunkManager; @@ -21,6 +22,7 @@ use Ad5001\BetterGen\populator\AmountPopulator; use Ad5001\BetterGen\utils\BuildingUtils; class RavinePopulator extends AmountPopulator { + /** @var ChunkManager */ protected $level; const NOISE = 250; @@ -74,7 +76,7 @@ class RavinePopulator extends AmountPopulator { * @param $z int */ 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); 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; diff --git a/src/Ad5001/BetterGen/populator/SugarCanePopulator.php b/src/Ad5001/BetterGen/populator/SugarCanePopulator.php index fb94ef5..4fde840 100644 --- a/src/Ad5001/BetterGen/populator/SugarCanePopulator.php +++ b/src/Ad5001/BetterGen/populator/SugarCanePopulator.php @@ -16,11 +16,13 @@ namespace Ad5001\BetterGen\populator; use pocketmine\block\Block; use pocketmine\level\ChunkManager; +use pocketmine\level\Level; use pocketmine\utils\Random; use Ad5001\BetterGen\structure\SugarCane; use Ad5001\BetterGen\populator\AmountPopulator; class SugarCanePopulator extends AmountPopulator { + /** @var ChunkManager */ protected $level; /* * Constructs the class @@ -57,7 +59,7 @@ class SugarCanePopulator extends AmountPopulator { * @param $z int */ 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); if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) { break; diff --git a/src/Ad5001/BetterGen/populator/TemplePopulator.php b/src/Ad5001/BetterGen/populator/TemplePopulator.php index 084688f..d957405 100644 --- a/src/Ad5001/BetterGen/populator/TemplePopulator.php +++ b/src/Ad5001/BetterGen/populator/TemplePopulator.php @@ -14,6 +14,7 @@ namespace Ad5001\BetterGen\populator; +use pocketmine\level\Level; use pocketmine\utils\Random; use pocketmine\block\Block; use pocketmine\level\ChunkManager; @@ -21,6 +22,7 @@ use Ad5001\BetterGen\structure\Temple; use Ad5001\BetterGen\populator\AmountPopulator; class TemplePopulator extends AmountPopulator { + /** @var Level */ protected $level; /* @@ -48,7 +50,7 @@ class TemplePopulator extends AmountPopulator { * @param $z int */ 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); if ($b === Block::SAND) { break; diff --git a/src/Ad5001/BetterGen/populator/TreePopulator.php b/src/Ad5001/BetterGen/populator/TreePopulator.php index 1e03293..d01952d 100644 --- a/src/Ad5001/BetterGen/populator/TreePopulator.php +++ b/src/Ad5001/BetterGen/populator/TreePopulator.php @@ -14,6 +14,8 @@ namespace Ad5001\BetterGen\populator; +use pocketmine\level\generator\object\Tree; +use pocketmine\level\Level; use pocketmine\utils\Random; use pocketmine\block\Block; use pocketmine\level\ChunkManager; @@ -23,11 +25,13 @@ use Ad5001\BetterGen\Main; class TreePopulator extends AmountPopulator { + /** @var Tree[] */ static $types = [ "pocketmine\\level\\generator\\object\\OakTree", "pocketmine\\level\\generator\\object\\BirchTree", "Ad5001\\BetterGen\\structure\\SakuraTree" ]; + /** @var ChunkManager */ protected $level; protected $type; @@ -63,7 +67,8 @@ class TreePopulator extends AmountPopulator { continue; } $treeC = self::$types [$this->type]; - $tree = new $treeC(); + /** @var Tree $tree */ + $tree = new $treeC(); $tree->placeObject($level, $x, $y, $z, $random); } } @@ -74,7 +79,7 @@ class TreePopulator extends AmountPopulator { * @param $z int */ 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); if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) { break; diff --git a/src/Ad5001/BetterGen/populator/WellPopulator.php b/src/Ad5001/BetterGen/populator/WellPopulator.php index f49d675..5dd0398 100644 --- a/src/Ad5001/BetterGen/populator/WellPopulator.php +++ b/src/Ad5001/BetterGen/populator/WellPopulator.php @@ -14,6 +14,7 @@ namespace Ad5001\BetterGen\populator; +use pocketmine\level\Level; use pocketmine\utils\Random; use pocketmine\block\Block; use pocketmine\level\ChunkManager; @@ -21,6 +22,7 @@ use Ad5001\BetterGen\structure\Well; use Ad5001\BetterGen\populator\AmountPopulator; class WellPopulator extends AmountPopulator { + /** @var ChunkManager */ protected $level; /* @@ -48,7 +50,7 @@ class WellPopulator extends AmountPopulator { * @param $z int */ 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); if ($b === Block::SAND) { break;