From 38f9faecd8369871096549fddc1645eac5fadf76 Mon Sep 17 00:00:00 2001 From: thebigsmileXD Date: Thu, 11 May 2017 11:49:57 +0200 Subject: [PATCH 1/8] Make Generation max height depend on the actual maxheight, fix PHPstorm namespaces --- .gitignore | 1 + src/Ad5001/BetterGen/generator/BetterNormal.php | 4 +++- src/Ad5001/BetterGen/populator/BushPopulator.php | 4 +++- .../BetterGen/populator/CactusPopulator.php | 4 +++- src/Ad5001/BetterGen/populator/CavePopulator.php | 4 +++- .../BetterGen/populator/DeadbushPopulator.php | 4 +++- .../BetterGen/populator/FallenTreePopulator.php | 6 ++++-- .../populator/FloatingIslandPopulator.php | 15 ++++++++++----- src/Ad5001/BetterGen/populator/IglooPopulator.php | 4 +++- src/Ad5001/BetterGen/populator/LakePopulator.php | 4 +++- .../BetterGen/populator/RavinePopulator.php | 4 +++- .../BetterGen/populator/SugarCanePopulator.php | 4 +++- .../BetterGen/populator/TemplePopulator.php | 4 +++- src/Ad5001/BetterGen/populator/TreePopulator.php | 9 +++++++-- src/Ad5001/BetterGen/populator/WellPopulator.php | 4 +++- 15 files changed, 55 insertions(+), 20 deletions(-) create mode 100644 .gitignore 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; From 796c10f51abf1f3501152106fb490943b6907c2e Mon Sep 17 00:00:00 2001 From: thebigsmileXD Date: Thu, 11 May 2017 13:29:22 +0200 Subject: [PATCH 2/8] Static call fixes, Params fix, spelling upgrades --- README.md | 13 +- plugin.yml | 2 +- resources/loots/mineshaft.json | 2 +- src/Ad5001/BetterGen/Main.php | 12 +- src/Ad5001/BetterGen/biome/BetterDesert.php | 3 +- src/Ad5001/BetterGen/biome/BetterForest.php | 22 +-- .../BetterGen/biome/BetterIcePlains.php | 7 +- src/Ad5001/BetterGen/biome/BetterMesa.php | 3 +- .../BetterGen/biome/BetterMesaPlains.php | 3 +- src/Ad5001/BetterGen/biome/BetterRiver.php | 4 +- src/Ad5001/BetterGen/biome/Mountainable.php | 4 +- .../generator/BetterBiomeSelector.php | 3 +- .../BetterGen/generator/BetterNormal.php | 13 +- src/Ad5001/BetterGen/loot/LootTable.php | 16 +-- .../BetterGen/populator/AmountPopulator.php | 2 +- .../BetterGen/populator/BushPopulator.php | 2 +- .../BetterGen/populator/CactusPopulator.php | 2 +- .../BetterGen/populator/CavePopulator.php | 4 +- .../BetterGen/populator/DeadbushPopulator.php | 2 +- .../populator/FallenTreePopulator.php | 2 +- .../populator/FloatingIslandPopulator.php | 11 +- .../BetterGen/populator/IglooPopulator.php | 2 +- .../BetterGen/populator/LakePopulator.php | 2 +- .../populator/MineshaftPopulator.php | 40 +++--- .../BetterGen/populator/RavinePopulator.php | 2 +- .../populator/SugarCanePopulator.php | 2 +- .../BetterGen/populator/TemplePopulator.php | 2 +- .../BetterGen/populator/TreePopulator.php | 2 +- .../BetterGen/populator/WellPopulator.php | 2 +- src/Ad5001/BetterGen/structure/Bush.php | 4 +- src/Ad5001/BetterGen/structure/Cactus.php | 2 +- src/Ad5001/BetterGen/structure/FallenTree.php | 128 +++++++++--------- src/Ad5001/BetterGen/structure/Igloo.php | 16 ++- src/Ad5001/BetterGen/structure/SakuraTree.php | 12 +- src/Ad5001/BetterGen/structure/SugarCane.php | 2 +- src/Ad5001/BetterGen/structure/Temple.php | 23 ++-- src/Ad5001/BetterGen/structure/Well.php | 44 +++--- src/Ad5001/BetterGen/utils/BuildingUtils.php | 2 +- src/Ad5001/BetterGen/utils/CommonUtils.php | 6 +- 39 files changed, 216 insertions(+), 209 deletions(-) diff --git a/README.md b/README.md index bb31282..3bf6db7 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,10 @@

PocketMine's Tomorrow's World Generator.

Welcome user to the home of a new PocketMine World Generator which features 9 new/modified biomes: + ------ -# Commun: -### Commun structures to all biomes features: +# Common: +### Common structures to all biomes features: 1.

Mineshafts:

2.

Ravines:

@@ -12,8 +13,6 @@ Welcome user to the home of a new PocketMine World Generator which features 9 ne 4.

Floating islands:

- - ----- # [NEW BIOME] Sakura forests: @@ -23,7 +22,7 @@ Welcome user to the home of a new PocketMine World Generator which features 9 ne ----- # [NEW BIOMES] Mesa Mountains & Plains -### These biomes are inspired (but not completly taken) from Minecraft PC. +### These biomes are inspired (but not completely taken) from Minecraft PC. @@ -31,13 +30,13 @@ Welcome user to the home of a new PocketMine World Generator which features 9 ne # Better Desert: ### The desert has been reworked and now includes the Minecraft PC's temples and wells ! -### Additionaly, deadbush, sugar cane and cactus are here too ! +### Additionally, deadbush, sugar cane and cactus are here too ! ----- # Better Ice Plains -### Ice plains got redisigned ! There is now snow instead of grass at it's bottom ! On the plus side, Igloos were imported from Minecraft PC ! +### Ice plains got redesigned ! There is now snow instead of grass at it's bottom ! On the plus side, Igloos were imported from Minecraft PC ! diff --git a/plugin.yml b/plugin.yml index db56c8c..8c90a65 100644 --- a/plugin.yml +++ b/plugin.yml @@ -6,7 +6,7 @@ # \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ # \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ # \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ -# Tommorow's pocketmine generator. +# Tomorrow's pocketmine generator. # @author Ad5001 # @link https://github.com/Ad5001/BetterGen name: BetterGen diff --git a/resources/loots/mineshaft.json b/resources/loots/mineshaft.json index 4d65d11..9f326e5 100644 --- a/resources/loots/mineshaft.json +++ b/resources/loots/mineshaft.json @@ -45,7 +45,7 @@ "id": 263, "data": 0 }, - "beethroot seeds": { + "beetroot seeds": { "percentage": 32, "minCount": 2, "maxCount": 4, diff --git a/src/Ad5001/BetterGen/Main.php b/src/Ad5001/BetterGen/Main.php index 8fe39cd..55d69cb 100644 --- a/src/Ad5001/BetterGen/Main.php +++ b/src/Ad5001/BetterGen/Main.php @@ -7,13 +7,16 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ namespace Ad5001\BetterGen; +use pocketmine\command\Command; +use pocketmine\command\CommandSender; +use pocketmine\event\Listener; use pocketmine\plugin\PluginBase; use pocketmine\level\generator\biome\Biome; use pocketmine\level\generator\Generator; @@ -35,7 +38,7 @@ use pocketmine\item\Item; use pocketmine\event\player\PlayerInteractEvent; use pocketmine\event\block\BlockBreakEvent; -class Main extends PluginBase implements \pocketmine\event\Listener { +class Main extends PluginBase implements Listener { const PREFIX = "§l§o§b[§r§l§2Better§aGen§o§b]§r§f "; const SAKURA_FOREST = 100; // Letting some place for future biomes. @@ -45,7 +48,7 @@ class Main extends PluginBase implements \pocketmine\event\Listener { public function onEnable() { $this->getServer()->getPluginManager()->registerEvents($this, $this); Generator::addGenerator(BetterNormal::class, "betternormal"); - if($this->isOtherNS()) $this->getLogger()->warning("Tesseract detected. Note that some parts of the generator could not work properly"); + if($this->isOtherNS()) $this->getLogger()->warning("Tesseract detected. Note that Tesseract is not up to date with the generation structure and some generation features may be limited or not working"); @mkdir($this->getDataFolder()); if(! file_exists(LootTable::getPluginFolder(). "processingLoots.json")) file_put_contents(LootTable::getPluginFolder(). "processingLoots.json", "{}"); @@ -65,7 +68,7 @@ class Main extends PluginBase implements \pocketmine\event\Listener { * @param $args array * return bool */ - public function onCommand(\pocketmine\command\CommandSender $sender, \pocketmine\command\Command $cmd, $label, array $args): bool { + public function onCommand(CommandSender $sender, Command $cmd, $label, array $args): bool { switch($cmd->getName()) { case "createworld" : // /createworld [generator = betternormal] [seed = rand()] [options(json)] switch(count($args)) { @@ -145,6 +148,7 @@ class Main extends PluginBase implements \pocketmine\event\Listener { return true; break; } + return false; } /* diff --git a/src/Ad5001/BetterGen/biome/BetterDesert.php b/src/Ad5001/BetterGen/biome/BetterDesert.php index b4e715d..f33e7fc 100644 --- a/src/Ad5001/BetterGen/biome/BetterDesert.php +++ b/src/Ad5001/BetterGen/biome/BetterDesert.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -24,6 +24,7 @@ use Ad5001\BetterGen\populator\SugarCanePopulator; class BetterDesert extends SandyBiome implements Mountainable { public function __construct() { + parent::__construct(); $deadBush = new DeadbushPopulator (); $deadBush->setBaseAmount(1); $deadBush->setRandomAmount(2); diff --git a/src/Ad5001/BetterGen/biome/BetterForest.php b/src/Ad5001/BetterGen/biome/BetterForest.php index eaffb3b..69db0e0 100644 --- a/src/Ad5001/BetterGen/biome/BetterForest.php +++ b/src/Ad5001/BetterGen/biome/BetterForest.php @@ -8,7 +8,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -66,25 +66,25 @@ class BetterForest extends ForestBiome implements Mountainable { public function getName() { return str_ireplace(" ", "", self::$types[$this->type]); } - - /* - * Returns the ID relativly. + + /** + * Returns the ID relatively. + * @return int */ public function getId() { return self::$ids [$this->type]; } - - /* - * Registers a forest type. Don't use this method directly use the one from the main class. - * @param $name string - * @param $treeClass string - * @param + /** + * @param string $name + * @param string $treeClass + * @param array $infos * @return bool */ public static function registerForest(string $name, string $treeClass, array $infos): bool { self::$types [] = str_ireplace("tree", "", explode("\\", $treeClass ) [count(explode("\\", $treeClass ) )] ) . " Forest"; TreePopulator::$types [] = $treeClass; self::$ids [] = Main::SAKURA_FOREST + (count(self::$types ) - 2); - Main::register(Main::SAKURA_FOREST + (count(self::$types ) - 2), new BetterForest(count(self::$types ) - 1, $infos )); + self::register(Main::SAKURA_FOREST + (count(self::$types ) - 2), new BetterForest(count(self::$types ) - 1, $infos )); + return true; } } \ No newline at end of file diff --git a/src/Ad5001/BetterGen/biome/BetterIcePlains.php b/src/Ad5001/BetterGen/biome/BetterIcePlains.php index 5b58eb1..e4e5529 100644 --- a/src/Ad5001/BetterGen/biome/BetterIcePlains.php +++ b/src/Ad5001/BetterGen/biome/BetterIcePlains.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -46,8 +46,9 @@ class BetterIcePlains extends SnowyBiome implements Mountainable { return "BetterIcePlains"; } - /* - * Returns biome's id. + /** + * Returns the biomes' id. + * @return int biome id */ public function getId() { return Biome::ICE_PLAINS; diff --git a/src/Ad5001/BetterGen/biome/BetterMesa.php b/src/Ad5001/BetterGen/biome/BetterMesa.php index f49eaf6..2976d70 100644 --- a/src/Ad5001/BetterGen/biome/BetterMesa.php +++ b/src/Ad5001/BetterGen/biome/BetterMesa.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -28,6 +28,7 @@ use Ad5001\BetterGen\populator\SugarCanePopulator; class BetterMesa extends SandyBiome { public function __construct() { + parent::__construct(); $deadBush = new DeadbushPopulator (); $deadBush->setBaseAmount(1); $deadBush->setRandomAmount(2); diff --git a/src/Ad5001/BetterGen/biome/BetterMesaPlains.php b/src/Ad5001/BetterGen/biome/BetterMesaPlains.php index 326bacd..cb700f3 100644 --- a/src/Ad5001/BetterGen/biome/BetterMesaPlains.php +++ b/src/Ad5001/BetterGen/biome/BetterMesaPlains.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -26,6 +26,7 @@ use Ad5001\BetterGen\Main; class BetterMesaPlains extends SandyBiome { public function __construct() { + parent::__construct(); $deadBush = new DeadbushPopulator (); $deadBush->setBaseAmount(1); $deadBush->setRandomAmount(2); diff --git a/src/Ad5001/BetterGen/biome/BetterRiver.php b/src/Ad5001/BetterGen/biome/BetterRiver.php index d6d97d5..ea18996 100644 --- a/src/Ad5001/BetterGen/biome/BetterRiver.php +++ b/src/Ad5001/BetterGen/biome/BetterRiver.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -45,7 +45,7 @@ class BetterRiver extends Biome { } /* - * Returns the ID relativly. + * Returns the ID relatively. */ public function getId() { return Biome::RIVER; diff --git a/src/Ad5001/BetterGen/biome/Mountainable.php b/src/Ad5001/BetterGen/biome/Mountainable.php index 6c47f0d..f2175a0 100644 --- a/src/Ad5001/BetterGen/biome/Mountainable.php +++ b/src/Ad5001/BetterGen/biome/Mountainable.php @@ -7,13 +7,13 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ namespace Ad5001\BetterGen\biome; -// Class to iplement when the biome can be set as a mountain +// Class to implement when the biome can be set as a mountain interface Mountainable { } \ No newline at end of file diff --git a/src/Ad5001/BetterGen/generator/BetterBiomeSelector.php b/src/Ad5001/BetterGen/generator/BetterBiomeSelector.php index 86c1b3c..48debb5 100644 --- a/src/Ad5001/BetterGen/generator/BetterBiomeSelector.php +++ b/src/Ad5001/BetterGen/generator/BetterBiomeSelector.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -33,6 +33,7 @@ class BetterBiomeSelector extends BiomeSelector { private $map = [ ]; private $lookup; public function __construct(Random $random, callable $lookup, Biome $fallback) { + parent::__construct($random, $lookup, $fallback); $this->fallback = $fallback; $this->lookup = $lookup; $this->temperature = new Simplex($random, 2, 1 / 16, 1 / 512); diff --git a/src/Ad5001/BetterGen/generator/BetterNormal.php b/src/Ad5001/BetterGen/generator/BetterNormal.php index 5a59a19..3b88849 100644 --- a/src/Ad5001/BetterGen/generator/BetterNormal.php +++ b/src/Ad5001/BetterGen/generator/BetterNormal.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -48,7 +48,7 @@ use Ad5001\BetterGen\populator\FloatingIslandPopulator; use Ad5001\BetterGen\Main; class BetterNormal extends Generator { - const NOT_OVERWRITABLE = [ + const NOT_OVERWRITABLE = [ Block::STONE, Block::GRAVEL, Block::BEDROCK, @@ -68,6 +68,7 @@ class BetterNormal extends Generator { protected $populators = [ ]; protected $generationPopulators = [ ]; public static $biomes = [ ]; + /** @var Biome[] */ public static $biomeById = [ ]; public static $levels = [ ]; protected static $GAUSSIAN_KERNEL = null; // From main class @@ -233,6 +234,7 @@ class BetterNormal extends Generator { * @param $rainfall float */ public static function getBiome($temperature, $rainfall) { + $ret = null; if (! isset(self::$biomes [( string ) round($rainfall, 1 )] )) { while(! isset(self::$biomes [( string ) round($rainfall, 1 )] ) ) { if (abs($rainfall - round($rainfall, 1 ) ) >= 0.05) @@ -254,9 +256,8 @@ class BetterNormal extends Generator { } if (is_string($ret )) { $ret = new $ret (); - } else { - return $ret; } + return $ret; } /* @@ -265,7 +266,7 @@ class BetterNormal extends Generator { * @return Biome */ public function getBiomeById(int $id): Biome { - return self::$biomeById[$id] ?? self::$biomeById(Biome::OCEAN); + return self::$biomeById[$id] ?? self::$biomeById[Biome::OCEAN]; } /* @@ -388,7 +389,7 @@ class BetterNormal extends Generator { } /* - * Generates the genration kernel based on smooth size (here 2) + * Generates the generation kernel based on smooth size (here 2) */ private static function generateKernel() { self::$GAUSSIAN_KERNEL = [ ]; diff --git a/src/Ad5001/BetterGen/loot/LootTable.php b/src/Ad5001/BetterGen/loot/LootTable.php index cd0798f..2f1ab26 100644 --- a/src/Ad5001/BetterGen/loot/LootTable.php +++ b/src/Ad5001/BetterGen/loot/LootTable.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -23,7 +23,7 @@ use pocketmine\nbt\NBT; /* * This class is used for loot setting. - * Please note that they AREN'T as powerfull as PC ones due to some implementations limitations. + * Please note that they AREN'T as powerful as PC ones due to some implementations limitations. * Loot table format: * { * "max": Max number of loots (storable amount) @@ -33,9 +33,9 @@ use pocketmine\nbt\NBT; * "maxCount": Maximal count * "id": Id of the item * "data": Item damage - * "tags": {"display": {"Name": "Example NBT data"}}. This parameter is optionnal - * "minStacks": If choosen, the minimum amount of stacks that can be found - * "maxStacks": If choosen the maximum number of stacks that can be choosen + * "tags": {"display": {"Name": "Example NBT data"}}. This parameter is optional + * "minStacks": If chosen, the minimum amount of stacks that can be found + * "maxStacks": If chosen the maximum number of stacks that can be chosen * } * } */ @@ -55,7 +55,7 @@ class LootTable { const LOOT_MINESHAFT = 2; /* - * Asyncronous loot table choosing + * Asynchronous loot table choosing * @param $place pocketmine\math\Vector3 * @param $type int * @param $random pocketmine\utils\Random @@ -80,7 +80,7 @@ class LootTable { } /* - * Syncronous inventory filling with loot table. + * Synchronous inventory filling with loot table. * @param $inv pocketmine\inventory\BaseInventory * @param $pos pocketmine\math\Vector3 * @return void @@ -96,7 +96,7 @@ class LootTable { for($i = 0; $i <= $randCount; $i++) { $rand = rand(0, count($loots)); $items[$rand] = Item::get($loot["id"], $loot["data"], rand($loot["minCount"], $loot["maxCount"])); - if(isset($loot["tags"])) $items[$rand]->setCompoundTag(NBT::fromJSON($loot["tags"])); + if(isset($loot["tags"])) $items[$rand]->setCompoundTag(NBT::parseJSON($loot["tags"])); } } $inv->setContents($items); diff --git a/src/Ad5001/BetterGen/populator/AmountPopulator.php b/src/Ad5001/BetterGen/populator/AmountPopulator.php index 43a85e2..6ae8765 100644 --- a/src/Ad5001/BetterGen/populator/AmountPopulator.php +++ b/src/Ad5001/BetterGen/populator/AmountPopulator.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ diff --git a/src/Ad5001/BetterGen/populator/BushPopulator.php b/src/Ad5001/BetterGen/populator/BushPopulator.php index 3d80926..765166c 100644 --- a/src/Ad5001/BetterGen/populator/BushPopulator.php +++ b/src/Ad5001/BetterGen/populator/BushPopulator.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ diff --git a/src/Ad5001/BetterGen/populator/CactusPopulator.php b/src/Ad5001/BetterGen/populator/CactusPopulator.php index f9345a2..d1802a4 100644 --- a/src/Ad5001/BetterGen/populator/CactusPopulator.php +++ b/src/Ad5001/BetterGen/populator/CactusPopulator.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ diff --git a/src/Ad5001/BetterGen/populator/CavePopulator.php b/src/Ad5001/BetterGen/populator/CavePopulator.php index 943d0b4..fb5ab45 100644 --- a/src/Ad5001/BetterGen/populator/CavePopulator.php +++ b/src/Ad5001/BetterGen/populator/CavePopulator.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -123,7 +123,7 @@ class CavePopulator extends AmountPopulator { $y --; } $z += round(($random->nextBoundedInt(round(30 * ($depth / 10) ) + 1 ) / 10 - 1)); - return [ ]; + return; } } $repeat = $random->nextBoundedInt(25 ) + 15; diff --git a/src/Ad5001/BetterGen/populator/DeadbushPopulator.php b/src/Ad5001/BetterGen/populator/DeadbushPopulator.php index 392f66a..edf583e 100644 --- a/src/Ad5001/BetterGen/populator/DeadbushPopulator.php +++ b/src/Ad5001/BetterGen/populator/DeadbushPopulator.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ diff --git a/src/Ad5001/BetterGen/populator/FallenTreePopulator.php b/src/Ad5001/BetterGen/populator/FallenTreePopulator.php index 890dc6f..a16bcde 100644 --- a/src/Ad5001/BetterGen/populator/FallenTreePopulator.php +++ b/src/Ad5001/BetterGen/populator/FallenTreePopulator.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ diff --git a/src/Ad5001/BetterGen/populator/FloatingIslandPopulator.php b/src/Ad5001/BetterGen/populator/FloatingIslandPopulator.php index c58f251..35c0e3a 100644 --- a/src/Ad5001/BetterGen/populator/FloatingIslandPopulator.php +++ b/src/Ad5001/BetterGen/populator/FloatingIslandPopulator.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -54,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));//static call + $biome = BetterNormal::$biomeById[$chunk->getBiomeId($x % 16, $z % 16)]; $populators = $biome->getPopulators(); foreach($populators as $populator) { $populator->populate($level, $chunkX, $chunkZ, $random); @@ -94,10 +94,7 @@ class FloatingIslandPopulator extends AmountPopulator { */ public function buildIslandBottomShape(ChunkManager $level, Vector3 $pos, int $radius, Random $random) { $pos = $pos->round(); - $xx = $pos->x; - $zz = $z; //undefined $currentLen = 1; - $isEdge = false; $hBound = 0; $current = 0; for($y = $pos->y - 1; $radius > 0; $y--) { @@ -110,7 +107,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));//static call + $biome = BetterNormal::$biomeById[$chunk->getBiomeId($x % 16, $z % 16)]; $block = $biome->getGroundCover()[$pos->y - $y - 1] ?? Block::get(Block::STONE); $block = $block->getId(); } elseif($random->nextBoundedInt(5) == 0 && $isEdge) { @@ -132,7 +129,7 @@ class FloatingIslandPopulator extends AmountPopulator { $radius--; } } - return $pos->y - 1 - $y; + //return $pos->y - 1 - $y;//void } diff --git a/src/Ad5001/BetterGen/populator/IglooPopulator.php b/src/Ad5001/BetterGen/populator/IglooPopulator.php index 292669c..cc49f2e 100644 --- a/src/Ad5001/BetterGen/populator/IglooPopulator.php +++ b/src/Ad5001/BetterGen/populator/IglooPopulator.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ diff --git a/src/Ad5001/BetterGen/populator/LakePopulator.php b/src/Ad5001/BetterGen/populator/LakePopulator.php index 7957cc0..018e465 100644 --- a/src/Ad5001/BetterGen/populator/LakePopulator.php +++ b/src/Ad5001/BetterGen/populator/LakePopulator.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ diff --git a/src/Ad5001/BetterGen/populator/MineshaftPopulator.php b/src/Ad5001/BetterGen/populator/MineshaftPopulator.php index 3f740f8..78e639b 100644 --- a/src/Ad5001/BetterGen/populator/MineshaftPopulator.php +++ b/src/Ad5001/BetterGen/populator/MineshaftPopulator.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -23,6 +23,7 @@ use Ad5001\BetterGen\loot\LootTable; class MineshaftPopulator extends AmountPopulator { protected $maxPath; + /** @var ChunkManager */ protected $level; const DIR_XPLUS = 0; const DIR_XMIN = 1; @@ -69,15 +70,14 @@ class MineshaftPopulator extends AmountPopulator { } } } - - /* + + /** * Builds a mineshaft part and return applicable directions - * @param $x int - * @param $y int - * @param $z int - * @param $dir int - * @param $random pocketmine\utils\Random - * @param $deepneth int + * @param int $x + * @param int $y + * @param int $z + * @param int $dir + * @param Random $random */ public function generateMineshaftPart(int $x, int $y, int $z, int $dir, Random $random) { if ($this->maxPath -- < 1) @@ -91,18 +91,18 @@ class MineshaftPopulator extends AmountPopulator { // First, filling everything blank. BuildingUtils::fill($this->level, new Vector3($x, $y, $z - 1 ), new Vector3($x + 4, $y + 2, $z + 1 ), Block::get(Block::AIR )); // Then, making sure the floor is solid. - BuildingUtils::fillCallback(new Vector3($x, $y - 1, $z - 1 ), new Vector3($x + 4, $y - 1, $z + 1 ), function ($v3, $level) { + BuildingUtils::fillCallback(new Vector3($x, $y - 1, $z - 1 ), new Vector3($x + 4, $y - 1, $z + 1 ), function ($v3, ChunkManager $level) { if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR) $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); }, $this->level); // Putting rails - BuildingUtils::fillCallback(new Vector3($x, $y, $z ), new Vector3($x + 4, $y, $z ), function ($v3, $level, $random) { + BuildingUtils::fillCallback(new Vector3($x, $y, $z ), new Vector3($x + 4, $y, $z ), function ($v3, ChunkManager $level, Random $random) { if ($random->nextBoundedInt(3 ) !== 0) { $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL); $level->setBlockDataAt($v3->x, $v3->y, $v3->z, 1); } }, $this->level, $random); - // After this, building the floor maintener (the wood structure) + // After this, building the floor maintainer (the wood structure) $level->setBlockIdAt($x, $y, $z - 1, Block::FENCE); $level->setBlockIdAt($x, $y, $z + 1, Block::FENCE); $level->setBlockIdAt($x, $y + 1, $z - 1, Block::FENCE); @@ -143,7 +143,7 @@ class MineshaftPopulator extends AmountPopulator { $level->setBlockDataAt($v3->x, $v3->y, $v3->z, 1); } }, $this->level, $random); - // After this, building the floor maintener (the wood structure) + // After this, building the floor maintainer (the wood structure) $level->setBlockIdAt($x, $y, $z - 1, Block::FENCE); $level->setBlockIdAt($x, $y, $z + 1, Block::FENCE); $level->setBlockIdAt($x, $y + 1, $z - 1, Block::FENCE); @@ -162,7 +162,7 @@ class MineshaftPopulator extends AmountPopulator { if ($direction2 == 0) $direction2 = 2; if ($direction2 == 1) - $direction2 = + $direction2 = 4; LootTable::buildLootTable(new Vector3($x - $direction2, $y, $z + $direction ), LootTable::LOOT_MINESHAFT, $random); } if ($random->nextBoundedInt(30 ) !== 0) @@ -172,19 +172,19 @@ class MineshaftPopulator extends AmountPopulator { // First, filling everything blank. BuildingUtils::fill($this->level, new Vector3($x - 1, $y, $z ), new Vector3($x + 1, $y + 2, $z + 4 )); // Then, making sure the floor is solid. - BuildingUtils::fillCallback(new Vector3($x - 1, $y - 1, $z ), new Vector3($x + 1, $y - 1, $z + 4 ), function ($v3, $level) { + BuildingUtils::fillCallback(new Vector3($x - 1, $y - 1, $z ), new Vector3($x + 1, $y - 1, $z + 4 ), function ($v3, ChunkManager $level) { if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR) $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); }, $this->level); // Putting rails - BuildingUtils::fillCallback(new Vector3($x, $y, $z ), new Vector3($x, $y, $z + 4 ), function ($v3, $level, $random) { + BuildingUtils::fillCallback(new Vector3($x, $y, $z ), new Vector3($x, $y, $z + 4 ), function ($v3, ChunkManager $level, Random $random) { if ($random->nextBoundedInt(3 ) !== 0) { $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL); $level->setBlockDataAt($v3->x, $v3->y, $v3->z, 0); } }, $this->level, $random); - // After this, building the floor maintener (the wood structure) + // After this, building the floor maintainer (the wood structure) $level->setBlockIdAt($x - 1, $y, $z, Block::FENCE); $level->setBlockIdAt($x + 1, $y, $z, Block::FENCE); $level->setBlockIdAt($x - 1, $y + 1, $z, Block::FENCE); @@ -225,7 +225,7 @@ class MineshaftPopulator extends AmountPopulator { $level->setBlockDataAt($v3->x, $v3->y, $v3->z, 0); } }, $this->level, $random); - // After this, building the floor maintener (the wood structure) + // After this, building the floor maintainer (the wood structure) $level->setBlockIdAt($x - 1, $y, $z, Block::FENCE); $level->setBlockIdAt($x + 1, $y, $z, Block::FENCE); $level->setBlockIdAt($x - 1, $y + 1, $z, Block::FENCE); @@ -288,7 +288,7 @@ class MineshaftPopulator extends AmountPopulator { } // Then, making sure the floor is solid. - BuildingUtils::fillCallback(new Vector3($x + 1, $y - 1, $z - 1 ), new Vector3($x - 1, $y - 1, $z + 1 ), function ($v3, $level) { + BuildingUtils::fillCallback(new Vector3($x + 1, $y - 1, $z - 1 ), new Vector3($x - 1, $y - 1, $z + 1 ), function ($v3, ChunkManager $level) { if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR) $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); @@ -315,7 +315,7 @@ class MineshaftPopulator extends AmountPopulator { $choose = $random->nextBoundedInt(4); unset($possiblePathes [$chooseNew] [$choose]); } - // Buidling pathes + // Building pathes foreach($possiblePathes [0] as $path ) { switch ($path) { case self::DIR_XPLUS : diff --git a/src/Ad5001/BetterGen/populator/RavinePopulator.php b/src/Ad5001/BetterGen/populator/RavinePopulator.php index a15f32c..ce1c47c 100644 --- a/src/Ad5001/BetterGen/populator/RavinePopulator.php +++ b/src/Ad5001/BetterGen/populator/RavinePopulator.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ diff --git a/src/Ad5001/BetterGen/populator/SugarCanePopulator.php b/src/Ad5001/BetterGen/populator/SugarCanePopulator.php index 4fde840..1ac6c15 100644 --- a/src/Ad5001/BetterGen/populator/SugarCanePopulator.php +++ b/src/Ad5001/BetterGen/populator/SugarCanePopulator.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ diff --git a/src/Ad5001/BetterGen/populator/TemplePopulator.php b/src/Ad5001/BetterGen/populator/TemplePopulator.php index d957405..24d1d52 100644 --- a/src/Ad5001/BetterGen/populator/TemplePopulator.php +++ b/src/Ad5001/BetterGen/populator/TemplePopulator.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ diff --git a/src/Ad5001/BetterGen/populator/TreePopulator.php b/src/Ad5001/BetterGen/populator/TreePopulator.php index d01952d..d8edd40 100644 --- a/src/Ad5001/BetterGen/populator/TreePopulator.php +++ b/src/Ad5001/BetterGen/populator/TreePopulator.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ diff --git a/src/Ad5001/BetterGen/populator/WellPopulator.php b/src/Ad5001/BetterGen/populator/WellPopulator.php index 5dd0398..664b242 100644 --- a/src/Ad5001/BetterGen/populator/WellPopulator.php +++ b/src/Ad5001/BetterGen/populator/WellPopulator.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ diff --git a/src/Ad5001/BetterGen/structure/Bush.php b/src/Ad5001/BetterGen/structure/Bush.php index af1c2e6..022ba97 100644 --- a/src/Ad5001/BetterGen/structure/Bush.php +++ b/src/Ad5001/BetterGen/structure/Bush.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -22,7 +22,7 @@ use pocketmine\math\Vector3; use pocketmine\level\generator\object\Object; class Bush extends Object { - public $overridable = [ + public $overridable = [ Block::AIR => true, 17 => true, Block::SNOW_LAYER => true, diff --git a/src/Ad5001/BetterGen/structure/Cactus.php b/src/Ad5001/BetterGen/structure/Cactus.php index e2ff8a7..4e01f0d 100644 --- a/src/Ad5001/BetterGen/structure/Cactus.php +++ b/src/Ad5001/BetterGen/structure/Cactus.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ diff --git a/src/Ad5001/BetterGen/structure/FallenTree.php b/src/Ad5001/BetterGen/structure/FallenTree.php index 8efdba3..661a4c8 100644 --- a/src/Ad5001/BetterGen/structure/FallenTree.php +++ b/src/Ad5001/BetterGen/structure/FallenTree.php @@ -1,54 +1,56 @@ true, - 6 => true, - 17 => true, - 18 => true, - Block::DANDELION => true, - Block::POPPY => true, - Block::SNOW_LAYER => true, - Block::LOG2 => true, - Block::LEAVES2 => true, - Block::CACTUS => true + public $overridable = [ + Block::AIR => true, + 6 => true, + 17 => true, + 18 => true, + Block::DANDELION => true, + Block::POPPY => true, + Block::SNOW_LAYER => true, + Block::LOG2 => true, + Block::LEAVES2 => true, + Block::CACTUS => true ]; + /** @var Tree */ protected $tree; protected $direction; protected $random; - + private $length; + /* * Constructs the class * @param $tree Tree - * @throws Exeption + * @throws Exception */ public function __construct(Tree $tree) { $this->tree = $tree; } - + /* * Places a fallen tree * @param $level pocketmine\level\ChunkManager @@ -62,27 +64,27 @@ class FallenTree extends Object { $this->length = $this->tree->trunkHeight + $randomHeight; $this->direction = $random->nextBoundedInt(4); $this->random = $random; - switch($this->direction) { + switch ($this->direction) { case 0: case 1:// Z+ - if(in_array(false, BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x, $y, $z + $this->length), function($v3, $level) { - if(!in_array($level->getBlockIdAt($v3->x, $v3->y, $v3->z), $this->overridable)) return false; - }, $level))) { - return false; - } - break; + if (in_array(false, BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x, $y, $z + $this->length), function ($v3, ChunkManager $level) { + if (!in_array($level->getBlockIdAt($v3->x, $v3->y, $v3->z), $this->overridable)) return false; else return true; + }, $level))) { + return false; + } + break; case 2: case 3: // X+ - if(in_array(false, BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x + $this->length, $y, $z), function($v3, $level) { - if(!in_array($level->getBlockIdAt($v3->x, $v3->y, $v3->z), $this->overridable)) return false; - }, $level))) { - return false; - } - break; + if (in_array(false, BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x + $this->length, $y, $z), function ($v3, ChunkManager $level) { + if (!in_array($level->getBlockIdAt($v3->x, $v3->y, $v3->z), $this->overridable)) return false; else return true; + }, $level))) { + return false; + } + break; } return true; } - + /* * Places a fallen tree * @param $level pocketmine\level\ChunkManager @@ -92,37 +94,39 @@ class FallenTree extends Object { */ public function placeObject(ChunkManager $level, $x, $y, $z) { echo "Placing at $x $y $z FallenTree\n"; - switch($this->direction) { + switch ($this->direction) { case 0: - $level->setBlockIdAt($x, $y, $z, $this->tree->trunkBlock); - $level->setBlockDataAt($x, $y, $z, $this->tree->type); - $z += 2; + $level->setBlockIdAt($x, $y, $z, $this->tree->trunkBlock); + $level->setBlockDataAt($x, $y, $z, $this->tree->type); + $z += 2; + break; case 1:// Z+ - BuildingUtils::fill($level, new Vector3($x, $y, $z), new Vector3($x, $y, $z + $this->length), Block::get($this->tree->trunkBlock, $this->tree->type + 4)); - BuildingUtils::fillRandom($level, new Vector3($x + 1, $y, $z), new Vector3($x, $y, $z + $this->length), Block::get(Block::VINE), $this->random); - BuildingUtils::fillRandom($level, new Vector3($x - 1, $y, $z), new Vector3($x, $y, $z + $this->length), Block::get(Block::VINE), $this->random); - break; + BuildingUtils::fill($level, new Vector3($x, $y, $z), new Vector3($x, $y, $z + $this->length), Block::get($this->tree->trunkBlock, $this->tree->type + 4)); + BuildingUtils::fillRandom($level, new Vector3($x + 1, $y, $z), new Vector3($x, $y, $z + $this->length), Block::get(Block::VINE), $this->random); + BuildingUtils::fillRandom($level, new Vector3($x - 1, $y, $z), new Vector3($x, $y, $z + $this->length), Block::get(Block::VINE), $this->random); + break; case 2: - $level->setBlockIdAt($x, $y, $z, $this->tree->trunkBlock); - $level->setBlockDataAt($x, $y, $z, $this->tree->type); - $x += 2; + $level->setBlockIdAt($x, $y, $z, $this->tree->trunkBlock); + $level->setBlockDataAt($x, $y, $z, $this->tree->type); + $x += 2; + break; case 3: // X+ - BuildingUtils::fill($level, new Vector3($x, $y, $z), new Vector3($x + $this->length, $y, $z), Block::get($this->tree->trunkBlock, $this->tree->type + 8)); - BuildingUtils::fillRandom($level, new Vector3($x, $y, $z + 1), new Vector3($x + $this->length, $y, $z), Block::get(Block::VINE), $this->random); - BuildingUtils::fillRandom($level, new Vector3($x, $y, $z - 1), new Vector3($x + $this->length, $y, $z), Block::get(Block::VINE), $this->random); - break; + BuildingUtils::fill($level, new Vector3($x, $y, $z), new Vector3($x + $this->length, $y, $z), Block::get($this->tree->trunkBlock, $this->tree->type + 8)); + BuildingUtils::fillRandom($level, new Vector3($x, $y, $z + 1), new Vector3($x + $this->length, $y, $z), Block::get(Block::VINE), $this->random); + BuildingUtils::fillRandom($level, new Vector3($x, $y, $z - 1), new Vector3($x + $this->length, $y, $z), Block::get(Block::VINE), $this->random); + break; } // Second call to build the last wood block - switch($this->direction) { + switch ($this->direction) { case 1: - $level->setBlockIdAt($x, $y, $z + $this->length + 2, $this->tree->trunkBlock); - break; + $level->setBlockIdAt($x, $y, $z + $this->length + 2, $this->tree->trunkBlock); + break; case 3: - $level->setBlockIdAt($x + $this->length + 2, $y, $z, $this->tree->trunkBlock); - break; + $level->setBlockIdAt($x + $this->length + 2, $y, $z, $this->tree->trunkBlock); + break; } } - + /* * Places a Block * @param $x int @@ -131,9 +135,9 @@ class FallenTree extends Object { * @param $level pocketmine\level\ChunkManager */ public function placeBlock($x, $y, $z, ChunkManager $level) { - if (isset($this->overridable [$level->getBlockIdAt($x, $y, $z )] ) && ! isset($this->overridable [$level->getBlockIdAt($x, $y - 1, $z )] )) { - $level->setBlockIdAt($x, $y, $z, $this->trunk [0]); - $level->setBlockDataAt($x, $y, $z, $this->trunk [1]); + if (isset($this->overridable [$level->getBlockIdAt($x, $y, $z)]) && !isset($this->overridable [$level->getBlockIdAt($x, $y - 1, $z)])) { + $level->setBlockIdAt($x, $y, $z, $this->tree->trunkBlock); + $level->setBlockDataAt($x, $y, $z, $this->tree->type); } } } \ No newline at end of file diff --git a/src/Ad5001/BetterGen/structure/Igloo.php b/src/Ad5001/BetterGen/structure/Igloo.php index 71a231f..8617d4b 100644 --- a/src/Ad5001/BetterGen/structure/Igloo.php +++ b/src/Ad5001/BetterGen/structure/Igloo.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -59,7 +59,7 @@ class Igloo extends Object { if (! isset($this->overridable [$level->getBlockIdAt($xx, $yy, $zz )] )) return false; break; - case 2 : // Entrence is z+ + case 2 : // Entrance is z+ for($xx = $x - 3; $xx <= $x + 3; $xx ++) for($yy = $y + 1; $yy <= $y + 4; $yy ++) for($zz = $z - 3; $zz <= $z + 4; $zz ++) @@ -84,6 +84,7 @@ class Igloo extends Object { * @param $y int * @param $z int * @param $random pocketmine\utils\Random + * @return bool placed */ public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) { if (! isset($this->direction ) && ! $this->canPlaceObject($level, $x, $y, $z, $random )) @@ -150,7 +151,7 @@ class Igloo extends Object { $level->setBlockIdAt($xx, $y + 1, $zz, Block::CARPET); } - // Other furnitures + // Other furniture // Bed $level->setBlockIdAt($x - 1, $y + 1, $z + 2, Block::BED_BLOCK); $level->setBlockIdAt($x, $y + 1, $z + 2, Block::BED_BLOCK); @@ -225,7 +226,7 @@ class Igloo extends Object { $level->setBlockIdAt($xx, $y + 1, $zz, Block::CARPET); } - // Other furnitures + // Other furniture // Bed $level->setBlockIdAt($x + 1, $y + 1, $z + 2, Block::BED_BLOCK); $level->setBlockIdAt($x, $y + 1, $z + 2, Block::BED_BLOCK); @@ -238,7 +239,7 @@ class Igloo extends Object { break; // Third direction - case 2 : // Entrence is z+ + case 2 : // Entrance is z+ // Ground for($xx = $x - 3; $xx <= $x + 3; $xx ++) for($zz = $z - 3; $zz <= $z + 4; $zz ++) @@ -299,7 +300,7 @@ class Igloo extends Object { $level->setBlockIdAt($xx, $y + 1, $zz, Block::CARPET); } - // Other furnitures + // Other furniture // Bed $level->setBlockIdAt($x + 2, $y + 1, $z - 1, Block::BED_BLOCK); $level->setBlockIdAt($x + 2, $y + 1, $z, Block::BED_BLOCK); @@ -373,7 +374,7 @@ class Igloo extends Object { $level->setBlockIdAt($xx, $y + 1, $zz, Block::CARPET); } - // Other furnitures + // Other furniture // Bed $level->setBlockIdAt($x + 2, $y + 1, $z + 1, Block::BED_BLOCK); $level->setBlockIdAt($x + 2, $y + 1, $z, Block::BED_BLOCK); @@ -385,5 +386,6 @@ class Igloo extends Object { $level->setBlockIdAt($x - 2, $y + 1, $z + 1, Block::FURNACE); break; } + return true; } } \ No newline at end of file diff --git a/src/Ad5001/BetterGen/structure/SakuraTree.php b/src/Ad5001/BetterGen/structure/SakuraTree.php index d32da10..d40cb06 100644 --- a/src/Ad5001/BetterGen/structure/SakuraTree.php +++ b/src/Ad5001/BetterGen/structure/SakuraTree.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -26,7 +26,7 @@ if(Main::isOtherNS()) { } class SakuraTree extends Tree { - const TRUNK_POS = [ // Checks for trees trunks. Not automaticly generated but there is no point of making more or less + const TRUNK_POS = [ // Checks for trees trunks. Not automatically generated but there is no point of making more or less 7 => [ 0, 1 @@ -495,7 +495,7 @@ class SakuraTree extends Tree { $z ]; - // Filling horisontally + // Filling horizontally if ($hParts > 0) { for($i = 0; $i < $hParts; $i ++) { $lastX += $xDiff * 2; @@ -512,7 +512,7 @@ class SakuraTree extends Tree { $lastZ += $zDiff; $this->setLog($level, $lastX, $lastY, $lastZ); - // Filling verticaly + // Filling vertically if ($vParts > 0) { for($i = 0; $i < $vParts; $i ++) { $lastX += $xDiff; @@ -530,7 +530,7 @@ class SakuraTree extends Tree { $this->setLog($level, $lastX, $lastY + $i, $lastZ); } $lastY ++; - // FIlling the branches. + // Filling the branches. $branchLen2 = function ($base) { return ceil($base / 2); }; @@ -629,7 +629,7 @@ class SakuraTree extends Tree { break; } - // Leaves falling from the tree diagonaly + // Leaves falling from the tree diagonally foreach(self::DIAG_LEAVES [$trunkHeight] as $pos ) { $numDown = $random->nextBoundedInt(3 ) + 1; for($y = $lastY + 1; $y > $lastY - $numDown; $y --) diff --git a/src/Ad5001/BetterGen/structure/SugarCane.php b/src/Ad5001/BetterGen/structure/SugarCane.php index 3e150d2..44b6f2f 100644 --- a/src/Ad5001/BetterGen/structure/SugarCane.php +++ b/src/Ad5001/BetterGen/structure/SugarCane.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ diff --git a/src/Ad5001/BetterGen/structure/Temple.php b/src/Ad5001/BetterGen/structure/Temple.php index 41ded3d..a43e0cd 100644 --- a/src/Ad5001/BetterGen/structure/Temple.php +++ b/src/Ad5001/BetterGen/structure/Temple.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -77,6 +77,8 @@ class Temple extends Object { - 2 ] ]; + /** @var ChunkManager */ + private $level; public $overridable = [ Block::AIR => true, 6 => true, @@ -107,7 +109,7 @@ class Temple extends Object { 1 ] ]; - + /* * Checks if a temple is placeable * @param $level pocketmine\level\ChunkManager @@ -118,6 +120,7 @@ class Temple extends Object { * @return bool */ public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) { + $this->level = $level; $this->direction = $random->nextBoundedInt(4); for($xx = $x - 10; $xx <= $x + 10; $xx ++) for($yy = $y + 1; $yy <= $y + 11; $yy ++) @@ -168,7 +171,7 @@ class Temple extends Object { for($zz = $z - 1; $zz <= $z + 1; $zz ++) $this->placeBlock($xx, $yy, $zz, 0); - // Floor patern + // Floor pattern foreach($this->directions as $dir ) { // Building pillar for($yy = $y + 1; $yy <= $y + 3; $yy ++) @@ -413,7 +416,7 @@ class Temple extends Object { } /* - * Places one of the towers. Out is inversed $direction1, stairs come from inversed $direction2 to $direction2, patterns are on $direction1 and $direction2 + * Places one of the towers. Out is inverted $direction1, stairs come from inverted $direction2 to $direction2, patterns are on $direction1 and $direction2 * @param $x int * @param $y int * @param $z int @@ -497,12 +500,12 @@ class Temple extends Object { $this->placeBlock($x, $y + 7, $z - 2, Block::SANDSTONE, 2); $this->placeBlock($x + 1, $y + 7, $z - 2, Block::SANDSTONE, 2); break; - - // Building entrance to second floor. - BuildingUtils::fill($this->level, new Vector3($x - 9, $y + 5, $z + 4 ), new Vector3($x - 7, $y + 7, $z + 5 ), Block::get(Block::SANDSTONE, 2 )); - BuildingUtils::fill($this->level, new Vector3($x - 8, $y + 5, $z + 4 ), new Vector3($x - 8, $y + 6, $z + 5 ), Block::get(Block::AIR )); } - + + // Building entrance to second floor. + BuildingUtils::fill($this->level, new Vector3($x - 9, $y + 5, $z + 4 ), new Vector3($x - 7, $y + 7, $z + 5 ), Block::get(Block::SANDSTONE, 2 )); + BuildingUtils::fill($this->level, new Vector3($x - 8, $y + 5, $z + 4 ), new Vector3($x - 8, $y + 6, $z + 5 ), Block::get(Block::AIR )); + // Finishing stairs system $this->placeBlock($x - 2, $y + 3, $z, Block::SANDSTONE_STAIRS, 1); $this->placeBlock($x - 3, $y + 4, $z, Block::SANDSTONE_STAIRS, 1); @@ -890,7 +893,7 @@ class Temple extends Object { * @param $direction int * @return int */ - protected function getInversedDirection(int $direction): int { + protected function getInvertedDirection(int $direction): int { switch ($direction) { case self::DIRECTION_PLUSX : // x+ (0) return self::DIRECTION_MINX; diff --git a/src/Ad5001/BetterGen/structure/Well.php b/src/Ad5001/BetterGen/structure/Well.php index a9421e5..4bd6ee6 100644 --- a/src/Ad5001/BetterGen/structure/Well.php +++ b/src/Ad5001/BetterGen/structure/Well.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -22,6 +22,8 @@ use pocketmine\level\generator\object\Object; class Well extends Object { + /** @var ChunkManager */ + private $level; public $overridable = [ Block::AIR => true, 6 => true, @@ -52,17 +54,18 @@ class Well extends Object { 1 ] ]; - + /* * Checks if a well is placeable - * @param $level pocketmine\level\ChunkManager + * @param $level ChunkManager * @param $x int * @param $y int * @param $z int - * @param $random pocketmine\utils\Random + * @param $random Random * @return bool */ public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) { + $this->level = $level; for($xx = $x - 2; $xx <= $x + 2; $xx ++) for($yy = $y; $yy <= $y + 3; $yy ++) for($zz = $z - 2; $zz <= $z + 2; $zz ++) @@ -73,16 +76,16 @@ class Well extends Object { /* * Places a well - * @param $level pocketmine\level\ChunkManager + * @param $level ChunkManager * @param $x int * @param $y int * @param $z int - * @param $random pocketmine\utils\Random + * @param $random Random */ public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) { $this->level = $level; foreach($this->directions as $direction ) { - // Building pillard + // Building pillars for($yy = $y; $yy < $y + 3; $yy ++) $this->placeBlock($x + $direction [0], $yy, $z + $direction [1], Block::SANDSTONE); @@ -92,32 +95,20 @@ class Well extends Object { $this->placeBlock($x + ($direction [0] * 2), $y, $z + ($direction [1] * 2), Block::SANDSTONE); // Building slabs on the sides. Places two times due to all directions. - $this->placeSlab($x + ($direction [0] * 2), $y, $z); - $this->placeSlab($x, $y, $z + ($direction [1] * 2)); + $this->placeBlock($x + ($direction [0] * 2), $y, $z, Block::SANDSTONE, 1); + $this->placeBlock($x, $y, $z + ($direction [1] * 2), Block::SANDSTONE, 1); // Placing water.Places two times due to all directions. $this->placeBlock($x + $direction [0], $y, $z, Block::WATER); $this->placeBlock($x, $y, $z + $direction [1], Block::WATER); } - // Finitions + // Final things for($xx = $x - 1; $xx <= $x + 1; $xx ++) for($zz = $z - 1; $zz <= $z + 1; $zz ++) - $this->placeSlab($xx, $y + 3, $zz); - $this->placeSlab($x, $y + 3, $z, Block::SANDSTONE); - $this->placeSlab($x, $y, $z, Block::WATER); - } - - /* - * Places a slab - * @param $x int - * @param $y int - * @param $z int - * @return void - */ - public function placeSlab($x, $y, $z) { - $this->level->setBlockIdAt($x, $y, $z, 44); - $this->level->setBlockDataAt($x, $y, $z, 1); + $this->placeBlock($xx, $y + 3, $zz); + $this->placeBlock($x, $y + 3, $z, Block::SANDSTONE, 1); + $this->placeBlock($x, $y, $z, Block::WATER); } /* @@ -128,7 +119,8 @@ class Well extends Object { * @param $id int * @return void */ - public function placeBlock($x, $y, $z, $id) { + public function placeBlock($x, $y, $z, $id = 0, $meta = 0) { $this->level->setBlockIdAt($x, $y, $z, $id); + $this->level->setBlockDataAt($x, $y, $z, $meta); } } \ No newline at end of file diff --git a/src/Ad5001/BetterGen/utils/BuildingUtils.php b/src/Ad5001/BetterGen/utils/BuildingUtils.php index c987582..8a74a34 100644 --- a/src/Ad5001/BetterGen/utils/BuildingUtils.php +++ b/src/Ad5001/BetterGen/utils/BuildingUtils.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ diff --git a/src/Ad5001/BetterGen/utils/CommonUtils.php b/src/Ad5001/BetterGen/utils/CommonUtils.php index edf21db..13af710 100644 --- a/src/Ad5001/BetterGen/utils/CommonUtils.php +++ b/src/Ad5001/BetterGen/utils/CommonUtils.php @@ -7,17 +7,17 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ namespace Ad5001\BetterGen\utils; - # Communs utils under no namespace made for a specific usage + # Common utils under no namespace made for a specific usage class CommonUtils { /** - * Searches case insensitivly array $haystack for $needle. + * Searches case insensitively array $haystack for $needle. * src: http://php.net/manual/en/function.in-array.php#89256 * @param mixed $needle * @param array $haystack From 055014aa88557debf1ab9dc31d1e0124b2352d58 Mon Sep 17 00:00:00 2001 From: thebigsmileXD Date: Thu, 11 May 2017 14:07:26 +0200 Subject: [PATCH 3/8] Undefined fixes --- src/Ad5001/BetterGen/Main.php | 59 +- src/Ad5001/BetterGen/biome/BetterDesert.php | 10 +- src/Ad5001/BetterGen/biome/BetterForest.php | 6 +- .../BetterGen/biome/BetterIcePlains.php | 8 +- src/Ad5001/BetterGen/biome/BetterMesa.php | 11 +- .../BetterGen/biome/BetterMesaPlains.php | 10 +- src/Ad5001/BetterGen/biome/BetterRiver.php | 2 +- .../generator/BetterBiomeSelector.php | 5 +- .../BetterGen/generator/BetterNormal.php | 47 +- src/Ad5001/BetterGen/loot/LootTable.php | 8 +- .../BetterGen/populator/AmountPopulator.php | 2 +- .../BetterGen/populator/BushPopulator.php | 8 +- .../BetterGen/populator/CactusPopulator.php | 3 +- .../BetterGen/populator/CavePopulator.php | 9 +- .../BetterGen/populator/DeadbushPopulator.php | 1 - .../populator/FallenTreePopulator.php | 3 +- .../populator/FloatingIslandPopulator.php | 29 +- .../BetterGen/populator/IglooPopulator.php | 7 +- .../BetterGen/populator/LakePopulator.php | 7 +- .../populator/MineshaftPopulator.php | 32 +- .../BetterGen/populator/RavinePopulator.php | 7 +- .../populator/SugarCanePopulator.php | 3 +- .../BetterGen/populator/TemplePopulator.php | 7 +- .../BetterGen/populator/TreePopulator.php | 8 +- .../BetterGen/populator/WellPopulator.php | 7 +- src/Ad5001/BetterGen/structure/Bush.php | 5 +- src/Ad5001/BetterGen/structure/Cactus.php | 6 +- src/Ad5001/BetterGen/structure/Igloo.php | 2 +- src/Ad5001/BetterGen/structure/SakuraTree.php | 921 +++++++++--------- src/Ad5001/BetterGen/structure/SugarCane.php | 4 +- src/Ad5001/BetterGen/structure/Temple.php | 11 +- src/Ad5001/BetterGen/structure/Well.php | 2 +- src/Ad5001/BetterGen/utils/BuildingUtils.php | 2 +- 33 files changed, 620 insertions(+), 632 deletions(-) diff --git a/src/Ad5001/BetterGen/Main.php b/src/Ad5001/BetterGen/Main.php index 55d69cb..ed72ce9 100644 --- a/src/Ad5001/BetterGen/Main.php +++ b/src/Ad5001/BetterGen/Main.php @@ -14,29 +14,26 @@ namespace Ad5001\BetterGen; +use Ad5001\BetterGen\biome\BetterForest; +use Ad5001\BetterGen\generator\BetterNormal; +use Ad5001\BetterGen\loot\LootTable; +use pocketmine\block\Block; use pocketmine\command\Command; use pocketmine\command\CommandSender; +use pocketmine\event\block\BlockBreakEvent; +use pocketmine\event\level\ChunkPopulateEvent; use pocketmine\event\Listener; -use pocketmine\plugin\PluginBase; +use pocketmine\event\player\PlayerInteractEvent; use pocketmine\level\generator\biome\Biome; use pocketmine\level\generator\Generator; -use pocketmine\level\generator\normal\Normal; -use pocketmine\event\level\ChunkPopulateEvent; -use Ad5001\BetterGen\generator\BetterNormal; -use Ad5001\BetterGen\biome\BetterForest; -use Ad5001\BetterGen\loot\LootTable; -use pocketmine\utils\Config; -use pocketmine\block\Block; -use pocketmine\tile\Chest; -use pocketmine\nbt\NBT; use pocketmine\nbt\tag\CompoundTag; +use pocketmine\nbt\tag\IntTag; use pocketmine\nbt\tag\ListTag; use pocketmine\nbt\tag\StringTag; -use pocketmine\nbt\tag\IntTag; +use pocketmine\plugin\PluginBase; +use pocketmine\tile\Chest; use pocketmine\tile\Tile; -use pocketmine\item\Item; -use pocketmine\event\player\PlayerInteractEvent; -use pocketmine\event\block\BlockBreakEvent; +use pocketmine\utils\Config; class Main extends PluginBase implements Listener { const PREFIX = "§l§o§b[§r§l§2Better§aGen§o§b]§r§f "; @@ -214,7 +211,6 @@ class Main extends PluginBase implements Listener { $cfg = new Config(LootTable::getPluginFolder() . "processingLoots.json", Config::JSON); if($event->getBlock()->getId() !== Block::CHEST) return; if(!$cfg->exists($event->getBlock()->getX() . ";" . $event->getBlock()->getY() . ";" . $event->getBlock()->getZ())) return; - $chest = new \pocketmine\block\Chest(0); $nbt = new CompoundTag("", [ new ListTag("Items", []), new StringTag("id", Tile::CHEST), @@ -222,12 +218,10 @@ class Main extends PluginBase implements Listener { new IntTag("y", $event->getBlock()->y), new IntTag("z", $event->getBlock()->z) ]); - $chest->setLevel($event->getBlock()->getLevel()); - $cItem = Item::get(Item::CHEST, 0); - $cItem->setCustomName("§k(Fake)§r Minecart chest"); - $chest->place($cItem, $event->getBlock()->getLevel()->getBlock($event->getBlock()), $chest, 0, 0, 0, 0); - $inv = $event->getBlock()->getLevel()->getTile($event->getBlock()); - LootTable::fillChest($inv->getInventory(), $event->getBlock()); + /** @var Chest $chest */ + $chest = Tile::createTile(Tile::CHEST, $event->getBlock()->getLevel(), $nbt); + $chest->setName("§k(Fake)§r Minecart chest"); + LootTable::fillChest($chest->getInventory(), $event->getBlock()); } @@ -238,21 +232,18 @@ class Main extends PluginBase implements Listener { $cfg = new Config(LootTable::getPluginFolder() . "processingLoots.json", Config::JSON); if($event->getBlock()->getId() !== Block::CHEST) return; if(!$cfg->exists($event->getBlock()->getX() . ";" . $event->getBlock()->getY() . ";" . $event->getBlock()->getZ())) return; - $chest = new \pocketmine\block\Chest(0); $nbt = new CompoundTag("", [ - new ListTag("Items", []), - new StringTag("id", Tile::CHEST), - new IntTag("x", $event->getBlock()->x), - new IntTag("y", $event->getBlock()->y), - new IntTag("z", $event->getBlock()->z) + new ListTag("Items", []), + new StringTag("id", Tile::CHEST), + new IntTag("x", $event->getBlock()->x), + new IntTag("y", $event->getBlock()->y), + new IntTag("z", $event->getBlock()->z) ]); - $chest->setLevel($event->getBlock()->getLevel()); - $cItem = Item::get(Item::CHEST, 0); - $cItem->setCustomName("§k(Fake)§r Minecart chest"); - $chest->place($cItem, $event->getBlock()->getLevel()->getBlock($event->getBlock()), $chest, 0, 0, 0, 0); - $inv = $event->getBlock()->getLevel()->getTile($event->getBlock()); - LootTable::fillChest($inv->getInventory(), $event->getBlock()); - $event->setCancelled(); + /** @var Chest $chest */ + $chest = Tile::createTile(Tile::CHEST, $event->getBlock()->getLevel(), $nbt); + $chest->setName("§k(Fake)§r Minecart chest"); + LootTable::fillChest($chest->getInventory(), $event->getBlock()); + // $event->setCancelled(); //i think nope. You want to break it with items } /* diff --git a/src/Ad5001/BetterGen/biome/BetterDesert.php b/src/Ad5001/BetterGen/biome/BetterDesert.php index f33e7fc..ee5e2e7 100644 --- a/src/Ad5001/BetterGen/biome/BetterDesert.php +++ b/src/Ad5001/BetterGen/biome/BetterDesert.php @@ -13,14 +13,14 @@ */ namespace Ad5001\BetterGen\biome; -use pocketmine\level\generator\normal\biome\SandyBiome; -use pocketmine\level\generator\biome\Biome; -use pocketmine\block\Block; -use Ad5001\BetterGen\populator\TemplePopulator; -use Ad5001\BetterGen\populator\WellPopulator; use Ad5001\BetterGen\populator\CactusPopulator; use Ad5001\BetterGen\populator\DeadbushPopulator; use Ad5001\BetterGen\populator\SugarCanePopulator; +use Ad5001\BetterGen\populator\TemplePopulator; +use Ad5001\BetterGen\populator\WellPopulator; +use pocketmine\block\Block; +use pocketmine\level\generator\biome\Biome; +use pocketmine\level\generator\normal\biome\SandyBiome; class BetterDesert extends SandyBiome implements Mountainable { public function __construct() { diff --git a/src/Ad5001/BetterGen/biome/BetterForest.php b/src/Ad5001/BetterGen/biome/BetterForest.php index 69db0e0..f50868d 100644 --- a/src/Ad5001/BetterGen/biome/BetterForest.php +++ b/src/Ad5001/BetterGen/biome/BetterForest.php @@ -15,12 +15,12 @@ namespace Ad5001\BetterGen\biome; -use pocketmine\level\generator\normal\biome\ForestBiome; -use pocketmine\level\generator\biome\Biome; use Ad5001\BetterGen\Main; -use Ad5001\BetterGen\populator\TreePopulator; use Ad5001\BetterGen\populator\BushPopulator; use Ad5001\BetterGen\populator\FallenTreePopulator; +use Ad5001\BetterGen\populator\TreePopulator; +use pocketmine\level\generator\biome\Biome; +use pocketmine\level\generator\normal\biome\ForestBiome; class BetterForest extends ForestBiome implements Mountainable { diff --git a/src/Ad5001/BetterGen/biome/BetterIcePlains.php b/src/Ad5001/BetterGen/biome/BetterIcePlains.php index e4e5529..6700eae 100644 --- a/src/Ad5001/BetterGen/biome/BetterIcePlains.php +++ b/src/Ad5001/BetterGen/biome/BetterIcePlains.php @@ -14,11 +14,11 @@ namespace Ad5001\BetterGen\biome; -use pocketmine\level\generator\normal\biome\SnowyBiome; -use pocketmine\level\generator\biome\Biome; -use pocketmine\block\Block; -use Ad5001\BetterGen\populator\IglooPopulator; use Ad5001\BetterGen\Main; +use Ad5001\BetterGen\populator\IglooPopulator; +use pocketmine\block\Block; +use pocketmine\level\generator\biome\Biome; +use pocketmine\level\generator\normal\biome\SnowyBiome; class BetterIcePlains extends SnowyBiome implements Mountainable { public function __construct() { diff --git a/src/Ad5001/BetterGen/biome/BetterMesa.php b/src/Ad5001/BetterGen/biome/BetterMesa.php index 2976d70..e82460b 100644 --- a/src/Ad5001/BetterGen/biome/BetterMesa.php +++ b/src/Ad5001/BetterGen/biome/BetterMesa.php @@ -14,17 +14,14 @@ namespace Ad5001\BetterGen\biome; -use pocketmine\level\generator\normal\biome\SandyBiome; -use pocketmine\level\generator\populator\Ore; -use pocketmine\level\generator\object\OreType; -use pocketmine\level\generator\biome\Biome; -use pocketmine\block\Block; -use pocketmine\block\GoldOre; use Ad5001\BetterGen\Main; -use Ad5001\BetterGen\populator\TreePopulator; use Ad5001\BetterGen\populator\CactusPopulator; use Ad5001\BetterGen\populator\DeadbushPopulator; use Ad5001\BetterGen\populator\SugarCanePopulator; +use Ad5001\BetterGen\populator\TreePopulator; +use pocketmine\block\Block; +use pocketmine\block\GoldOre; +use pocketmine\level\generator\normal\biome\SandyBiome; class BetterMesa extends SandyBiome { public function __construct() { diff --git a/src/Ad5001/BetterGen/biome/BetterMesaPlains.php b/src/Ad5001/BetterGen/biome/BetterMesaPlains.php index cb700f3..610e972 100644 --- a/src/Ad5001/BetterGen/biome/BetterMesaPlains.php +++ b/src/Ad5001/BetterGen/biome/BetterMesaPlains.php @@ -14,15 +14,13 @@ namespace Ad5001\BetterGen\biome; -use pocketmine\level\generator\normal\biome\SandyBiome; -use pocketmine\level\generator\object\OreType; -use pocketmine\level\generator\biome\Biome; -use pocketmine\block\Block; -use pocketmine\block\GoldOre; +use Ad5001\BetterGen\Main; use Ad5001\BetterGen\populator\CactusPopulator; use Ad5001\BetterGen\populator\DeadbushPopulator; use Ad5001\BetterGen\populator\SugarCanePopulator; -use Ad5001\BetterGen\Main; +use pocketmine\block\Block; +use pocketmine\block\GoldOre; +use pocketmine\level\generator\normal\biome\SandyBiome; class BetterMesaPlains extends SandyBiome { public function __construct() { diff --git a/src/Ad5001/BetterGen/biome/BetterRiver.php b/src/Ad5001/BetterGen/biome/BetterRiver.php index ea18996..b6f7df2 100644 --- a/src/Ad5001/BetterGen/biome/BetterRiver.php +++ b/src/Ad5001/BetterGen/biome/BetterRiver.php @@ -14,8 +14,8 @@ namespace Ad5001\BetterGen\biome; -use pocketmine\level\generator\biome\Biome; use pocketmine\block\Block; +use pocketmine\level\generator\biome\Biome; class BetterRiver extends Biome { public function __construct() { diff --git a/src/Ad5001/BetterGen/generator/BetterBiomeSelector.php b/src/Ad5001/BetterGen/generator/BetterBiomeSelector.php index 48debb5..a87a300 100644 --- a/src/Ad5001/BetterGen/generator/BetterBiomeSelector.php +++ b/src/Ad5001/BetterGen/generator/BetterBiomeSelector.php @@ -13,10 +13,10 @@ */ namespace Ad5001\BetterGen\generator; -use pocketmine\level\generator\biome\BiomeSelector; use pocketmine\level\generator\biome\Biome; -use pocketmine\utils\Random; +use pocketmine\level\generator\biome\BiomeSelector; use pocketmine\level\generator\noise\Simplex; +use pocketmine\utils\Random; class BetterBiomeSelector extends BiomeSelector { @@ -30,7 +30,6 @@ class BetterBiomeSelector extends BiomeSelector { /** @var Biome[] */ private $biomes = [ ]; - private $map = [ ]; private $lookup; public function __construct(Random $random, callable $lookup, Biome $fallback) { parent::__construct($random, $lookup, $fallback); diff --git a/src/Ad5001/BetterGen/generator/BetterNormal.php b/src/Ad5001/BetterGen/generator/BetterNormal.php index 3b88849..7cd9464 100644 --- a/src/Ad5001/BetterGen/generator/BetterNormal.php +++ b/src/Ad5001/BetterGen/generator/BetterNormal.php @@ -14,15 +14,18 @@ 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; -use pocketmine\level\generator\noise\Simplex; -use pocketmine\level\generator\object\OreType; -use pocketmine\level\generator\normal\object\OreType as OreType2; -use pocketmine\level\generator\populator\Ore; +use Ad5001\BetterGen\biome\BetterDesert; +use Ad5001\BetterGen\biome\BetterForest; +use Ad5001\BetterGen\biome\BetterIcePlains; +use Ad5001\BetterGen\biome\BetterMesa; +use Ad5001\BetterGen\biome\BetterMesaPlains; +use Ad5001\BetterGen\biome\BetterRiver; +use Ad5001\BetterGen\biome\Mountainable; +use Ad5001\BetterGen\Main; +use Ad5001\BetterGen\populator\CavePopulator; +use Ad5001\BetterGen\populator\FloatingIslandPopulator; +use Ad5001\BetterGen\populator\MineshaftPopulator; +use Ad5001\BetterGen\populator\RavinePopulator; use pocketmine\block\Block; use pocketmine\block\CoalOre; use pocketmine\block\DiamondOre; @@ -32,20 +35,15 @@ use pocketmine\block\Gravel; use pocketmine\block\IronOre; use pocketmine\block\LapisOre; use pocketmine\block\RedstoneOre; +use pocketmine\level\ChunkManager; +use pocketmine\level\generator\biome\Biome; +use pocketmine\level\generator\Generator; +use pocketmine\level\generator\noise\Simplex; +use pocketmine\level\generator\normal\object\OreType as OreType2; +use pocketmine\level\generator\object\OreType; use pocketmine\level\Level; -use Ad5001\BetterGen\biome\BetterForest; -use Ad5001\BetterGen\biome\BetterDesert; -use Ad5001\BetterGen\biome\BetterIcePlains; -use Ad5001\BetterGen\biome\BetterMesa; -use Ad5001\BetterGen\biome\BetterMesaPlains; -use Ad5001\BetterGen\biome\BetterRiver; -use Ad5001\BetterGen\biome\Mountainable; -use Ad5001\BetterGen\populator\CavePopulator; -use Ad5001\BetterGen\populator\RavinePopulator; -use Ad5001\BetterGen\populator\LakePopulator; -use Ad5001\BetterGen\populator\MineshaftPopulator; -use Ad5001\BetterGen\populator\FloatingIslandPopulator; -use Ad5001\BetterGen\Main; +use pocketmine\math\Vector3; +use pocketmine\utils\Random; class BetterNormal extends Generator { const NOT_OVERWRITABLE = [ @@ -61,9 +59,11 @@ class BetterNormal extends Generator { Block::WATER, Block::STILL_WATER ]; + /** @var BetterBiomeSelector */ protected $selector; /** @var Level */ protected $level; + /** @var Random */ protected $random; protected $populators = [ ]; protected $generationPopulators = [ ]; @@ -78,7 +78,8 @@ class BetterNormal extends Generator { ] ]; protected $waterHeight = 63; - + private $noiseBase; + /* * Picks a biome by X and Z * @param $x int diff --git a/src/Ad5001/BetterGen/loot/LootTable.php b/src/Ad5001/BetterGen/loot/LootTable.php index 2f1ab26..24c0cdf 100644 --- a/src/Ad5001/BetterGen/loot/LootTable.php +++ b/src/Ad5001/BetterGen/loot/LootTable.php @@ -14,12 +14,12 @@ namespace Ad5001\BetterGen\loot; +use pocketmine\inventory\BaseInventory; +use pocketmine\item\Item; +use pocketmine\math\Vector3; +use pocketmine\nbt\NBT; use pocketmine\utils\Config; use pocketmine\utils\Random; -use pocketmine\math\Vector3; -use pocketmine\item\Item; -use pocketmine\inventory\BaseInventory; -use pocketmine\nbt\NBT; /* * This class is used for loot setting. diff --git a/src/Ad5001/BetterGen/populator/AmountPopulator.php b/src/Ad5001/BetterGen/populator/AmountPopulator.php index 6ae8765..aee3766 100644 --- a/src/Ad5001/BetterGen/populator/AmountPopulator.php +++ b/src/Ad5001/BetterGen/populator/AmountPopulator.php @@ -14,8 +14,8 @@ namespace Ad5001\BetterGen\populator; -use pocketmine\utils\Random; use pocketmine\level\generator\populator\Populator; +use pocketmine\utils\Random; abstract class AmountPopulator extends Populator { protected $baseAmount = 0; diff --git a/src/Ad5001/BetterGen/populator/BushPopulator.php b/src/Ad5001/BetterGen/populator/BushPopulator.php index 765166c..65c64cd 100644 --- a/src/Ad5001/BetterGen/populator/BushPopulator.php +++ b/src/Ad5001/BetterGen/populator/BushPopulator.php @@ -14,13 +14,11 @@ namespace Ad5001\BetterGen\populator; -use pocketmine\level\Level; -use pocketmine\utils\Random; +use Ad5001\BetterGen\structure\Bush; use pocketmine\block\Block; use pocketmine\level\ChunkManager; -use Ad5001\BetterGen\populator\TreePopulator; -use Ad5001\BetterGen\populator\AmountPopulator; -use Ad5001\BetterGen\structure\Bush; +use pocketmine\level\Level; +use pocketmine\utils\Random; class BushPopulator extends AmountPopulator { /** @var ChunkManager */ diff --git a/src/Ad5001/BetterGen/populator/CactusPopulator.php b/src/Ad5001/BetterGen/populator/CactusPopulator.php index d1802a4..cc7b7c7 100644 --- a/src/Ad5001/BetterGen/populator/CactusPopulator.php +++ b/src/Ad5001/BetterGen/populator/CactusPopulator.php @@ -15,12 +15,11 @@ namespace Ad5001\BetterGen\populator; +use Ad5001\BetterGen\structure\Cactus; 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 */ diff --git a/src/Ad5001/BetterGen/populator/CavePopulator.php b/src/Ad5001/BetterGen/populator/CavePopulator.php index fb5ab45..60682a8 100644 --- a/src/Ad5001/BetterGen/populator/CavePopulator.php +++ b/src/Ad5001/BetterGen/populator/CavePopulator.php @@ -14,13 +14,12 @@ namespace Ad5001\BetterGen\populator; -use pocketmine\level\Level; -use pocketmine\utils\Random; +use Ad5001\BetterGen\utils\BuildingUtils; use pocketmine\block\Block; use pocketmine\level\ChunkManager; +use pocketmine\level\Level; use pocketmine\math\Vector3; -use Ad5001\BetterGen\utils\BuildingUtils; -use Ad5001\BetterGen\populator\AmountPopulator; +use pocketmine\utils\Random; class CavePopulator extends AmountPopulator { /** @var ChunkManager */ @@ -93,7 +92,7 @@ class CavePopulator extends AmountPopulator { foreach($gen = $this->generateBranch($x, $y, $z, 5, 3, 5, $random ) as $v3 ) { $generatedBranches --; if ($generatedBranches <= 0) { - $gen->send(self::STOP); + $gen->send(self::STOP); // send not found.. @Ad5001 what is that } else { $gen->send(self::CONTINUE); } diff --git a/src/Ad5001/BetterGen/populator/DeadbushPopulator.php b/src/Ad5001/BetterGen/populator/DeadbushPopulator.php index edf583e..dee8bc2 100644 --- a/src/Ad5001/BetterGen/populator/DeadbushPopulator.php +++ b/src/Ad5001/BetterGen/populator/DeadbushPopulator.php @@ -18,7 +18,6 @@ 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 */ diff --git a/src/Ad5001/BetterGen/populator/FallenTreePopulator.php b/src/Ad5001/BetterGen/populator/FallenTreePopulator.php index a16bcde..be8bd58 100644 --- a/src/Ad5001/BetterGen/populator/FallenTreePopulator.php +++ b/src/Ad5001/BetterGen/populator/FallenTreePopulator.php @@ -14,12 +14,11 @@ namespace Ad5001\BetterGen\populator; +use Ad5001\BetterGen\structure\FallenTree; 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 { diff --git a/src/Ad5001/BetterGen/populator/FloatingIslandPopulator.php b/src/Ad5001/BetterGen/populator/FloatingIslandPopulator.php index 35c0e3a..3c2a600 100644 --- a/src/Ad5001/BetterGen/populator/FloatingIslandPopulator.php +++ b/src/Ad5001/BetterGen/populator/FloatingIslandPopulator.php @@ -14,22 +14,21 @@ 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; -use pocketmine\level\generator\object\OreType; -use pocketmine\level\generator\normal\object\OreType as OreType2; -use pocketmine\math\Vector3; -use pocketmine\block\CoalOre; -use pocketmine\block\IronOre; -use pocketmine\block\RedstoneOre; -use pocketmine\block\LapisOre; -use pocketmine\block\GoldOre; -use pocketmine\block\DiamondOre; use Ad5001\BetterGen\Main; +use pocketmine\block\Block; +use pocketmine\block\CoalOre; +use pocketmine\block\DiamondOre; +use pocketmine\block\GoldOre; +use pocketmine\block\IronOre; +use pocketmine\block\LapisOre; +use pocketmine\block\RedstoneOre; +use pocketmine\level\ChunkManager; +use pocketmine\level\generator\normal\object\OreType as OreType2; +use pocketmine\level\generator\object\OreType; +use pocketmine\level\Level; +use pocketmine\math\Vector3; +use pocketmine\utils\Random; class FloatingIslandPopulator extends AmountPopulator { @@ -162,6 +161,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);//x z undefined + $ores->populate($level, $pos->x >> 4, $pos->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 cc49f2e..b49cf60 100644 --- a/src/Ad5001/BetterGen/populator/IglooPopulator.php +++ b/src/Ad5001/BetterGen/populator/IglooPopulator.php @@ -14,12 +14,11 @@ namespace Ad5001\BetterGen\populator; -use pocketmine\level\Level; -use pocketmine\utils\Random; +use Ad5001\BetterGen\structure\Igloo; use pocketmine\block\Block; use pocketmine\level\ChunkManager; -use Ad5001\BetterGen\populator\AmountPopulator; -use Ad5001\BetterGen\structure\Igloo; +use pocketmine\level\Level; +use pocketmine\utils\Random; class IglooPopulator extends AmountPopulator { /** @var ChunkManager */ diff --git a/src/Ad5001/BetterGen/populator/LakePopulator.php b/src/Ad5001/BetterGen/populator/LakePopulator.php index 018e465..ee2194f 100644 --- a/src/Ad5001/BetterGen/populator/LakePopulator.php +++ b/src/Ad5001/BetterGen/populator/LakePopulator.php @@ -14,13 +14,12 @@ namespace Ad5001\BetterGen\populator; -use pocketmine\level\Level; -use pocketmine\utils\Random; +use Ad5001\BetterGen\utils\BuildingUtils; use pocketmine\block\Block; use pocketmine\level\ChunkManager; +use pocketmine\level\Level; use pocketmine\math\Vector3; -use Ad5001\BetterGen\utils\BuildingUtils; -use Ad5001\BetterGen\populator\AmountPopulator; +use pocketmine\utils\Random; class LakePopulator extends AmountPopulator { /** @var ChunkManager */ diff --git a/src/Ad5001/BetterGen/populator/MineshaftPopulator.php b/src/Ad5001/BetterGen/populator/MineshaftPopulator.php index 78e639b..c325063 100644 --- a/src/Ad5001/BetterGen/populator/MineshaftPopulator.php +++ b/src/Ad5001/BetterGen/populator/MineshaftPopulator.php @@ -14,12 +14,12 @@ namespace Ad5001\BetterGen\populator; -use pocketmine\level\ChunkManager; -use pocketmine\utils\Random; -use Ad5001\BetterGen\utils\BuildingUtils; -use pocketmine\math\Vector3; -use pocketmine\block\Block; use Ad5001\BetterGen\loot\LootTable; +use Ad5001\BetterGen\utils\BuildingUtils; +use pocketmine\block\Block; +use pocketmine\level\ChunkManager; +use pocketmine\math\Vector3; +use pocketmine\utils\Random; class MineshaftPopulator extends AmountPopulator { protected $maxPath; @@ -131,13 +131,13 @@ class MineshaftPopulator extends AmountPopulator { // First, filling everything blank. BuildingUtils::fill($this->level, new Vector3($x, $y, $z - 1 ), new Vector3($x - 4, $y + 2, $z + 1 )); // Then, making sure the floor is solid. - BuildingUtils::fillCallback(new Vector3($x, $y - 1, $z - 1 ), new Vector3($x - 4, $y - 1, $z + 1 ), function ($v3, $level) { + BuildingUtils::fillCallback(new Vector3($x, $y - 1, $z - 1 ), new Vector3($x - 4, $y - 1, $z + 1 ), function ($v3, ChunkManager $level) { if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR) $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); }, $this->level); // Putting rails - BuildingUtils::fillCallback(new Vector3($x, $y, $z ), new Vector3($x - 4, $y, $z ), function ($v3, $level, $random) { + BuildingUtils::fillCallback(new Vector3($x, $y, $z ), new Vector3($x - 4, $y, $z ), function ($v3, ChunkManager $level, Random $random) { if ($random->nextBoundedInt(3 ) !== 0) { $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL); $level->setBlockDataAt($v3->x, $v3->y, $v3->z, 1); @@ -213,13 +213,13 @@ class MineshaftPopulator extends AmountPopulator { // First, filling everything blank. BuildingUtils::fill($this->level, new Vector3($x - 1, $y, $z ), new Vector3($x + 1, $y + 2, $z - 4 )); // Then, making sure the floor is solid. - BuildingUtils::fillCallback(new Vector3($x - 1, $y - 1, $z ), new Vector3($x + 1, $y - 1, $z - 4 ), function ($v3, $level) { + BuildingUtils::fillCallback(new Vector3($x - 1, $y - 1, $z ), new Vector3($x + 1, $y - 1, $z - 4 ), function ($v3, ChunkManager $level) { if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR) $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); }, $this->level); // Putting rails - BuildingUtils::fillCallback(new Vector3($x, $y, $z ), new Vector3($x, $y, $z - 4 ), function ($v3, $level, $random) { + BuildingUtils::fillCallback(new Vector3($x, $y, $z ), new Vector3($x, $y, $z - 4 ), function ($v3, ChunkManager $level, Random $random) { if ($random->nextBoundedInt(3 ) !== 0) { $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL); $level->setBlockDataAt($v3->x, $v3->y, $v3->z, 0); @@ -310,7 +310,7 @@ class MineshaftPopulator extends AmountPopulator { self::DIR_ZMIN ] : [ ]) ]; - for($i = 7; $i > $newfloor; $i --) { + for($i = 7; $i > $newFloor; $i --) { $chooseNew =(int ) $newFloor && $random->nextBoolean (); $choose = $random->nextBoundedInt(4); unset($possiblePathes [$chooseNew] [$choose]); @@ -366,17 +366,17 @@ class MineshaftPopulator extends AmountPopulator { } // Building stairs for($i = 0; $i < 4; $i ++) { - switch ($path) { + switch ($i) { case self::DIR_XPLUS : BuildingUtils::fill($this->level, new Vector3($x + $i, $y - $i - 1, $z - 2 ), new Vector3($x + $i, $y - $i + 3, $z + 2 ), Block::get(Block::AIR )); - BuildingUtils::fillCallback(new Vector3($x + $i, $y - $i - 2, $z - 2 ), new Vector3($x + $i, $y - $i - 2, $z + 2 ), function ($v3, $level) { + BuildingUtils::fillCallback(new Vector3($x + $i, $y - $i - 2, $z - 2 ), new Vector3($x + $i, $y - $i - 2, $z + 2 ), function ($v3, ChunkManager $level) { if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR) $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); }, $this->level); break; case self::DIR_XMIN : BuildingUtils::fill($this->level, new Vector3($x - $i, $y - $i - 1, $z - 2 ), new Vector3($x - $i, $y - $i + 3, $z + 2 ), Block::get(Block::AIR )); - BuildingUtils::fillCallback(new Vector3($x - $i, $y - $i - 2, $z - 2 ), new Vector3($x - $i, $y - $i - 2, $z + 2 ), function ($v3, $level) { + BuildingUtils::fillCallback(new Vector3($x - $i, $y - $i - 2, $z - 2 ), new Vector3($x - $i, $y - $i - 2, $z + 2 ), function ($v3, ChunkManager $level) { if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR) $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); @@ -384,7 +384,7 @@ class MineshaftPopulator extends AmountPopulator { break; case self::DIR_ZPLUS : BuildingUtils::fill($this->level, new Vector3($x - 2, $y - $i - 1, $z + $i ), new Vector3($x + 2, $y - $i + 3, $z + $i ), Block::get(Block::AIR )); - BuildingUtils::fillCallback(new Vector3($x - 2, $y - $i - 2, $z + $i ), new Vector3($x + 2, $y - $i - 2, $z + $i ), function ($v3, $level) { + BuildingUtils::fillCallback(new Vector3($x - 2, $y - $i - 2, $z + $i ), new Vector3($x + 2, $y - $i - 2, $z + $i ), function ($v3, ChunkManager $level) { if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR) $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); @@ -392,7 +392,7 @@ class MineshaftPopulator extends AmountPopulator { break; case self::DIR_ZMIN : BuildingUtils::fill($this->level, new Vector3($x - 2, $y - $i - 1, $z - $i ), new Vector3($x + 2, $y - $i + 3, $z - $i ), Block::get(Block::AIR )); - BuildingUtils::fillCallback(new Vector3($x - 2, $y - $i - 2, $z - $i ), new Vector3($x + 2, $y - $i - 2, $z - $i ), function ($v3, $level) { + BuildingUtils::fillCallback(new Vector3($x - 2, $y - $i - 2, $z - $i ), new Vector3($x + 2, $y - $i - 2, $z - $i ), function ($v3, ChunkManager $level) { if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR) $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); @@ -402,7 +402,7 @@ class MineshaftPopulator extends AmountPopulator { } // Next one - switch ($path) { + switch ($i) { case self::DIR_XPLUS : $this->generateMineshaftPart($x + 4, $y - 4, $z, self::DIR_XPLUS, $random); break; diff --git a/src/Ad5001/BetterGen/populator/RavinePopulator.php b/src/Ad5001/BetterGen/populator/RavinePopulator.php index ce1c47c..ac75a31 100644 --- a/src/Ad5001/BetterGen/populator/RavinePopulator.php +++ b/src/Ad5001/BetterGen/populator/RavinePopulator.php @@ -14,12 +14,11 @@ namespace Ad5001\BetterGen\populator; -use pocketmine\level\Level; -use pocketmine\utils\Random; +use Ad5001\BetterGen\utils\BuildingUtils; use pocketmine\block\Block; use pocketmine\level\ChunkManager; -use Ad5001\BetterGen\populator\AmountPopulator; -use Ad5001\BetterGen\utils\BuildingUtils; +use pocketmine\level\Level; +use pocketmine\utils\Random; class RavinePopulator extends AmountPopulator { /** @var ChunkManager */ diff --git a/src/Ad5001/BetterGen/populator/SugarCanePopulator.php b/src/Ad5001/BetterGen/populator/SugarCanePopulator.php index 1ac6c15..1241835 100644 --- a/src/Ad5001/BetterGen/populator/SugarCanePopulator.php +++ b/src/Ad5001/BetterGen/populator/SugarCanePopulator.php @@ -14,12 +14,11 @@ namespace Ad5001\BetterGen\populator; +use Ad5001\BetterGen\structure\SugarCane; 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 */ diff --git a/src/Ad5001/BetterGen/populator/TemplePopulator.php b/src/Ad5001/BetterGen/populator/TemplePopulator.php index 24d1d52..cad160a 100644 --- a/src/Ad5001/BetterGen/populator/TemplePopulator.php +++ b/src/Ad5001/BetterGen/populator/TemplePopulator.php @@ -14,12 +14,11 @@ namespace Ad5001\BetterGen\populator; -use pocketmine\level\Level; -use pocketmine\utils\Random; +use Ad5001\BetterGen\structure\Temple; use pocketmine\block\Block; use pocketmine\level\ChunkManager; -use Ad5001\BetterGen\structure\Temple; -use Ad5001\BetterGen\populator\AmountPopulator; +use pocketmine\level\Level; +use pocketmine\utils\Random; class TemplePopulator extends AmountPopulator { /** @var Level */ diff --git a/src/Ad5001/BetterGen/populator/TreePopulator.php b/src/Ad5001/BetterGen/populator/TreePopulator.php index d8edd40..e5f93ec 100644 --- a/src/Ad5001/BetterGen/populator/TreePopulator.php +++ b/src/Ad5001/BetterGen/populator/TreePopulator.php @@ -14,14 +14,12 @@ namespace Ad5001\BetterGen\populator; +use Ad5001\BetterGen\Main; +use pocketmine\block\Block; +use pocketmine\level\ChunkManager; use pocketmine\level\generator\object\Tree; use pocketmine\level\Level; use pocketmine\utils\Random; -use pocketmine\block\Block; -use pocketmine\level\ChunkManager; -use Ad5001\BetterGen\structure\SakuraTree; -use Ad5001\BetterGen\populator\AmountPopulator; -use Ad5001\BetterGen\Main; class TreePopulator extends AmountPopulator { diff --git a/src/Ad5001/BetterGen/populator/WellPopulator.php b/src/Ad5001/BetterGen/populator/WellPopulator.php index 664b242..5555b33 100644 --- a/src/Ad5001/BetterGen/populator/WellPopulator.php +++ b/src/Ad5001/BetterGen/populator/WellPopulator.php @@ -14,12 +14,11 @@ namespace Ad5001\BetterGen\populator; -use pocketmine\level\Level; -use pocketmine\utils\Random; +use Ad5001\BetterGen\structure\Well; use pocketmine\block\Block; use pocketmine\level\ChunkManager; -use Ad5001\BetterGen\structure\Well; -use Ad5001\BetterGen\populator\AmountPopulator; +use pocketmine\level\Level; +use pocketmine\utils\Random; class WellPopulator extends AmountPopulator { /** @var ChunkManager */ diff --git a/src/Ad5001/BetterGen/structure/Bush.php b/src/Ad5001/BetterGen/structure/Bush.php index 022ba97..796636d 100644 --- a/src/Ad5001/BetterGen/structure/Bush.php +++ b/src/Ad5001/BetterGen/structure/Bush.php @@ -14,12 +14,11 @@ namespace Ad5001\BetterGen\structure; -use pocketmine\block\Leaves; use pocketmine\block\Block; use pocketmine\level\ChunkManager; -use pocketmine\utils\Random; -use pocketmine\math\Vector3; use pocketmine\level\generator\object\Object; +use pocketmine\math\Vector3; +use pocketmine\utils\Random; class Bush extends Object { public $overridable = [ diff --git a/src/Ad5001/BetterGen/structure/Cactus.php b/src/Ad5001/BetterGen/structure/Cactus.php index 4e01f0d..27cf28c 100644 --- a/src/Ad5001/BetterGen/structure/Cactus.php +++ b/src/Ad5001/BetterGen/structure/Cactus.php @@ -15,9 +15,9 @@ namespace Ad5001\BetterGen\structure; use pocketmine\block\Block; -use pocketmine\utils\Random; use pocketmine\level\ChunkManager; use pocketmine\level\generator\object\Object; +use pocketmine\utils\Random; class Cactus extends Object { @@ -29,10 +29,12 @@ class Cactus extends Object { * @param $z int * @param $random pocketmine\utils\Random */ + private $totalHeight; + public function canPlaceObject(ChunkManager $level, int $x, int $y, int $z, Random $random): bool { $this->totalHeight = 1 + $random->nextBoundedInt(3); $below = $level->getBlockIdAt($x, $y - 1, $z); - for($yy = $y; $yy <= $y + $totalHeight; $yy ++) { + for($yy = $y; $yy <= $y + $this->totalHeight; $yy ++) { if ($level->getBlockIdAt($x, $yy, $z ) !== Block::AIR || ($below !== Block::SAND && $below !== Block::CACTUS) || ($level->getBlockIdAt($x - 1, $yy, $z ) !== Block::AIR || $level->getBlockIdAt($x + 1, $yy, $z ) !== Block::AIR || $level->getBlockIdAt($x, $yy, $z - 1 ) !== Block::AIR || $level->getBlockIdAt($x, $yy, $z + 1 ) !== Block::AIR)) { return false; } diff --git a/src/Ad5001/BetterGen/structure/Igloo.php b/src/Ad5001/BetterGen/structure/Igloo.php index 8617d4b..d76fdac 100644 --- a/src/Ad5001/BetterGen/structure/Igloo.php +++ b/src/Ad5001/BetterGen/structure/Igloo.php @@ -16,8 +16,8 @@ namespace Ad5001\BetterGen\structure; use pocketmine\block\Block; use pocketmine\level\ChunkManager; -use pocketmine\utils\Random; use pocketmine\level\generator\object\Object; +use pocketmine\utils\Random; class Igloo extends Object { public $overridable = [ diff --git a/src/Ad5001/BetterGen/structure/SakuraTree.php b/src/Ad5001/BetterGen/structure/SakuraTree.php index d40cb06..f67d56a 100644 --- a/src/Ad5001/BetterGen/structure/SakuraTree.php +++ b/src/Ad5001/BetterGen/structure/SakuraTree.php @@ -1,10 +1,10 @@ [ - 0, - 1 - ], // 0 vertical, 1 horizontal and same goes for others... - 8 => [ - 1, - 0 - ], - 9 => [ - 1, - 1 - ], - 10 => [ - 2, - 0 - ], - 11 => [ - 2, - 1 - ], - 12 => [ - 2, - 2 - ], - 13 => [ - 3, - 1 - ] + 7 => [ + 0, + 1 + ], // 0 vertical, 1 horizontal and same goes for others... + 8 => [ + 1, + 0 + ], + 9 => [ + 1, + 1 + ], + 10 => [ + 2, + 0 + ], + 11 => [ + 2, + 1 + ], + 12 => [ + 2, + 2 + ], + 13 => [ + 3, + 1 + ] ]; const DIAG_LEAVES = [ // Diag poses of the leaves based on the height of the tree.X relative to $lastX and Z from $lastZ - 7 => [ - [ - 4, - 4 - ], - [ - - 4, - 4 - ], - [ - 4, - - 4 - ], - [ - - 4, - - 4 - ] + 7 => [ + [ + 4, + 4 ], - 8 => [ - [ - 6, - 6 - ], - [ - - 6, - 6 - ], - [ - 6, - - 6 - ], - [ - - 6, - - 6 - ] + [ + -4, + 4 ], - 9 => [ - [ - 6, - 6 - ], - [ - - 6, - 6 - ], - [ - 6, - - 6 - ], - [ - - 6, - - 6 - ] + [ + 4, + -4 ], - 10 => [ - [ - 6, - 6 - ], - [ - - 6, - 6 - ], - [ - 6, - - 6 - ], - [ - - 6, - - 6 - ] + [ + -4, + -4 + ] + ], + 8 => [ + [ + 6, + 6 ], - 11 => [ - [ - 7, - 7 - ], - [ - 6, - 8 - ], - [ - 8, - 6 - ], - [ - - 7, - 7 - ], - [ - - 6, - 8 - ], - [ - - 8, - 6 - ], - [ - 7, - - 7 - ], - [ - 6, - - 8 - ], - [ - 8, - - 6 - ], - [ - - 7, - - 7 - ], - [ - - 6, - - 8 - ], - [ - - 8, - - 6 - ] + [ + -6, + 6 ], - 12 => [ - [ - 7, - 7 - ], - [ - 6, - 8 - ], - [ - 8, - 6 - ], - [ - - 7, - 7 - ], - [ - - 6, - 8 - ], - [ - - 8, - 6 - ], - [ - 7, - - 7 - ], - [ - 6, - - 8 - ], - [ - 8, - - 6 - ], - [ - - 7, - - 7 - ], - [ - - 6, - - 8 - ], - [ - - 8, - - 6 - ] + [ + 6, + -6 ], - 13 => [ - [ - 7, - 7 - ], - [ - 6, - 8 - ], - [ - 8, - 6 - ], - [ - - 7, - 7 - ], - [ - - 6, - 8 - ], - [ - - 8, - 6 - ], - [ - 7, - - 7 - ], - [ - 6, - - 8 - ], - [ - 8, - - 6 - ], - [ - - 7, - - 7 - ], - [ - - 6, - - 8 - ], - [ - - 8, - - 6 - ] - ] + [ + -6, + -6 + ] + ], + 9 => [ + [ + 6, + 6 + ], + [ + -6, + 6 + ], + [ + 6, + -6 + ], + [ + -6, + -6 + ] + ], + 10 => [ + [ + 6, + 6 + ], + [ + -6, + 6 + ], + [ + 6, + -6 + ], + [ + -6, + -6 + ] + ], + 11 => [ + [ + 7, + 7 + ], + [ + 6, + 8 + ], + [ + 8, + 6 + ], + [ + -7, + 7 + ], + [ + -6, + 8 + ], + [ + -8, + 6 + ], + [ + 7, + -7 + ], + [ + 6, + -8 + ], + [ + 8, + -6 + ], + [ + -7, + -7 + ], + [ + -6, + -8 + ], + [ + -8, + -6 + ] + ], + 12 => [ + [ + 7, + 7 + ], + [ + 6, + 8 + ], + [ + 8, + 6 + ], + [ + -7, + 7 + ], + [ + -6, + 8 + ], + [ + -8, + 6 + ], + [ + 7, + -7 + ], + [ + 6, + -8 + ], + [ + 8, + -6 + ], + [ + -7, + -7 + ], + [ + -6, + -8 + ], + [ + -8, + -6 + ] + ], + 13 => [ + [ + 7, + 7 + ], + [ + 6, + 8 + ], + [ + 8, + 6 + ], + [ + -7, + 7 + ], + [ + -6, + 8 + ], + [ + -8, + 6 + ], + [ + 7, + -7 + ], + [ + 6, + -8 + ], + [ + 8, + -6 + ], + [ + -7, + -7 + ], + [ + -6, + -8 + ], + [ + -8, + -6 + ] + ] ]; const ADDITIONAL_BLOCKS = [ // Blocks who aren't set to fully fill the tree. X relative to $lastX and Z from $lastZ - 7 => [ ], - 8 => [ ], - 9 => [ ], - 10 => [ ], - 11 => [ - [ - 6, - 6 - ], - [ - 7, - 6 - ], - [ - 6, - 7 - ], - [ - - 6, - 6 - ], - [ - - 7, - 6 - ], - [ - - 6, - 7 - ], - [ - 6, - - 6 - ], - [ - 7, - - 6 - ], - [ - 6, - - 7 - ], - [ - - 6, - - 6 - ], - [ - - 7, - - 6 - ], - [ - - 6, - - 7 - ] + 7 => [], + 8 => [], + 9 => [], + 10 => [], + 11 => [ + [ + 6, + 6 ], - 12 => [ - [ - 6, - 6 - ], - [ - 7, - 6 - ], - [ - 6, - 7 - ], - [ - - 6, - 6 - ], - [ - - 7, - 6 - ], - [ - - 6, - 7 - ], - [ - 6, - - 6 - ], - [ - 7, - - 6 - ], - [ - 6, - - 7 - ], - [ - - 6, - - 6 - ], - [ - - 7, - - 6 - ], - [ - - 6, - - 7 - ] + [ + 7, + 6 ], - 13 => [ - [ - 6, - 6 - ], - [ - 7, - 6 - ], - [ - 6, - 7 - ], - [ - - 6, - 6 - ], - [ - - 7, - 6 - ], - [ - - 6, - 7 - ], - [ - 6, - - 6 - ], - [ - 7, - - 6 - ], - [ - 6, - - 7 - ], - [ - - 6, - - 6 - ], - [ - - 7, - - 6 - ], - [ - - 6, - - 7 - ] - ] + [ + 6, + 7 + ], + [ + -6, + 6 + ], + [ + -7, + 6 + ], + [ + -6, + 7 + ], + [ + 6, + -6 + ], + [ + 7, + -6 + ], + [ + 6, + -7 + ], + [ + -6, + -6 + ], + [ + -7, + -6 + ], + [ + -6, + -7 + ] + ], + 12 => [ + [ + 6, + 6 + ], + [ + 7, + 6 + ], + [ + 6, + 7 + ], + [ + -6, + 6 + ], + [ + -7, + 6 + ], + [ + -6, + 7 + ], + [ + 6, + -6 + ], + [ + 7, + -6 + ], + [ + 6, + -7 + ], + [ + -6, + -6 + ], + [ + -7, + -6 + ], + [ + -6, + -7 + ] + ], + 13 => [ + [ + 6, + 6 + ], + [ + 7, + 6 + ], + [ + 6, + 7 + ], + [ + -6, + 6 + ], + [ + -7, + 6 + ], + [ + -6, + 7 + ], + [ + 6, + -6 + ], + [ + 7, + -6 + ], + [ + 6, + -7 + ], + [ + -6, + -6 + ], + [ + -7, + -6 + ], + [ + -6, + -7 + ] + ] ]; const maxPerChunk = 2; public $trunkHeight = 11; - + private $leafType; + private $leaf2Type; + /* * Constructs the class */ @@ -451,7 +455,7 @@ class SakuraTree extends Tree { $this->leaf2Type = 0; $this->type = Wood::OAK; } - + /* * Builds the tree. * @param $level \pocketmine\level\ChunkManager @@ -466,7 +470,9 @@ class SakuraTree extends Tree { return; } $trunkHeight = 7 + $random->nextBoundedInt(7); - + + $xDiff = $zDiff = 0; + $direction = $random->nextBoundedInt(3); // Choosing building north east west south switch ($direction) { case 0 : @@ -486,35 +492,35 @@ class SakuraTree extends Tree { $zDiff = 0; break; } - list($vParts, $hParts ) = self::TRUNK_POS [$trunkHeight]; - + list($vParts, $hParts) = self::TRUNK_POS [$trunkHeight]; + $this->setLog($level, $x, $y, $z); - list($lastX, $lastY, $lastZ ) = [ - $x, - $y, - $z + list($lastX, $lastY, $lastZ) = [ + $x, + $y, + $z ]; - + // Filling horizontally if ($hParts > 0) { - for($i = 0; $i < $hParts; $i ++) { + for ($i = 0; $i < $hParts; $i++) { $lastX += $xDiff * 2; - $lastY ++; + $lastY++; $lastZ += $zDiff * 2; $this->setLog($level, $lastX - $xDiff, $lastY, $lastZ - $zDiff); $this->setLog($level, $lastX, $lastY, $lastZ); } } - + // The middle block $lastX += $xDiff; - $lastY ++; + $lastY++; $lastZ += $zDiff; $this->setLog($level, $lastX, $lastY, $lastZ); - + // Filling vertically if ($vParts > 0) { - for($i = 0; $i < $vParts; $i ++) { + for ($i = 0; $i < $vParts; $i++) { $lastX += $xDiff; $lastY += 2; $lastZ += $zDiff; @@ -524,18 +530,20 @@ class SakuraTree extends Tree { } // Filling the top trunk. $lastX += $xDiff; - $lastY ++; + $lastY++; $lastZ += $zDiff; - for($i = 0; $i < 4; $i ++) { + for ($i = 0; $i < 4; $i++) { $this->setLog($level, $lastX, $lastY + $i, $lastZ); } - $lastY ++; + $lastY++; // Filling the branches. $branchLen2 = function ($base) { return ceil($base / 2); }; - - for($dir = 0; $dir < 4; $dir ++) { + + $xd = $zd = 0; + + for ($dir = 0; $dir < 4; $dir++) { switch ($dir) { case 0 : $xd = 0; @@ -554,62 +562,67 @@ class SakuraTree extends Tree { $zd = 0; break; } - + $stickLen = round($trunkHeight / 3); $stickLen2 = call_user_func($branchLen2, $stickLen); $totalLength = $stickLen + $stickLen2; // Length of the stick $sideLen = $totalLength ** 2; // Side length - + + //TODO CHECK WHAT THIS IS SUPPOSED TO BE + $numForward = 0; + //TODO END + $lX1 = $lZ1 = $lX = $lZ = 0; + // First branch part + first leave part - for($i = 1; $i < $stickLen + 1; $i ++) { + for ($i = 1; $i < $stickLen + 1; $i++) { $lX1 = $lastX + ($xd * $i); $lZ1 = $lastZ + ($zd * $i); if ($zd !== 0) - for($x = $lX1 - $numForward; $x !== $lX1 + $numForward + 1; $x ++) { + for ($x = $lX1 - $numForward; $x !== $lX1 + $numForward + 1; $x++) { $this->setLeave($level, $x, $lastY + 3, $lZ1, $random); } if ($xd !== 0) - for($z = $lZ1 - $numForward; $z !== $lZ1 + $numForward + 1; $z ++) { + for ($z = $lZ1 - $numForward; $z !== $lZ1 + $numForward + 1; $z++) { $this->setLeave($level, $lX1, $lastY + 3, $z, $random); } $this->setLog($level, $lX1, $lastY, $lZ1); } - + // Second branch part. + second leave part $numForward = ($totalLength % 2 == 0) ? $totalLength - 1 : $totalLength; - for($i = 1; $i < $stickLen + 1; $i ++) { + for ($i = 1; $i < $stickLen + 1; $i++) { $lX = $lX1 + ($xd * $i); $lZ = $lZ1 + ($zd * $i); if ($zd !== 0) - for($x = $lX - $numForward; $x !== $lX + $numForward + 1; $x ++) { + for ($x = $lX - $numForward; $x !== $lX + $numForward + 1; $x++) { $this->setLeave($level, $x, $lastY + 2, $lZ, $random); } if ($xd !== 0) - for($z = $lZ - $numForward; $z !== $lZ + $numForward + 1; $z ++) { + for ($z = $lZ - $numForward; $z !== $lZ + $numForward + 1; $z++) { $this->setLeave($level, $lX, $lastY + 2, $z, $random); } $this->setLog($level, $lX, $lastY + 1, $lZ); } - + $lX += $xd; $lZ += $zd; // Leaves falling from the tree forward if ($lastZ !== $lZ) { // Z has changed, using X for setting - for($x = $lX - $numForward; $x <= $lX + $numForward; $x ++) { - $numDown = $random->nextBoundedInt(3 ) + 1; - for($y = $lastY + 1; $y > $lastY - $numDown; $y --) + for ($x = $lX - $numForward; $x <= $lX + $numForward; $x++) { + $numDown = $random->nextBoundedInt(3) + 1; + for ($y = $lastY + 1; $y > $lastY - $numDown; $y--) $this->setLeave($level, $x, $y, $lZ, $random); } } else { // Z have stayed, X has changed - for($z = $lZ - $numForward; $z <= $lZ + $numForward; $z ++) { - $numDown = $random->nextBoundedInt(3 ) + 1; - for($y = $lastY + 1; $y > $lastY + 1 - $numDown; $y --) + for ($z = $lZ - $numForward; $z <= $lZ + $numForward; $z++) { + $numDown = $random->nextBoundedInt(3) + 1; + for ($y = $lastY + 1; $y > $lastY + 1 - $numDown; $y--) $this->setLeave($level, $lX, $y, $z, $random); } } - + // continue; - + switch ($dir + 1) { case 4 : $xd2 = 0; @@ -628,21 +641,21 @@ class SakuraTree extends Tree { $zd2 = 0; break; } - + // Leaves falling from the tree diagonally - foreach(self::DIAG_LEAVES [$trunkHeight] as $pos ) { - $numDown = $random->nextBoundedInt(3 ) + 1; - for($y = $lastY + 1; $y > $lastY - $numDown; $y --) + foreach (self::DIAG_LEAVES [$trunkHeight] as $pos) { + $numDown = $random->nextBoundedInt(3) + 1; + for ($y = $lastY + 1; $y > $lastY - $numDown; $y--) $this->setLeave($level, $lastX + $pos [0], $y, $lastZ + $pos [1], $random); } - + // Additional leaves - foreach(self::ADDITIONAL_BLOCKS [$trunkHeight] as $pos ) { + foreach (self::ADDITIONAL_BLOCKS [$trunkHeight] as $pos) { $this->setLeave($level, $lastX + $pos [0], $lastY + 2, $lastZ + $pos [1], $random); } } } - + /* * Fills a log at. * @param $level pocketmine\level\ChunkManager @@ -654,7 +667,7 @@ class SakuraTree extends Tree { $level->setBlockIdAt($x, $y, $z, $this->trunkBlock); $level->setBlockDataAt($x, $y, $z, $this->type); } - + /* * Fills a leave at. * @param $level pocketmine\level\ChunkManager @@ -664,10 +677,10 @@ class SakuraTree extends Tree { * @param $random pocketmine\utils\Random */ public function setLeave(ChunkManager $level, $x, $y, $z, Random $random) { - $data = [ - $this->leafType, - $this->leaf2Type - ] [( int ) $random->nextBoolean ()]; + $data = [ + $this->leafType, + $this->leaf2Type + ] [( int )$random->nextBoolean()]; $level->setBlockIdAt($x, $y, $z, $this->leafBlock); $level->setBlockDataAt($x, $y, $z, $data); } diff --git a/src/Ad5001/BetterGen/structure/SugarCane.php b/src/Ad5001/BetterGen/structure/SugarCane.php index 44b6f2f..cbbc670 100644 --- a/src/Ad5001/BetterGen/structure/SugarCane.php +++ b/src/Ad5001/BetterGen/structure/SugarCane.php @@ -16,9 +16,9 @@ namespace Ad5001\BetterGen\structure; use pocketmine\block\Block; -use pocketmine\utils\Random; use pocketmine\level\ChunkManager; use pocketmine\level\generator\object\Object; +use pocketmine\utils\Random; class SugarCane extends Object { @@ -30,6 +30,8 @@ class SugarCane extends Object { * @param $z int * @param $random pocketmine\utils\Random */ + private $totalHeight; + public function canPlaceObject(ChunkManager $level, int $x, int $y, int $z, Random $random): bool { $this->totalHeight = 1 + $random->nextBoundedInt(3); $below = $level->getBlockIdAt($x, $y - 1, $z); diff --git a/src/Ad5001/BetterGen/structure/Temple.php b/src/Ad5001/BetterGen/structure/Temple.php index a43e0cd..d379db9 100644 --- a/src/Ad5001/BetterGen/structure/Temple.php +++ b/src/Ad5001/BetterGen/structure/Temple.php @@ -14,13 +14,13 @@ namespace Ad5001\BetterGen\structure; -use pocketmine\block\Block; -use pocketmine\level\ChunkManager; -use pocketmine\utils\Random; -use pocketmine\math\Vector3; -use pocketmine\level\generator\object\Object; use Ad5001\BetterGen\loot\LootTable; use Ad5001\BetterGen\utils\BuildingUtils; +use pocketmine\block\Block; +use pocketmine\level\ChunkManager; +use pocketmine\level\generator\object\Object; +use pocketmine\math\Vector3; +use pocketmine\utils\Random; class Temple extends Object { const DIRECTION_PLUSX = 0; @@ -109,6 +109,7 @@ class Temple extends Object { 1 ] ]; + private $direction; /* * Checks if a temple is placeable diff --git a/src/Ad5001/BetterGen/structure/Well.php b/src/Ad5001/BetterGen/structure/Well.php index 4bd6ee6..dcd55b9 100644 --- a/src/Ad5001/BetterGen/structure/Well.php +++ b/src/Ad5001/BetterGen/structure/Well.php @@ -17,8 +17,8 @@ namespace Ad5001\BetterGen\structure; use pocketmine\block\Block; use pocketmine\level\ChunkManager; -use pocketmine\utils\Random; use pocketmine\level\generator\object\Object; +use pocketmine\utils\Random; class Well extends Object { diff --git a/src/Ad5001/BetterGen/utils/BuildingUtils.php b/src/Ad5001/BetterGen/utils/BuildingUtils.php index 8a74a34..cd9cf3e 100644 --- a/src/Ad5001/BetterGen/utils/BuildingUtils.php +++ b/src/Ad5001/BetterGen/utils/BuildingUtils.php @@ -14,9 +14,9 @@ namespace Ad5001\BetterGen\utils; -use pocketmine\math\Vector3; use pocketmine\block\Block; use pocketmine\level\ChunkManager; +use pocketmine\math\Vector3; use pocketmine\utils\Random; class BuildingUtils { From 4ccd95196f88a31350b7eb4ba3d5d13b4ed09310 Mon Sep 17 00:00:00 2001 From: thebigsmileXD Date: Thu, 11 May 2017 15:12:17 +0200 Subject: [PATCH 4/8] Final touches --- processingLoots.json | 1 + .../BetterGen/generator/BetterNormal.php | 2 +- .../BetterGen/populator/BushPopulator.php | 2 +- .../BetterGen/populator/CactusPopulator.php | 2 +- .../BetterGen/populator/CavePopulator.php | 2 +- .../BetterGen/populator/DeadbushPopulator.php | 2 +- .../populator/FallenTreePopulator.php | 27 ++++++++++--------- .../populator/FloatingIslandPopulator.php | 8 +++--- .../BetterGen/populator/IglooPopulator.php | 2 +- .../BetterGen/populator/LakePopulator.php | 2 +- .../BetterGen/populator/RavinePopulator.php | 2 +- .../populator/SugarCanePopulator.php | 2 +- .../BetterGen/populator/TemplePopulator.php | 2 +- .../BetterGen/populator/TreePopulator.php | 2 +- .../BetterGen/populator/WellPopulator.php | 2 +- src/Ad5001/BetterGen/structure/FallenTree.php | 21 ++++++++------- src/Ad5001/BetterGen/structure/SakuraTree.php | 2 +- 17 files changed, 44 insertions(+), 39 deletions(-) create mode 100644 processingLoots.json diff --git a/processingLoots.json b/processingLoots.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/processingLoots.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/src/Ad5001/BetterGen/generator/BetterNormal.php b/src/Ad5001/BetterGen/generator/BetterNormal.php index 7cd9464..be0936a 100644 --- a/src/Ad5001/BetterGen/generator/BetterNormal.php +++ b/src/Ad5001/BetterGen/generator/BetterNormal.php @@ -447,6 +447,6 @@ class BetterNormal extends Generator { } } - return $y++; + return ++$y; } } \ No newline at end of file diff --git a/src/Ad5001/BetterGen/populator/BushPopulator.php b/src/Ad5001/BetterGen/populator/BushPopulator.php index 65c64cd..6c58765 100644 --- a/src/Ad5001/BetterGen/populator/BushPopulator.php +++ b/src/Ad5001/BetterGen/populator/BushPopulator.php @@ -71,6 +71,6 @@ class BushPopulator extends AmountPopulator { } } - return $y++; + return ++$y; } } \ No newline at end of file diff --git a/src/Ad5001/BetterGen/populator/CactusPopulator.php b/src/Ad5001/BetterGen/populator/CactusPopulator.php index cc7b7c7..bc0b114 100644 --- a/src/Ad5001/BetterGen/populator/CactusPopulator.php +++ b/src/Ad5001/BetterGen/populator/CactusPopulator.php @@ -65,6 +65,6 @@ class CactusPopulator extends AmountPopulator { break; } } - return $y === 0 ? - 1 : $y++; + return $y === 0 ? - 1 : ++$y; } } \ No newline at end of file diff --git a/src/Ad5001/BetterGen/populator/CavePopulator.php b/src/Ad5001/BetterGen/populator/CavePopulator.php index 60682a8..c68e3a8 100644 --- a/src/Ad5001/BetterGen/populator/CavePopulator.php +++ b/src/Ad5001/BetterGen/populator/CavePopulator.php @@ -75,7 +75,7 @@ class CavePopulator extends AmountPopulator { } } - return $y++; + return ++$y; } /* diff --git a/src/Ad5001/BetterGen/populator/DeadbushPopulator.php b/src/Ad5001/BetterGen/populator/DeadbushPopulator.php index dee8bc2..67a3536 100644 --- a/src/Ad5001/BetterGen/populator/DeadbushPopulator.php +++ b/src/Ad5001/BetterGen/populator/DeadbushPopulator.php @@ -56,6 +56,6 @@ class DeadbushPopulator extends AmountPopulator { break; } } - return $y === 0 ? - 1 : $y++; + return $y === 0 ? - 1 : ++$y; } } \ No newline at end of file diff --git a/src/Ad5001/BetterGen/populator/FallenTreePopulator.php b/src/Ad5001/BetterGen/populator/FallenTreePopulator.php index be8bd58..a8caa04 100644 --- a/src/Ad5001/BetterGen/populator/FallenTreePopulator.php +++ b/src/Ad5001/BetterGen/populator/FallenTreePopulator.php @@ -1,10 +1,10 @@ setBaseAmount(1); $this->setRandomAmount(2); } - + /* * Populate the chunk * @param $level pocketmine\level\ChunkManager @@ -46,7 +46,9 @@ class FallenTreePopulator extends AmountPopulator { $this->level = $level; $amount = $this->getAmount($random); $tree = TreePopulator::$types[$this->type]; - $fallenTree = new FallenTree(new $tree()); + $fallenTree = new \Ad5001\BetterGen\structure\FallenTree( + new $tree() + ); for($i = 0; $i < $amount; $i++) { $x = $random->nextRange($chunkX * 16, $chunkX * 16 + 15); $z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15); @@ -56,11 +58,12 @@ class FallenTreePopulator extends AmountPopulator { } } } - - /* + + /** * Gets the top block (y) on an x and z axes - * @param $x int - * @param $z int + * @param $x + * @param $z + * @return int */ protected function getHighestWorkableBlock($x, $z) { for($y = Level::Y_MAX; $y >= 0; -- $y) { @@ -69,6 +72,6 @@ class FallenTreePopulator extends AmountPopulator { break; } } - return $y === 0 ? - 1 : $y++; + return $y === 0 ? - 1 : ++$y; } } \ No newline at end of file diff --git a/src/Ad5001/BetterGen/populator/FloatingIslandPopulator.php b/src/Ad5001/BetterGen/populator/FloatingIslandPopulator.php index 3c2a600..3a8f239 100644 --- a/src/Ad5001/BetterGen/populator/FloatingIslandPopulator.php +++ b/src/Ad5001/BetterGen/populator/FloatingIslandPopulator.php @@ -78,7 +78,7 @@ class FloatingIslandPopulator extends AmountPopulator { } } - return $y++; + return ++$y; } @@ -89,7 +89,7 @@ class FloatingIslandPopulator extends AmountPopulator { * @param $pos pocketmine\math\Vector3 * @param $radius int * @param $random pocketmine\utils\Random - * @return void + * @return int lowest ore point */ public function buildIslandBottomShape(ChunkManager $level, Vector3 $pos, int $radius, Random $random) { $pos = $pos->round(); @@ -122,13 +122,13 @@ class FloatingIslandPopulator extends AmountPopulator { $oldHB = $hBound; $hBound = $random->nextFloat(); if($current >= $currentLen + $hBound) { - if($radius == 0) return; + if($radius == 0) return $pos->y; $current = 0; $currentLen += 0.3 * ($random->nextFloat() + 0.5); $radius--; } } - //return $pos->y - 1 - $y;//void + return $pos->y - 1 - $y; } diff --git a/src/Ad5001/BetterGen/populator/IglooPopulator.php b/src/Ad5001/BetterGen/populator/IglooPopulator.php index b49cf60..db76366 100644 --- a/src/Ad5001/BetterGen/populator/IglooPopulator.php +++ b/src/Ad5001/BetterGen/populator/IglooPopulator.php @@ -58,6 +58,6 @@ class IglooPopulator extends AmountPopulator { } } - return $y++; + return ++$y; } } \ No newline at end of file diff --git a/src/Ad5001/BetterGen/populator/LakePopulator.php b/src/Ad5001/BetterGen/populator/LakePopulator.php index ee2194f..021aa1a 100644 --- a/src/Ad5001/BetterGen/populator/LakePopulator.php +++ b/src/Ad5001/BetterGen/populator/LakePopulator.php @@ -67,6 +67,6 @@ class LakePopulator extends AmountPopulator { } } - return $y++; + return ++$y; } } \ No newline at end of file diff --git a/src/Ad5001/BetterGen/populator/RavinePopulator.php b/src/Ad5001/BetterGen/populator/RavinePopulator.php index ac75a31..05e49c2 100644 --- a/src/Ad5001/BetterGen/populator/RavinePopulator.php +++ b/src/Ad5001/BetterGen/populator/RavinePopulator.php @@ -84,7 +84,7 @@ class RavinePopulator extends AmountPopulator { } } - return $y++; + return ++$y; } /* diff --git a/src/Ad5001/BetterGen/populator/SugarCanePopulator.php b/src/Ad5001/BetterGen/populator/SugarCanePopulator.php index 1241835..07c1ddf 100644 --- a/src/Ad5001/BetterGen/populator/SugarCanePopulator.php +++ b/src/Ad5001/BetterGen/populator/SugarCanePopulator.php @@ -64,6 +64,6 @@ class SugarCanePopulator extends AmountPopulator { break; } } - return $y === 0 ? - 1 : $y++; + return $y === 0 ? - 1 : ++$y; } } \ No newline at end of file diff --git a/src/Ad5001/BetterGen/populator/TemplePopulator.php b/src/Ad5001/BetterGen/populator/TemplePopulator.php index cad160a..a1016ce 100644 --- a/src/Ad5001/BetterGen/populator/TemplePopulator.php +++ b/src/Ad5001/BetterGen/populator/TemplePopulator.php @@ -56,6 +56,6 @@ class TemplePopulator extends AmountPopulator { } } - return $y++; + return ++$y; } } \ No newline at end of file diff --git a/src/Ad5001/BetterGen/populator/TreePopulator.php b/src/Ad5001/BetterGen/populator/TreePopulator.php index e5f93ec..5954b93 100644 --- a/src/Ad5001/BetterGen/populator/TreePopulator.php +++ b/src/Ad5001/BetterGen/populator/TreePopulator.php @@ -86,6 +86,6 @@ class TreePopulator extends AmountPopulator { } } - return $y++; + return ++$y; } } \ No newline at end of file diff --git a/src/Ad5001/BetterGen/populator/WellPopulator.php b/src/Ad5001/BetterGen/populator/WellPopulator.php index 5555b33..5a867f3 100644 --- a/src/Ad5001/BetterGen/populator/WellPopulator.php +++ b/src/Ad5001/BetterGen/populator/WellPopulator.php @@ -56,6 +56,6 @@ class WellPopulator extends AmountPopulator { } } - return $y++; + return ++$y; } } \ No newline at end of file diff --git a/src/Ad5001/BetterGen/structure/FallenTree.php b/src/Ad5001/BetterGen/structure/FallenTree.php index 661a4c8..1847dbc 100644 --- a/src/Ad5001/BetterGen/structure/FallenTree.php +++ b/src/Ad5001/BetterGen/structure/FallenTree.php @@ -18,7 +18,7 @@ use Ad5001\BetterGen\utils\BuildingUtils; use pocketmine\block\Block; use pocketmine\level\ChunkManager; use pocketmine\level\generator\object\Object; -use pocketmine\level\generator\object\Tree; +use pocketmine\level\generator\object\Tree as ObjectTree; use pocketmine\math\Vector3; use pocketmine\utils\Random; @@ -36,18 +36,17 @@ class FallenTree extends Object { Block::LEAVES2 => true, Block::CACTUS => true ]; - /** @var Tree */ protected $tree; protected $direction; protected $random; - private $length; + private $length = 0; /* * Constructs the class - * @param $tree Tree - * @throws Exception + * @param $tree ObjectTree + * @throws Exeption */ - public function __construct(Tree $tree) { + public function __construct(ObjectTree $tree) { $this->tree = $tree; } @@ -61,14 +60,15 @@ class FallenTree extends Object { */ public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) { $randomHeight = round($random->nextBoundedInt(6) - 3); - $this->length = $this->tree->trunkHeight + $randomHeight; + $this->length = ($this->tree->trunkHeight??5) + $randomHeight; $this->direction = $random->nextBoundedInt(4); $this->random = $random; switch ($this->direction) { case 0: case 1:// Z+ if (in_array(false, BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x, $y, $z + $this->length), function ($v3, ChunkManager $level) { - if (!in_array($level->getBlockIdAt($v3->x, $v3->y, $v3->z), $this->overridable)) return false; else return true; + if (!in_array($level->getBlockIdAt($v3->x, $v3->y, $v3->z), $this->overridable)) return false; + else return true; }, $level))) { return false; } @@ -76,7 +76,8 @@ class FallenTree extends Object { case 2: case 3: // X+ if (in_array(false, BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x + $this->length, $y, $z), function ($v3, ChunkManager $level) { - if (!in_array($level->getBlockIdAt($v3->x, $v3->y, $v3->z), $this->overridable)) return false; else return true; + if (!in_array($level->getBlockIdAt($v3->x, $v3->y, $v3->z), $this->overridable)) return false; + else return true; }, $level))) { return false; } @@ -136,7 +137,7 @@ class FallenTree extends Object { */ public function placeBlock($x, $y, $z, ChunkManager $level) { if (isset($this->overridable [$level->getBlockIdAt($x, $y, $z)]) && !isset($this->overridable [$level->getBlockIdAt($x, $y - 1, $z)])) { - $level->setBlockIdAt($x, $y, $z, $this->tree->trunkBlock); + $level->setBlockIdAt($x, $y, $z, $this->tree->leafBlock); $level->setBlockDataAt($x, $y, $z, $this->tree->type); } } diff --git a/src/Ad5001/BetterGen/structure/SakuraTree.php b/src/Ad5001/BetterGen/structure/SakuraTree.php index f67d56a..9c89c5a 100644 --- a/src/Ad5001/BetterGen/structure/SakuraTree.php +++ b/src/Ad5001/BetterGen/structure/SakuraTree.php @@ -569,7 +569,7 @@ class SakuraTree extends Tree { $sideLen = $totalLength ** 2; // Side length //TODO CHECK WHAT THIS IS SUPPOSED TO BE - $numForward = 0; + $numForward = $sideLen; //TODO END $lX1 = $lZ1 = $lX = $lZ = 0; From a7b8469c9ca037c20d842d46da927c0a279c9044 Mon Sep 17 00:00:00 2001 From: thebigsmileXD Date: Thu, 11 May 2017 16:41:42 +0200 Subject: [PATCH 5/8] Fix generation issues --- .../BetterGen/generator/BetterNormal.php | 2 +- .../BetterGen/populator/BushPopulator.php | 2 +- .../BetterGen/populator/CactusPopulator.php | 2 +- .../BetterGen/populator/CavePopulator.php | 2 +- .../BetterGen/populator/DeadbushPopulator.php | 29 ++++++++++++------- .../populator/FallenTreePopulator.php | 11 ++++--- .../populator/FloatingIslandPopulator.php | 2 +- .../BetterGen/populator/IglooPopulator.php | 2 +- .../BetterGen/populator/LakePopulator.php | 2 +- .../BetterGen/populator/RavinePopulator.php | 2 +- .../populator/SugarCanePopulator.php | 2 +- .../BetterGen/populator/TemplePopulator.php | 2 +- .../BetterGen/populator/TreePopulator.php | 2 +- .../BetterGen/populator/WellPopulator.php | 2 +- src/Ad5001/BetterGen/structure/SakuraTree.php | 3 +- src/Ad5001/BetterGen/structure/Temple.php | 17 ++++++----- 16 files changed, 47 insertions(+), 37 deletions(-) diff --git a/src/Ad5001/BetterGen/generator/BetterNormal.php b/src/Ad5001/BetterGen/generator/BetterNormal.php index be0936a..70c914c 100644 --- a/src/Ad5001/BetterGen/generator/BetterNormal.php +++ b/src/Ad5001/BetterGen/generator/BetterNormal.php @@ -438,7 +438,7 @@ class BetterNormal extends Generator { * @param $z int */ protected function getHighestWorkableBlock($x, $z) { - for($y = Level::Y_MAX; $y > 0; -- $y) { + for($y = Level::Y_MAX - 1; $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 6c58765..c1363cb 100644 --- a/src/Ad5001/BetterGen/populator/BushPopulator.php +++ b/src/Ad5001/BetterGen/populator/BushPopulator.php @@ -62,7 +62,7 @@ class BushPopulator extends AmountPopulator { * @param $z int */ protected function getHighestWorkableBlock($x, $z) { - for($y = Level::Y_MAX; $y > 0; -- $y) { + for($y = Level::Y_MAX - 1; $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 bc0b114..9a2e28d 100644 --- a/src/Ad5001/BetterGen/populator/CactusPopulator.php +++ b/src/Ad5001/BetterGen/populator/CactusPopulator.php @@ -59,7 +59,7 @@ class CactusPopulator extends AmountPopulator { * @param $z int */ protected function getHighestWorkableBlock($x, $z) { - for($y = Level::Y_MAX; $y >= 0; -- $y) { + for($y = Level::Y_MAX - 1; $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 c68e3a8..feb31a1 100644 --- a/src/Ad5001/BetterGen/populator/CavePopulator.php +++ b/src/Ad5001/BetterGen/populator/CavePopulator.php @@ -66,7 +66,7 @@ class CavePopulator extends AmountPopulator { * @param $z int */ protected function getHighestWorkableBlock($x, $z) { - for($y = Level::Y_MAX; $y > 0; -- $y) { + for($y = Level::Y_MAX - 1; $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 67a3536..0859a69 100644 --- a/src/Ad5001/BetterGen/populator/DeadbushPopulator.php +++ b/src/Ad5001/BetterGen/populator/DeadbushPopulator.php @@ -14,8 +14,10 @@ namespace Ad5001\BetterGen\populator; +use Ad5001\BetterGen\generator\BetterBiomeSelector; use pocketmine\block\Block; use pocketmine\level\ChunkManager; +use pocketmine\level\generator\biome\Biome; use pocketmine\level\Level; use pocketmine\utils\Random; @@ -36,26 +38,31 @@ class DeadbushPopulator extends AmountPopulator { for($i = 0; $i < $amount; $i++) { $x = $random->nextRange($chunkX * 16, $chunkX * 16 + 15); $z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15); + if(!in_array($level->getChunk($chunkX, $chunkZ)->getBiomeId(abs($x % 16), ($z % 16)), [40, 39, Biome::DESERT])) continue; $y = $this->getHighestWorkableBlock($x, $z); - if ($y !== -1 && $level->getBlockIdAt($x, $y - 1, $z ) == Block::SAND) { - $level->setBlockIdAt($x, $y + 1, $z, Block::DEAD_BUSH); - $level->setBlockDataAt($x, $y + 1, $z, 1); + if ($y !== -1) { + $level->setBlockIdAt($x, $y, $z, Block::DEAD_BUSH); + $level->setBlockDataAt($x, $y, $z, 1); } } } - - /* + + /** * Gets the top block (y) on an x and z axes - * @param $x int - * @param $z int + * @param $x + * @param $z + * @return int */ - protected function getHighestWorkableBlock($x, $z) { - for($y = Level::Y_MAX; $y >= 0; -- $y) { + private function getHighestWorkableBlock($x, $z){ + for($y = Level::Y_MAX - 1; $y > 0; --$y){ $b = $this->level->getBlockIdAt($x, $y, $z); - if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) { + if($b === Block::DIRT or $b === Block::GRASS or $b === Block::SAND or $b === Block::SANDSTONE or $b === Block::HARDENED_CLAY or $b === Block::STAINED_HARDENED_CLAY){ break; + }elseif($b !== Block::AIR){ + return -1; } } - return $y === 0 ? - 1 : ++$y; + + return ++$y; } } \ No newline at end of file diff --git a/src/Ad5001/BetterGen/populator/FallenTreePopulator.php b/src/Ad5001/BetterGen/populator/FallenTreePopulator.php index a8caa04..9570d19 100644 --- a/src/Ad5001/BetterGen/populator/FallenTreePopulator.php +++ b/src/Ad5001/BetterGen/populator/FallenTreePopulator.php @@ -65,13 +65,16 @@ class FallenTreePopulator extends AmountPopulator { * @param $z * @return int */ - protected function getHighestWorkableBlock($x, $z) { - for($y = Level::Y_MAX; $y >= 0; -- $y) { + private function getHighestWorkableBlock($x, $z){ + for($y = Level::Y_MAX - 1; $y > 0; --$y){ $b = $this->level->getBlockIdAt($x, $y, $z); - if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) { + if($b === Block::DIRT or $b === Block::GRASS){ break; + }elseif($b !== Block::AIR and $b !== Block::SNOW_LAYER){ + return -1; } } - return $y === 0 ? - 1 : ++$y; + + return ++$y; } } \ No newline at end of file diff --git a/src/Ad5001/BetterGen/populator/FloatingIslandPopulator.php b/src/Ad5001/BetterGen/populator/FloatingIslandPopulator.php index 3a8f239..f3e06b0 100644 --- a/src/Ad5001/BetterGen/populator/FloatingIslandPopulator.php +++ b/src/Ad5001/BetterGen/populator/FloatingIslandPopulator.php @@ -69,7 +69,7 @@ class FloatingIslandPopulator extends AmountPopulator { * @param $z int */ protected function getHighestWorkableBlock($x, $z) { - for($y = Level::Y_MAX; $y > 0; -- $y) { + for($y = Level::Y_MAX - 1; $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; diff --git a/src/Ad5001/BetterGen/populator/IglooPopulator.php b/src/Ad5001/BetterGen/populator/IglooPopulator.php index db76366..352763c 100644 --- a/src/Ad5001/BetterGen/populator/IglooPopulator.php +++ b/src/Ad5001/BetterGen/populator/IglooPopulator.php @@ -49,7 +49,7 @@ class IglooPopulator extends AmountPopulator { * @param $z int */ protected function getHighestWorkableBlock($x, $z) { - for($y = Level::Y_MAX; $y > 0; -- $y) { + for($y = Level::Y_MAX - 1; $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 021aa1a..1462379 100644 --- a/src/Ad5001/BetterGen/populator/LakePopulator.php +++ b/src/Ad5001/BetterGen/populator/LakePopulator.php @@ -58,7 +58,7 @@ class LakePopulator extends AmountPopulator { * @param $z int */ protected function getHighestWorkableBlock($x, $z) { - for($y = Level::Y_MAX; $y > 0; -- $y) { + for($y = Level::Y_MAX - 1; $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 05e49c2..d278bf0 100644 --- a/src/Ad5001/BetterGen/populator/RavinePopulator.php +++ b/src/Ad5001/BetterGen/populator/RavinePopulator.php @@ -75,7 +75,7 @@ class RavinePopulator extends AmountPopulator { * @param $z int */ protected function getHighestWorkableBlock($x, $z) { - for($y = Level::Y_MAX; $y > 0; -- $y) { + for($y = Level::Y_MAX - 1; $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 07c1ddf..b027d20 100644 --- a/src/Ad5001/BetterGen/populator/SugarCanePopulator.php +++ b/src/Ad5001/BetterGen/populator/SugarCanePopulator.php @@ -58,7 +58,7 @@ class SugarCanePopulator extends AmountPopulator { * @param $z int */ protected function getHighestWorkableBlock($x, $z) { - for($y = Level::Y_MAX; $y >= 0; -- $y) { + for($y = Level::Y_MAX - 1; $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 a1016ce..36b0147 100644 --- a/src/Ad5001/BetterGen/populator/TemplePopulator.php +++ b/src/Ad5001/BetterGen/populator/TemplePopulator.php @@ -49,7 +49,7 @@ class TemplePopulator extends AmountPopulator { * @param $z int */ protected function getHighestWorkableBlock($x, $z) { - for($y = Level::Y_MAX; $y > 0; -- $y) { + for($y = Level::Y_MAX - 1; $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 5954b93..b85470a 100644 --- a/src/Ad5001/BetterGen/populator/TreePopulator.php +++ b/src/Ad5001/BetterGen/populator/TreePopulator.php @@ -77,7 +77,7 @@ class TreePopulator extends AmountPopulator { * @param $z int */ protected function getHighestWorkableBlock($x, $z) { - for($y = Level::Y_MAX; $y > 0; -- $y) { + for($y = Level::Y_MAX - 1; $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 5a867f3..33e2aa0 100644 --- a/src/Ad5001/BetterGen/populator/WellPopulator.php +++ b/src/Ad5001/BetterGen/populator/WellPopulator.php @@ -49,7 +49,7 @@ class WellPopulator extends AmountPopulator { * @param $z int */ protected function getHighestWorkableBlock($x, $z) { - for($y = Level::Y_MAX; $y > 0; -- $y) { + for($y = Level::Y_MAX - 1; $y > 0; -- $y) { $b = $this->level->getBlockIdAt($x, $y, $z); if ($b === Block::SAND) { break; diff --git a/src/Ad5001/BetterGen/structure/SakuraTree.php b/src/Ad5001/BetterGen/structure/SakuraTree.php index 9c89c5a..e855c3c 100644 --- a/src/Ad5001/BetterGen/structure/SakuraTree.php +++ b/src/Ad5001/BetterGen/structure/SakuraTree.php @@ -569,7 +569,7 @@ class SakuraTree extends Tree { $sideLen = $totalLength ** 2; // Side length //TODO CHECK WHAT THIS IS SUPPOSED TO BE - $numForward = $sideLen; + $numForward = ($totalLength % 2 == 0) ? $totalLength - 1 : $totalLength; //TODO END $lX1 = $lZ1 = $lX = $lZ = 0; @@ -589,7 +589,6 @@ class SakuraTree extends Tree { } // Second branch part. + second leave part - $numForward = ($totalLength % 2 == 0) ? $totalLength - 1 : $totalLength; for ($i = 1; $i < $stickLen + 1; $i++) { $lX = $lX1 + ($xd * $i); $lZ = $lZ1 + ($zd * $i); diff --git a/src/Ad5001/BetterGen/structure/Temple.php b/src/Ad5001/BetterGen/structure/Temple.php index d379db9..d719aef 100644 --- a/src/Ad5001/BetterGen/structure/Temple.php +++ b/src/Ad5001/BetterGen/structure/Temple.php @@ -14,13 +14,13 @@ namespace Ad5001\BetterGen\structure; -use Ad5001\BetterGen\loot\LootTable; -use Ad5001\BetterGen\utils\BuildingUtils; use pocketmine\block\Block; use pocketmine\level\ChunkManager; -use pocketmine\level\generator\object\Object; -use pocketmine\math\Vector3; use pocketmine\utils\Random; +use pocketmine\math\Vector3; +use pocketmine\level\generator\object\Object; +use Ad5001\BetterGen\loot\LootTable; +use Ad5001\BetterGen\utils\BuildingUtils; class Temple extends Object { const DIRECTION_PLUSX = 0; @@ -109,7 +109,6 @@ class Temple extends Object { 1 ] ]; - private $direction; /* * Checks if a temple is placeable @@ -172,7 +171,7 @@ class Temple extends Object { for($zz = $z - 1; $zz <= $z + 1; $zz ++) $this->placeBlock($xx, $yy, $zz, 0); - // Floor pattern + // Floor patern foreach($this->directions as $dir ) { // Building pillar for($yy = $y + 1; $yy <= $y + 3; $yy ++) @@ -183,6 +182,8 @@ class Temple extends Object { $this->placeBlock($x + ($dir [0] * 3), $y, $z, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x, $y, $z + ($dir [1] * 2), Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x, $y, $z + ($dir [1] * 3), Block::STAINED_HARDENED_CLAY, 1); + $this->placeBlock($x + ($dir [0] * 2), $yy, $z + ($dir [1]), Block::STAINED_HARDENED_CLAY, 1); + $this->placeBlock($x + ($dir [0]), $yy, $z + ($dir [1] * 2), Block::STAINED_HARDENED_CLAY, 1); // Sandstone $this->placeBlock($x + $dir [0], $y, $z); @@ -417,7 +418,7 @@ class Temple extends Object { } /* - * Places one of the towers. Out is inverted $direction1, stairs come from inverted $direction2 to $direction2, patterns are on $direction1 and $direction2 + * Places one of the towers. Out is inversed $direction1, stairs come from inversed $direction2 to $direction2, patterns are on $direction1 and $direction2 * @param $x int * @param $y int * @param $z int @@ -894,7 +895,7 @@ class Temple extends Object { * @param $direction int * @return int */ - protected function getInvertedDirection(int $direction): int { + protected function getInversedDirection(int $direction): int { switch ($direction) { case self::DIRECTION_PLUSX : // x+ (0) return self::DIRECTION_MINX; From 7ce51d546a1bbd3cf6391c066405976f55ebbed2 Mon Sep 17 00:00:00 2001 From: thebigsmileXD Date: Fri, 12 May 2017 09:01:46 +0200 Subject: [PATCH 6/8] Reformatting, Fix #2, temple debug command --- plugin.yml | 6 + src/Ad5001/BetterGen/Main.php | 205 ++--- src/Ad5001/BetterGen/structure/SakuraTree.php | 4 +- src/Ad5001/BetterGen/structure/Temple.php | 719 +++++++++--------- 4 files changed, 484 insertions(+), 450 deletions(-) diff --git a/plugin.yml b/plugin.yml index 8c90a65..5c857ff 100644 --- a/plugin.yml +++ b/plugin.yml @@ -23,9 +23,15 @@ commands: description: Teleports you to an another world usage: "/worldtp " permission: bettergen.cmd.worldtp + temple: + description: Spawns a temple for debugging + usage: "/temple" + permission: bettergen.cmd.debug permissions: bettergen.cmd.createworld: default: op bettergen.cmd.worldtp: default: op + bettergen.cmd.debug: + default: op ... \ No newline at end of file diff --git a/src/Ad5001/BetterGen/Main.php b/src/Ad5001/BetterGen/Main.php index ed72ce9..2dce547 100644 --- a/src/Ad5001/BetterGen/Main.php +++ b/src/Ad5001/BetterGen/Main.php @@ -1,10 +1,10 @@ getServer()->getPluginManager()->registerEvents($this, $this); - Generator::addGenerator(BetterNormal::class, "betternormal"); - if($this->isOtherNS()) $this->getLogger()->warning("Tesseract detected. Note that Tesseract is not up to date with the generation structure and some generation features may be limited or not working"); - @mkdir($this->getDataFolder()); - if(! file_exists(LootTable::getPluginFolder(). "processingLoots.json")) - file_put_contents(LootTable::getPluginFolder(). "processingLoots.json", "{}"); + + public static function registerBiome(int $id, Biome $biome) { + BetterNormal::registerBiome($biome); } - + /* * Called when the plugin disables */ - public function onDisable() { + + public function onEnable() { + $this->getServer()->getPluginManager()->registerEvents($this, $this); + Generator::addGenerator(BetterNormal::class, "betternormal"); + if ($this->isOtherNS()) $this->getLogger()->warning("Tesseract detected. Note that Tesseract is not up to date with the generation structure and some generation features may be limited or not working"); + @mkdir($this->getDataFolder()); + if (!file_exists(LootTable::getPluginFolder() . "processingLoots.json")) + file_put_contents(LootTable::getPluginFolder() . "processingLoots.json", "{}"); } - + /* * Called when one of the defined commands of the plugin has been called * @param $sender \pocketmine\command\CommandSender @@ -65,10 +72,37 @@ class Main extends PluginBase implements Listener { * @param $args array * return bool */ + + public static function isOtherNS() { + try { + return @class_exists("pocketmine\\level\\generator\\normal\\object\\OakTree"); + } catch (\Exception $e) { + return false; + } + } + + /* + * Registers a forest type. + * @param $name string + * @param $treeClass string + * @params $infos Array(temperature, rainfall) + * @return bool + */ + + public function onDisable() { + } + + /* + * Registers a biome for the normal generator. Normal means(Biome::register) doesn't allow biome to be generated + * @param $id int + * @param $biome Biome + * @return void + */ + public function onCommand(CommandSender $sender, Command $cmd, $label, array $args): bool { - switch($cmd->getName()) { + switch ($cmd->getName()) { case "createworld" : // /createworld [generator = betternormal] [seed = rand()] [options(json)] - switch(count($args)) { + switch (count($args)) { case 0 : return false; break; @@ -77,50 +111,50 @@ class Main extends PluginBase implements Listener { $generator = Generator::getGenerator("betternormal"); $generatorName = "betternormal"; $seed = $this->generateRandomSeed(); - $options = [ ]; + $options = []; break; case 2 : // /createworld [generator = betternormal] $name = $args [0]; $generator = Generator::getGenerator($args [1]); - if(Generator::getGeneratorName($generator) !== strtolower($args [1])) { + if (Generator::getGeneratorName($generator) !== strtolower($args [1])) { $sender->sendMessage(self::PREFIX . "§4Could not find generator {$args[1]}. Are you sure it is registered?"); return true; } $generatorName = strtolower($args [1]); $seed = $this->generateRandomSeed(); - $options = [ ]; + $options = []; break; case 3 : // /createworld [generator = betternormal] [seed = rand()] $name = $args [0]; $generator = Generator::getGenerator($args [1]); - if(Generator::getGeneratorName($generator) !== strtolower($args [1])) { + if (Generator::getGeneratorName($generator) !== strtolower($args [1])) { $sender->sendMessage(self::PREFIX . "§4Could not find generator {$args[1]}. Are you sure it is registered?"); return true; } $generatorName = strtolower($args [1]); - if(preg_match("[^\d]", $args [2]) !== false) { + if (preg_match("[^\d]", $args [2]) !== false) { $parts = str_split($args [2]); - foreach($parts as $key => $str) { + foreach ($parts as $key => $str) { $parts [$key] = ord($str); } $seed = implode("", $parts); } else { $seed = $args [2]; } - $options = [ ]; + $options = []; break; default : // /createworld [generator = betternormal] [seed = rand()] [options(json)] $name = $args [0]; $generator = Generator::getGenerator($args [1]); - if(Generator::getGeneratorName($generator) !== strtolower($args [1])) { + if (Generator::getGeneratorName($generator) !== strtolower($args [1])) { $sender->sendMessage(self::PREFIX . "§4Could not find generator {$args[1]}. Are you sure it is registered?"); return true; } $generatorName = strtolower($args [1]); - if($args[2] == "rand") $args[2] = $this->generateRandomSeed(); - if(preg_match("[^\d]", $args [2]) !== false) { + if ($args[2] == "rand") $args[2] = $this->generateRandomSeed(); + if (preg_match("[^\d]", $args [2]) !== false) { $parts = str_split($args [2]); - foreach($parts as $key => $str) { + foreach ($parts as $key => $str) { $parts [$key] = ord($str); } $seed = implode("", $parts); @@ -129,14 +163,14 @@ class Main extends PluginBase implements Listener { } unset($args [0], $args [1], $args [2]); $options = json_decode($args [3], true); - if(! is_array($options)) { + if (!is_array($options)) { $sender->sendMessage(Main::PREFIX . "§4Invalid JSON for options."); return true; } break; } $options["preset"] = json_encode($options); - if((int) $seed == 0/*String*/){ + if ((int)$seed == 0/*String*/) { $seed = $this->generateRandomSeed(); } $this->getServer()->broadcastMessage(Main::PREFIX . "§aGenerating level $name with generator $generatorName and seed $seed.."); @@ -144,57 +178,54 @@ class Main extends PluginBase implements Listener { $this->getServer()->loadLevel($name); return true; break; + case 'temple':{ + if($sender instanceof ConsoleCommandSender) return false; + /** @var Player $sender */ + $temple = new Temple(); + $temple->placeObject($sender->getLevel(), $sender->x, $sender->y, $sender->z, new Random()); + return true; + } } return false; } - - /* - * Registers a forest type. - * @param $name string - * @param $treeClass string - * @params $infos Array(temperature, rainfall) - * @return bool - */ - public function registerForest(string $name, string $treeClass, array $infos): bool { - if(! @class_exists($treeClass)) - return false; - if(! @is_subclass_of($treeClass, "pocketmine\\level\\generator\\normal\\object\\Tree")) - return false; - if(count($infos) < 2 or ! is_float($infos [0]) or ! is_float($infos [1])) - return false; - return BetterForest::registerForest($name, $treeClass, $infos); - } - - /* - * Registers a biome for the normal generator. Normal means(Biome::register) doesn't allow biome to be generated - * @param $id int - * @param $biome Biome - * @return void - */ - public static function registerBiome(int $id, Biome $biome) { - BetterNormal::registerBiome($biome); - } - + /* * Generates a(semi) random seed. * @return int */ + public function generateRandomSeed(): int { - return (int) round(rand(0, round(time()) / memory_get_usage(true)) * (int) str_shuffle("127469453645108") / (int) str_shuffle("12746945364")); + return (int)round(rand(0, round(time()) / memory_get_usage(true)) * (int)str_shuffle("127469453645108") / (int)str_shuffle("12746945364")); } - + // Listener - + /* * Checks after a chunk populates so we an add tiles and loot tables * @param $event pocketmine\event\level\ChunkPopulateEvent * @return int */ + + public function registerForest(string $name, string $treeClass, array $infos): bool { + if (!@class_exists($treeClass)) + return false; + if (!@is_subclass_of($treeClass, "pocketmine\\level\\generator\\normal\\object\\Tree")) + return false; + if (count($infos) < 2 or !is_float($infos [0]) or !is_float($infos [1])) + return false; + return BetterForest::registerForest($name, $treeClass, $infos); + } + + + /* + * Checks when a player interacts with a loot chest to create it. + */ + public function onChunkPopulate(ChunkPopulateEvent $event) { $cfg = new Config(LootTable::getPluginFolder() . "processingLoots.json", Config::JSON); - foreach($cfg->getAll() as $key => $value) { + foreach ($cfg->getAll() as $key => $value) { list($x, $y, $z) = explode(";", $key); - if($value["saveAs"] == "chest" && $event->getLevel()->getBlockIdAt($x, $y, $z) == Block::AIR ){ + if ($value["saveAs"] == "chest" && $event->getLevel()->getBlockIdAt($x, $y, $z) == Block::AIR) { $event->getLevel()->setBlockIdAt($x, $y, $z, Block::CHEST); } else { $cfg->remove($key); @@ -202,36 +233,38 @@ class Main extends PluginBase implements Listener { } } } - - + + /* - * Checks when a player interacts with a loot chest to create it. + * Checks when a player breaks a loot chest which is not created to create it */ + public function onInteract(PlayerInteractEvent $event) { $cfg = new Config(LootTable::getPluginFolder() . "processingLoots.json", Config::JSON); - if($event->getBlock()->getId() !== Block::CHEST) return; - if(!$cfg->exists($event->getBlock()->getX() . ";" . $event->getBlock()->getY() . ";" . $event->getBlock()->getZ())) return; + if ($event->getBlock()->getId() !== Block::CHEST) return; + if (!$cfg->exists($event->getBlock()->getX() . ";" . $event->getBlock()->getY() . ";" . $event->getBlock()->getZ())) return; $nbt = new CompoundTag("", [ - new ListTag("Items", []), - new StringTag("id", Tile::CHEST), - new IntTag("x", $event->getBlock()->x), - new IntTag("y", $event->getBlock()->y), - new IntTag("z", $event->getBlock()->z) + new ListTag("Items", []), + new StringTag("id", Tile::CHEST), + new IntTag("x", $event->getBlock()->x), + new IntTag("y", $event->getBlock()->y), + new IntTag("z", $event->getBlock()->z) ]); /** @var Chest $chest */ $chest = Tile::createTile(Tile::CHEST, $event->getBlock()->getLevel(), $nbt); $chest->setName("§k(Fake)§r Minecart chest"); LootTable::fillChest($chest->getInventory(), $event->getBlock()); } - - + /* - * Checks when a player breaks a loot chest which is not created to create it - */ + * Check if it's a Tesseract like namespace + * @return bool + */ + public function onBlockBreak(BlockBreakEvent $event) { $cfg = new Config(LootTable::getPluginFolder() . "processingLoots.json", Config::JSON); - if($event->getBlock()->getId() !== Block::CHEST) return; - if(!$cfg->exists($event->getBlock()->getX() . ";" . $event->getBlock()->getY() . ";" . $event->getBlock()->getZ())) return; + if ($event->getBlock()->getId() !== Block::CHEST) return; + if (!$cfg->exists($event->getBlock()->getX() . ";" . $event->getBlock()->getY() . ";" . $event->getBlock()->getZ())) return; $nbt = new CompoundTag("", [ new ListTag("Items", []), new StringTag("id", Tile::CHEST), @@ -245,16 +278,4 @@ class Main extends PluginBase implements Listener { LootTable::fillChest($chest->getInventory(), $event->getBlock()); // $event->setCancelled(); //i think nope. You want to break it with items } - - /* - * Check if it's a Tesseract like namespace - * @return bool - */ - public static function isOtherNS() { - try { - return @class_exists("pocketmine\\level\\generator\\normal\\object\\OakTree"); - } catch(\Exception $e) { - return false; - } - } } diff --git a/src/Ad5001/BetterGen/structure/SakuraTree.php b/src/Ad5001/BetterGen/structure/SakuraTree.php index e855c3c..0e41259 100644 --- a/src/Ad5001/BetterGen/structure/SakuraTree.php +++ b/src/Ad5001/BetterGen/structure/SakuraTree.php @@ -442,8 +442,8 @@ class SakuraTree extends Tree { public $trunkHeight = 11; - private $leafType; - private $leaf2Type; + public $leafType; + public $leaf2Type; /* * Constructs the class diff --git a/src/Ad5001/BetterGen/structure/Temple.php b/src/Ad5001/BetterGen/structure/Temple.php index d719aef..4ad1e18 100644 --- a/src/Ad5001/BetterGen/structure/Temple.php +++ b/src/Ad5001/BetterGen/structure/Temple.php @@ -1,10 +1,10 @@ true, + Block::SAPLING => true, + Block::LOG => true, + Block::LEAVES => true, + Block::STONE => true, + Block::DANDELION => true, + Block::POPPY => true, + Block::SNOW_LAYER => true, + Block::LOG2 => true, + Block::LEAVES2 => true, + Block::CACTUS => true + ]; + protected $directions = [ + [ + 1, + 1 + ], + [ + 1, + -1 + ], + [ + -1, + -1 + ], + [ + -1, + 1 + ] ]; /** @var ChunkManager */ private $level; - public $overridable = [ - Block::AIR => true, - 6 => true, - 17 => true, - 18 => true, - Block::DANDELION => true, - Block::POPPY => true, - Block::SNOW_LAYER => true, - Block::LOG2 => true, - Block::LEAVES2 => true, - Block::CACTUS => true - ]; - protected $directions = [ - [ - 1, - 1 - ], - [ - 1, - - 1 - ], - [ - - 1, - - 1 - ], - [ - - 1, - 1 - ] - ]; + private $direction = 0; /* * Checks if a temple is placeable @@ -119,17 +121,18 @@ class Temple extends Object { * @param $random pocketmine\utils\Random * @return bool */ + public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) { $this->level = $level; $this->direction = $random->nextBoundedInt(4); - for($xx = $x - 10; $xx <= $x + 10; $xx ++) - for($yy = $y + 1; $yy <= $y + 11; $yy ++) - for($zz = $z - 10; $zz <= $z + 10; $zz ++) - if (! isset($this->overridable [$level->getBlockIdAt($xx, $yy, $zz )] )) + for ($xx = $x - 10; $xx <= $x + 10; $xx++) + for ($yy = $y + 1; $yy <= $y + 11; $yy++) + for ($zz = $z - 10; $zz <= $z + 10; $zz++) + if (!isset($this->overridable [$level->getBlockIdAt($xx, $yy, $zz)])) return false; return true; } - + /* * Places a temple * @param $level pocketmine\level\ChunkManager @@ -140,41 +143,41 @@ class Temple extends Object { */ public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) { // Clearing space... - BuildingUtils::fill($level, new Vector3($x + 10, $y + 1, $z + 10 ), new Vector3($x - 10, $y + 2, $z - 10 ), Block::get(Block::AIR )); + BuildingUtils::fill($level, new Vector3($x + 10, $y + 1, $z + 10), new Vector3($x - 10, $y + 2, $z - 10), Block::get(Block::AIR)); // First, build a pyramid. $this->level = $level; $firstPos = new Vector3($x + 10, $y, $z + 10); $sndPos = new Vector3($x - 10, $y, $z - 10); - for($i = 0; $i <= 9; $i ++) { + for ($i = 0; $i <= 9; $i++) { // Building sides - BuildingUtils::walls($level, $firstPos, $sndPos, Block::get(Block::SANDSTONE )); - + BuildingUtils::walls($level, $firstPos, $sndPos, Block::get(Block::SANDSTONE)); + // Next floor - $firstPos->x --; - $firstPos->z --; + $firstPos->x--; + $firstPos->z--; $firstPos->y = $y + $i; - $sndPos->x ++; - $sndPos->z ++; + $sndPos->x++; + $sndPos->z++; $sndPos->y = $y + $i; } // Floors - for($xx = $x + 9; $xx >= $x - 9; $xx --) - for($zz = $z + 9; $zz >= $z - 9; $zz --) + for ($xx = $x + 9; $xx >= $x - 9; $xx--) + for ($zz = $z + 9; $zz >= $z - 9; $zz--) $this->placeBlock($xx, $y, $zz); - for($xx = $x + 5; $xx >= $x - 5; $xx --) - for($zz = $z + 5; $zz >= $z - 5; $zz --) + for ($xx = $x + 5; $xx >= $x - 5; $xx--) + for ($zz = $z + 5; $zz >= $z - 5; $zz--) $this->placeBlock($xx, $y + 4, $zz); - + // Creating hole - for($xx = $x - 1; $xx <= $x + 1; $xx ++) - for($yy = $y - 11; $yy <= $y + 4; $yy ++) - for($zz = $z - 1; $zz <= $z + 1; $zz ++) + for ($xx = $x - 1; $xx <= $x + 1; $xx++) + for ($yy = $y - 11; $yy <= $y + 4; $yy++) + for ($zz = $z - 1; $zz <= $z + 1; $zz++) $this->placeBlock($xx, $yy, $zz, 0); - + // Floor patern - foreach($this->directions as $dir ) { + foreach ($this->directions as $dir) { // Building pillar - for($yy = $y + 1; $yy <= $y + 3; $yy ++) + for ($yy = $y + 1; $yy <= $y + 3; $yy++) $this->placeBlock($x + ($dir [0] * 2), $yy, $z + ($dir [1] * 2), Block::SANDSTONE, 2); // Orange hardened clay $this->placeBlock($x + $dir [0], $y, $z + $dir [1], Block::STAINED_HARDENED_CLAY, 1); @@ -184,7 +187,7 @@ class Temple extends Object { $this->placeBlock($x, $y, $z + ($dir [1] * 3), Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + ($dir [0] * 2), $yy, $z + ($dir [1]), Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + ($dir [0]), $yy, $z + ($dir [1] * 2), Block::STAINED_HARDENED_CLAY, 1); - + // Sandstone $this->placeBlock($x + $dir [0], $y, $z); $this->placeBlock($x, $y, $z + $dir [1]); @@ -192,54 +195,54 @@ class Temple extends Object { // Blue hardened clay (center) $this->placeBlock($x, $y, $z, Block::STAINED_HARDENED_CLAY, 11); // Hole walls - BuildingUtils::walls($level, new Vector3($x - 2, $y, $z - 2 ), new Vector3($x + 2, $y - 8, $z + 2 ), Block::get(Block::SANDSTONE )); - + BuildingUtils::walls($level, new Vector3($x - 2, $y, $z - 2), new Vector3($x + 2, $y - 8, $z + 2), Block::get(Block::SANDSTONE)); + // Last step like this - for($xx = $x - 2; $xx <= $x + 2; $xx ++) { + for ($xx = $x - 2; $xx <= $x + 2; $xx++) { $this->placeBlock($xx, $y - 9, $z - 2, Block::SANDSTONE, 2); $this->placeBlock($xx, $y - 9, $z + 2, Block::SANDSTONE, 2); } - for($zz = $z - 2; $zz <= $z + 2; $zz ++) { + for ($zz = $z - 2; $zz <= $z + 2; $zz++) { $this->placeBlock($x - 2, $y - 9, $zz, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y - 9, $zz, Block::SANDSTONE, 2); } - - foreach(self::THREE_DIAGS as $diagPos ) { + + foreach (self::THREE_DIAGS as $diagPos) { $this->placeBlock($x + $diagPos [0], $y - 10, $z + $diagPos [1], Block::SANDSTONE, 1); $this->placeBlock($x + $diagPos [0], $y - 11, $z + $diagPos [1], Block::SANDSTONE, 2); } - + // Floor + TNT - for($xx = $x - 2; $xx <= $x + 2; $xx ++) - for($zz = $z - 2; $zz <= $z + 2; $zz ++) + for ($xx = $x - 2; $xx <= $x + 2; $xx++) + for ($zz = $z - 2; $zz <= $z + 2; $zz++) $this->placeBlock($xx, $y - 12, $zz, Block::SANDSTONE, 2); - for($xx = $x - 1; $xx <= $x + 1; $xx ++) - for($zz = $z - 1; $zz <= $z + 1; $zz ++) + for ($xx = $x - 1; $xx <= $x + 1; $xx++) + for ($zz = $z - 1; $zz <= $z + 1; $zz++) $this->placeBlock($xx, $y - 13, $zz, Block::TNT); $this->placeBlock($x, $y - 11, $z, Block::STONE_PRESSURE_PLATE); - + // Chests - LootTable::buildLootTable(new Vector3($x, $y - 11, $z + 2 ), LootTable::LOOT_DESERT_TEMPLE, $random); - LootTable::buildLootTable(new Vector3($x, $y - 11, $z - 2 ), LootTable::LOOT_DESERT_TEMPLE, $random); - LootTable::buildLootTable(new Vector3($x + 2, $y - 11, $z ), LootTable::LOOT_DESERT_TEMPLE, $random); - LootTable::buildLootTable(new Vector3($x - 2, $y - 11, $z ), LootTable::LOOT_DESERT_TEMPLE, $random); - + LootTable::buildLootTable(new Vector3($x, $y - 11, $z + 2), LootTable::LOOT_DESERT_TEMPLE, $random); + LootTable::buildLootTable(new Vector3($x, $y - 11, $z - 2), LootTable::LOOT_DESERT_TEMPLE, $random); + LootTable::buildLootTable(new Vector3($x + 2, $y - 11, $z), LootTable::LOOT_DESERT_TEMPLE, $random); + LootTable::buildLootTable(new Vector3($x - 2, $y - 11, $z), LootTable::LOOT_DESERT_TEMPLE, $random); + // Entrance is a rectangular parallelepiped switch ($this->direction) { case self::DIRECTION_PLUSX : // x+ (0) - // Building towers. + // Building towers. $this->placeTower($x + 8, $y, $z + 8, self::DIRECTION_PLUSX, self::DIRECTION_PLUSZ); $this->placeTower($x + 8, $y, $z - 8, self::DIRECTION_PLUSX, self::DIRECTION_MINZ); // Creating rectangular parallelepiped of sandstone. - BuildingUtils::fill($level, new Vector3($x + 6, $y + 1, $z - 6 ), new Vector3($x + 9, $y + 4, $z + 6 ), Block::get(Block::SANDSTONE )); + BuildingUtils::fill($level, new Vector3($x + 6, $y + 1, $z - 6), new Vector3($x + 9, $y + 4, $z + 6), Block::get(Block::SANDSTONE)); // Creating a path to the entrance - BuildingUtils::fill($level, new Vector3($x + 6, $y + 1, $z - 1 ), new Vector3($x + 9, $y + 4, $z + 1 ), Block::get(Block::AIR )); + BuildingUtils::fill($level, new Vector3($x + 6, $y + 1, $z - 1), new Vector3($x + 9, $y + 4, $z + 1), Block::get(Block::AIR)); // Creating path to towers. - for($yy = $y + 1; $yy <= $y + 2; $yy ++) - for($zz = $z - 6; $zz <= $z + 6; $zz ++) + for ($yy = $y + 1; $yy <= $y + 2; $yy++) + for ($zz = $z - 6; $zz <= $z + 6; $zz++) $this->placeBlock($x + 8, $yy, $zz, 0); // Door additional blocks - for($yy = $y + 1; $yy <= $y + 4; $yy ++) { + for ($yy = $y + 1; $yy <= $y + 4; $yy++) { $this->placeBlock($x + 6, $yy, $z - 2); $this->placeBlock($x + 6, $yy, $z + 2); // Polished entrance @@ -251,40 +254,40 @@ class Temple extends Object { } // Finishing entrance structure $this->placeBlock($x + 9, $y + 3, $z, Block::SANDSTONE, 2); - for($zz = $z - 2; $zz <= $z + 2; $zz ++) + for ($zz = $z - 2; $zz <= $z + 2; $zz++) $this->placeBlock($x + 10, $y + 4, $zz, Block::SANDSTONE, 2); $this->placeBlock($x + 10, $y + 5, $z, Block::SANDSTONE, 1); $this->placeBlock($x + 10, $y + 5, $z - 1, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + 10, $y + 5, $z + 1, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + 10, $y + 5, $z - 2, Block::SANDSTONE, 2); $this->placeBlock($x + 10, $y + 5, $z + 2, Block::SANDSTONE, 2); - for($zz = $z - 1; $zz <= $z + 1; $zz ++) + for ($zz = $z - 1; $zz <= $z + 1; $zz++) $this->placeBlock($x + 10, $y + 6, $zz, Block::SANDSTONE, 2); - for($xx = $x + 6; $xx <= $x + 9; $xx ++) - for($zz = $z - 2; $zz <= $z + 2; $zz ++) + for ($xx = $x + 6; $xx <= $x + 9; $xx++) + for ($zz = $z - 2; $zz <= $z + 2; $zz++) $this->placeBlock($xx, $y + 4, $zz); break; - + case self::DIRECTION_MINX : // x- (1) - // Building towers. + // Building towers. $this->placeTower($x - 8, $y, $z + 8, self::DIRECTION_MINX, self::DIRECTION_PLUSZ); $this->placeTower($x - 8, $y, $z - 8, self::DIRECTION_MINX, self::DIRECTION_MINZ); // Creating rectangular parallelepiped of sandstone. - for($xx = $x - 6; $xx >= $x - 9; $xx --) - for($yy = $y + 1; $yy <= $y + 4; $yy ++) - for($zz = $z - 6; $zz <= $z + 6; $zz ++) + for ($xx = $x - 6; $xx >= $x - 9; $xx--) + for ($yy = $y + 1; $yy <= $y + 4; $yy++) + for ($zz = $z - 6; $zz <= $z + 6; $zz++) $this->placeBlock($xx, $yy, $zz); // Creating a path to the entrance - for($xx = $x - 6; $xx >= $x - 9; $xx --) - for($yy = $y + 1; $yy <= $y + 4; $yy ++) - for($zz = $z - 1; $zz <= $z + 1; $zz ++) + for ($xx = $x - 6; $xx >= $x - 9; $xx--) + for ($yy = $y + 1; $yy <= $y + 4; $yy++) + for ($zz = $z - 1; $zz <= $z + 1; $zz++) $this->placeBlock($xx, $yy, $zz, 0); // Creating path to towers. - for($yy = $y + 1; $yy <= $y + 2; $yy ++) - for($zz = $z - 6; $zz <= $z + 6; $zz ++) + for ($yy = $y + 1; $yy <= $y + 2; $yy++) + for ($zz = $z - 6; $zz <= $z + 6; $zz++) $this->placeBlock($x - 8, $yy, $zz, 0); // Door additional blocks - for($yy = $y + 1; $yy <= $y + 4; $yy ++) { + for ($yy = $y + 1; $yy <= $y + 4; $yy++) { $this->placeBlock($x - 6, $yy, $z - 2); $this->placeBlock($x - 6, $yy, $z + 2); // Polished entrance @@ -296,35 +299,35 @@ class Temple extends Object { } // Finishing entrance structure $this->placeBlock($x - 9, $y + 3, $z, Block::SANDSTONE, 2); - for($zz = $z - 2; $zz <= $z + 2; $zz ++) + for ($zz = $z - 2; $zz <= $z + 2; $zz++) $this->placeBlock($x - 10, $y + 4, $zz, Block::SANDSTONE, 2); $this->placeBlock($x - 10, $y + 5, $z, Block::SANDSTONE, 1); $this->placeBlock($x - 10, $y + 5, $z - 1, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 10, $y + 5, $z + 1, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 10, $y + 5, $z - 2, Block::SANDSTONE, 2); $this->placeBlock($x - 10, $y + 5, $z + 2, Block::SANDSTONE, 2); - for($zz = $z - 1; $zz <= $z + 1; $zz ++) + for ($zz = $z - 1; $zz <= $z + 1; $zz++) $this->placeBlock($x - 10, $y + 6, $zz, Block::SANDSTONE, 2); - for($xx = $x - 6; $xx >= $x - 9; $xx --) - for($zz = $z - 2; $zz <= $z + 2; $zz ++) + for ($xx = $x - 6; $xx >= $x - 9; $xx--) + for ($zz = $z - 2; $zz <= $z + 2; $zz++) $this->placeBlock($xx, $y + 4, $zz); break; - + case self::DIRECTION_PLUSZ : // z+ (2) - // Building towers. + // Building towers. $this->placeTower($x + 8, $y, $z + 8, self::DIRECTION_PLUSZ, self::DIRECTION_PLUSX); $this->placeTower($x - 8, $y, $z + 8, self::DIRECTION_PLUSZ, self::DIRECTION_MINX); // Creating rectangular parallelepiped of sandstone. - BuildingUtils::fill($level, new Vector3($x - 6, $y + 1, $z + 6 ), new Vector3($x + 6, $y + 4, $z + 9 ), Block::get(Block::SANDSTONE )); + BuildingUtils::fill($level, new Vector3($x - 6, $y + 1, $z + 6), new Vector3($x + 6, $y + 4, $z + 9), Block::get(Block::SANDSTONE)); // Creating a path to the entrance - for($xx = $x - 1; $xx <= $x + 1; $xx ++) - for($yy = $y + 1; $yy <= $y + 4; $yy ++) - for($zz = $z + 6; $zz <= $z + 9; $zz ++) + for ($xx = $x - 1; $xx <= $x + 1; $xx++) + for ($yy = $y + 1; $yy <= $y + 4; $yy++) + for ($zz = $z + 6; $zz <= $z + 9; $zz++) $this->placeBlock($xx, $yy, $zz, 0); // Creating path to towers. - BuildingUtils::fill($level, new Vector3($x - 1, $y + 1, $z + 6 ), new Vector3($x + 1, $y + 4, $z + 9 ), Block::get(Block::AIR )); + BuildingUtils::fill($level, new Vector3($x - 1, $y + 1, $z + 6), new Vector3($x + 1, $y + 4, $z + 9), Block::get(Block::AIR)); // Door additional blocks - for($yy = $y + 1; $yy <= $y + 4; $yy ++) { + for ($yy = $y + 1; $yy <= $y + 4; $yy++) { $this->placeBlock($x - 2, $yy, $z + 6); $this->placeBlock($x + 2, $yy, $z + 6); // Polished entrance @@ -336,34 +339,34 @@ class Temple extends Object { } // Finishing entrance structure $this->placeBlock($x, $y + 3, $z + 9, Block::SANDSTONE, 2); - for($xx = $x - 2; $xx <= $x + 2; $xx ++) + for ($xx = $x - 2; $xx <= $x + 2; $xx++) $this->placeBlock($xx, $y + 4, $z + 10, Block::SANDSTONE, 2); $this->placeBlock($x, $y + 5, $z + 10, Block::SANDSTONE, 1); $this->placeBlock($x - 1, $y + 5, $z + 10, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + 1, $y + 5, $z + 10, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 2, $y + 5, $z + 10, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y + 5, $z + 10, Block::SANDSTONE, 2); - for($xx = $x - 1; $xx <= $x + 1; $xx ++) + for ($xx = $x - 1; $xx <= $x + 1; $xx++) $this->placeBlock($xx, $y + 6, $z + 10, Block::SANDSTONE, 2); - for($zz = $z + 6; $zz <= $z + 9; $zz ++) - for($xx = $x - 2; $xx <= $x + 2; $xx ++) + for ($zz = $z + 6; $zz <= $z + 9; $zz++) + for ($xx = $x - 2; $xx <= $x + 2; $xx++) $this->placeBlock($xx, $y + 4, $zz); break; - + case self::DIRECTION_MINZ : // z- (3) - // Building towers. + // Building towers. $this->placeTower($x + 8, $y, $z - 8, self::DIRECTION_MINZ, self::DIRECTION_PLUSX); $this->placeTower($x - 8, $y, $z - 8, self::DIRECTION_MINZ, self::DIRECTION_MINX); // Creating rectangular parallelepiped of sandstone. - BuildingUtils::fill($level, new Vector3($x - 6, $y + 1, $z - 6 ), new Vector3($x + 6, $y + 4, $z - 9 ), Block::get(Block::SANDSTONE )); + BuildingUtils::fill($level, new Vector3($x - 6, $y + 1, $z - 6), new Vector3($x + 6, $y + 4, $z - 9), Block::get(Block::SANDSTONE)); // Creating a path to the entrance - BuildingUtils::fill($level, new Vector3($x - 1, $y + 1, $z - 6 ), new Vector3($x + 1, $y + 4, $z - 9 ), Block::get(Block::AIR )); + BuildingUtils::fill($level, new Vector3($x - 1, $y + 1, $z - 6), new Vector3($x + 1, $y + 4, $z - 9), Block::get(Block::AIR)); // Creating path to towers. - for($yy = $y + 1; $yy <= $y + 2; $yy ++) - for($xx = $x - 6; $xx <= $x + 6; $xx ++) + for ($yy = $y + 1; $yy <= $y + 2; $yy++) + for ($xx = $x - 6; $xx <= $x + 6; $xx++) $this->placeBlock($xx, $yy, $z - 8, 0); // Door additional blocks - for($yy = $y + 1; $yy <= $y + 4; $yy ++) { + for ($yy = $y + 1; $yy <= $y + 4; $yy++) { $this->placeBlock($x - 2, $yy, $z - 6); $this->placeBlock($x + 2, $yy, $z - 6); // Polished entrance @@ -375,22 +378,22 @@ class Temple extends Object { } // Finishing entrance structure $this->placeBlock($x, $y + 3, $z - 9, Block::SANDSTONE, 2); - for($xx = $x - 2; $xx <= $x + 2; $xx ++) + for ($xx = $x - 2; $xx <= $x + 2; $xx++) $this->placeBlock($xx, $y + 4, $z - 10, Block::SANDSTONE, 2); $this->placeBlock($x, $y + 5, $z - 10, Block::SANDSTONE, 1); $this->placeBlock($x - 1, $y + 5, $z - 10, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + 1, $y + 5, $z - 10, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 2, $y + 5, $z - 10, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y + 5, $z - 10, Block::SANDSTONE, 2); - for($xx = $x - 1; $xx <= $x + 1; $xx ++) + for ($xx = $x - 1; $xx <= $x + 1; $xx++) $this->placeBlock($xx, $y + 6, $z - 10, Block::SANDSTONE, 2); - for($zz = $z - 6; $zz >= $z - 9; $zz --) - for($xx = $x - 2; $xx <= $x + 2; $xx ++) + for ($zz = $z - 6; $zz >= $z - 9; $zz--) + for ($xx = $x - 2; $xx <= $x + 2; $xx++) $this->placeBlock($xx, $y + 4, $zz); break; } } - + /* * Places a slab * @param $x int @@ -398,11 +401,12 @@ class Temple extends Object { * @param $z int * @return void */ - protected function placeSlab($x, $y, $z) { - $this->level->setBlockIdAt($x, $y, $z, 44); - $this->level->setBlockDataAt($x, $y, $z, 1); + + protected function placeBlock($x, $y, $z, $id = Block::SANDSTONE, $meta = 0) { + $this->level->setBlockIdAt($x, $y, $z, $id); + $this->level->setBlockDataAt($x, $y, $z, $meta); } - + /* * Places a slab * @param $x int @@ -412,28 +416,15 @@ class Temple extends Object { * @param $meta int * @return void */ - protected function placeBlock($x, $y, $z, $id = Block::SANDSTONE, $meta = 0) { - $this->level->setBlockIdAt($x, $y, $z, $id); - $this->level->setBlockDataAt($x, $y, $z, $meta); - } - - /* - * Places one of the towers. Out is inversed $direction1, stairs come from inversed $direction2 to $direction2, patterns are on $direction1 and $direction2 - * @param $x int - * @param $y int - * @param $z int - * @param $direction1 int - * @param $direction2 int - * @return void - */ + public function placeTower($x, $y, $z, $direction1 = self::DIRECTION_PLUSX, $direction2 = self::DIRECTION_PLUSZ) { - BuildingUtils::walls($this->level, new Vector3($x + 2, $y, $z + 2 ), new Vector3($x - 2, $y + 8, $z - 2 ), Block::get(Block::SANDSTONE )); + BuildingUtils::walls($this->level, new Vector3($x + 2, $y, $z + 2), new Vector3($x - 2, $y + 8, $z - 2), Block::get(Block::SANDSTONE)); switch ($direction1) { case self::DIRECTION_PLUSX : // x+ (0) - // Stairs + // Stairs switch ($direction2) { case self::DIRECTION_PLUSZ : - for($zz = $z + 1; $zz >= $z; $zz --) { + for ($zz = $z + 1; $zz >= $z; $zz--) { $this->placeBlock($x - 1, $y + 1, $zz); $this->placeBlock($x - 1, $y + 2, $zz); } @@ -441,19 +432,19 @@ class Temple extends Object { $this->placeBlock($x, $y + 1, $z + 1); $this->placeSlab($x, $y + 2, $z + 1); // Pattern - foreach([ - 1, - 2, - 4 - ] as $h ) { + foreach ([ + 1, + 2, + 4 + ] as $h) { $this->placeBlock($x - 1, $y + $h, $z + 2, Block::SANDSTONE, 2); $this->placeBlock($x + 1, $y + $h, $z + 2, Block::SANDSTONE, 2); $this->placeBlock($x, $y + $h, $z + 2, Block::STAINED_HARDENED_CLAY, 1); } - foreach([ - 3, - 5 - ] as $h ) { + foreach ([ + 3, + 5 + ] as $h) { $this->placeBlock($x - 1, $y + $h, $z + 2, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + 1, $y + $h, $z + 2, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x, $y + $h, $z + 2, Block::SANDSTONE, 1); @@ -464,13 +455,13 @@ class Temple extends Object { $this->placeBlock($x - 1, $y + 7, $z + 2, Block::SANDSTONE, 2); $this->placeBlock($x, $y + 7, $z + 2, Block::SANDSTONE, 2); $this->placeBlock($x + 1, $y + 7, $z + 2, Block::SANDSTONE, 2); - + // Building entrance to second floor. - BuildingUtils::fill($this->level, new Vector3($x - 9, $y + 5, $z - 4 ), new Vector3($x - 7, $y + 7, $z - 5 ), Block::get(Block::SANDSTONE, 2 )); - BuildingUtils::fill($this->level, new Vector3($x - 8, $y + 5, $z - 4 ), new Vector3($x - 8, $y + 6, $z - 5 ), Block::get(Block::AIR )); + BuildingUtils::fill($this->level, new Vector3($x - 9, $y + 5, $z - 4), new Vector3($x - 7, $y + 7, $z - 5), Block::get(Block::SANDSTONE, 2)); + BuildingUtils::fill($this->level, new Vector3($x - 8, $y + 5, $z - 4), new Vector3($x - 8, $y + 6, $z - 5), Block::get(Block::AIR)); break; case self::DIRECTION_MINZ : - for($zz = $z - 1; $zz <= $z; $zz ++) { + for ($zz = $z - 1; $zz <= $z; $zz++) { $this->placeBlock($x - 1, $y + 1, $zz); $this->placeBlock($x - 1, $y + 2, $zz); } @@ -478,19 +469,19 @@ class Temple extends Object { $this->placeBlock($x, $y + 1, $z - 1); $this->placeSlab($x, $y + 2, $z - 1); // Pattern - foreach([ - 1, - 2, - 4 - ] as $h ) { + foreach ([ + 1, + 2, + 4 + ] as $h) { $this->placeBlock($x - 1, $y + $h, $z - 2, Block::SANDSTONE, 2); $this->placeBlock($x + 1, $y + $h, $z - 2, Block::SANDSTONE, 2); $this->placeBlock($x, $y + $h, $z - 2, Block::STAINED_HARDENED_CLAY, 1); } - foreach([ - 3, - 5 - ] as $h ) { + foreach ([ + 3, + 5 + ] as $h) { $this->placeBlock($x - 1, $y + $h, $z - 2, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + 1, $y + $h, $z - 2, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x, $y + $h, $z - 2, Block::SANDSTONE, 1); @@ -505,8 +496,8 @@ class Temple extends Object { } // Building entrance to second floor. - BuildingUtils::fill($this->level, new Vector3($x - 9, $y + 5, $z + 4 ), new Vector3($x - 7, $y + 7, $z + 5 ), Block::get(Block::SANDSTONE, 2 )); - BuildingUtils::fill($this->level, new Vector3($x - 8, $y + 5, $z + 4 ), new Vector3($x - 8, $y + 6, $z + 5 ), Block::get(Block::AIR )); + BuildingUtils::fill($this->level, new Vector3($x - 9, $y + 5, $z + 4), new Vector3($x - 7, $y + 7, $z + 5), Block::get(Block::SANDSTONE, 2)); + BuildingUtils::fill($this->level, new Vector3($x - 8, $y + 5, $z + 4), new Vector3($x - 8, $y + 6, $z + 5), Block::get(Block::AIR)); // Finishing stairs system $this->placeBlock($x - 2, $y + 3, $z, Block::SANDSTONE_STAIRS, 1); @@ -515,22 +506,22 @@ class Temple extends Object { $this->placeBlock($x - 2, $y + 5, $z, Block::AIR); $this->placeBlock($x - 2, $y + 6, $z, Block::AIR); // Making path from stairs to first floor. - BuildingUtils::fill($this->level, new Vector3($x - 4, $y, $z + 2 ), new Vector3($x - 9, $y + 4, $z - 2 ), Block::get(Block::SANDSTONE )); - + BuildingUtils::fill($this->level, new Vector3($x - 4, $y, $z + 2), new Vector3($x - 9, $y + 4, $z - 2), Block::get(Block::SANDSTONE)); + // Other side pattern - foreach([ - 1, - 2, - 4 - ] as $h ) { + foreach ([ + 1, + 2, + 4 + ] as $h) { $this->placeBlock($x + 2, $y + $h, $z + 1, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y + $h, $z - 1, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y + $h, $z, Block::STAINED_HARDENED_CLAY, 1); } - foreach([ - 3, - 5 - ] as $h ) { + foreach ([ + 3, + 5 + ] as $h) { $this->placeBlock($x + 2, $y + $h, $z - 1, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + 2, $y + $h, $z + 1, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + 2, $y + $h, $z, Block::SANDSTONE, 1); @@ -542,12 +533,12 @@ class Temple extends Object { $this->placeBlock($x + 2, $y + 7, $z, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y + 7, $z + 1, Block::SANDSTONE, 2); break; - + case self::DIRECTION_MINX : // x- (1) - // Stairs + // Stairs switch ($direction2) { case self::DIRECTION_PLUSZ : - for($zz = $z + 1; $zz >= $z; $zz --) { + for ($zz = $z + 1; $zz >= $z; $zz--) { $this->placeBlock($x + 1, $y + 1, $zz); $this->placeBlock($x + 1, $y + 2, $zz); } @@ -555,19 +546,19 @@ class Temple extends Object { $this->placeBlock($x, $y + 1, $z + 1); $this->placeSlab($x, $y + 2, $z + 1); // Pattern - foreach([ - 1, - 2, - 4 - ] as $h ) { + foreach ([ + 1, + 2, + 4 + ] as $h) { $this->placeBlock($x + 1, $y + $h, $z + 2, Block::SANDSTONE, 2); $this->placeBlock($x - 1, $y + $h, $z + 2, Block::SANDSTONE, 2); $this->placeBlock($x, $y + $h, $z + 2, Block::STAINED_HARDENED_CLAY, 1); } - foreach([ - 3, - 5 - ] as $h ) { + foreach ([ + 3, + 5 + ] as $h) { $this->placeBlock($x + 1, $y + $h, $z + 2, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 1, $y + $h, $z + 2, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x, $y + $h, $z + 2, Block::SANDSTONE, 1); @@ -578,13 +569,13 @@ class Temple extends Object { $this->placeBlock($x - 1, $y + 7, $z + 2, Block::SANDSTONE, 2); $this->placeBlock($x, $y + 7, $z + 2, Block::SANDSTONE, 2); $this->placeBlock($x + 1, $y + 7, $z + 2, Block::SANDSTONE, 2); - + // Building entrance to second floor. - BuildingUtils::fill($this->level, new Vector3($x + 9, $y + 5, $z - 4 ), new Vector3($x + 7, $y + 7, $z - 5 ), Block::get(Block::SANDSTONE, 2 )); - BuildingUtils::fill($this->level, new Vector3($x + 8, $y + 5, $z - 4 ), new Vector3($x + 8, $y + 6, $z - 5 ), Block::get(Block::AIR )); + BuildingUtils::fill($this->level, new Vector3($x + 9, $y + 5, $z - 4), new Vector3($x + 7, $y + 7, $z - 5), Block::get(Block::SANDSTONE, 2)); + BuildingUtils::fill($this->level, new Vector3($x + 8, $y + 5, $z - 4), new Vector3($x + 8, $y + 6, $z - 5), Block::get(Block::AIR)); break; case self::DIRECTION_MINZ : - for($zz = $z - 1; $zz <= $z; $zz ++) { + for ($zz = $z - 1; $zz <= $z; $zz++) { $this->placeBlock($x + 1, $y + 1, $zz); $this->placeBlock($x + 1, $y + 2, $zz); } @@ -592,19 +583,19 @@ class Temple extends Object { $this->placeBlock($x, $y + 1, $z - 1); $this->placeSlab($x, $y + 2, $z - 1); // Pattern - foreach([ - 1, - 2, - 4 - ] as $h ) { + foreach ([ + 1, + 2, + 4 + ] as $h) { $this->placeBlock($x + 1, $y + $h, $z - 2, Block::SANDSTONE, 2); $this->placeBlock($x - 1, $y + $h, $z - 2, Block::SANDSTONE, 2); $this->placeBlock($x, $y + $h, $z - 2, Block::STAINED_HARDENED_CLAY, 1); } - foreach([ - 3, - 5 - ] as $h ) { + foreach ([ + 3, + 5 + ] as $h) { $this->placeBlock($x + 1, $y + $h, $z - 2, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 1, $y + $h, $z - 2, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x, $y + $h, $z - 2, Block::SANDSTONE, 1); @@ -615,13 +606,13 @@ class Temple extends Object { $this->placeBlock($x - 1, $y + 6, $z - 2, Block::SANDSTONE, 2); $this->placeBlock($x, $y + 6, $z - 2, Block::SANDSTONE, 2); $this->placeBlock($x + 1, $y + 6, $z - 2, Block::SANDSTONE, 2); - + // Building entrance to second floor. - BuildingUtils::fill($this->level, new Vector3($x + 9, $y + 5, $z + 4 ), new Vector3($x + 7, $y + 7, $z + 5 ), Block::get(Block::SANDSTONE, 2 )); - BuildingUtils::fill($this->level, new Vector3($x + 8, $y + 5, $z + 4 ), new Vector3($x + 8, $y + 6, $z + 5 ), Block::get(Block::AIR )); + BuildingUtils::fill($this->level, new Vector3($x + 9, $y + 5, $z + 4), new Vector3($x + 7, $y + 7, $z + 5), Block::get(Block::SANDSTONE, 2)); + BuildingUtils::fill($this->level, new Vector3($x + 8, $y + 5, $z + 4), new Vector3($x + 8, $y + 6, $z + 5), Block::get(Block::AIR)); break; } - + // Finishing stairs system $this->placeBlock($x + 2, $y + 3, $z, Block::SANDSTONE_STAIRS, 0); $this->placeBlock($x + 3, $y + 4, $z, Block::SANDSTONE_STAIRS, 0); @@ -629,22 +620,22 @@ class Temple extends Object { $this->placeBlock($x + 2, $y + 5, $z, Block::AIR); $this->placeBlock($x + 2, $y + 6, $z, Block::AIR); // Making path from stairs to first floor. - BuildingUtils::fill($this->level, new Vector3($x + 4, $y, $z + 2 ), new Vector3($x + 9, $y + 4, $z - 2 ), Block::get(Block::SANDSTONE )); - + BuildingUtils::fill($this->level, new Vector3($x + 4, $y, $z + 2), new Vector3($x + 9, $y + 4, $z - 2), Block::get(Block::SANDSTONE)); + // Other side pattern - foreach([ - 1, - 2, - 4 - ] as $h ) { + foreach ([ + 1, + 2, + 4 + ] as $h) { $this->placeBlock($x - 2, $y + $h, $z + 1, Block::SANDSTONE, 2); $this->placeBlock($x - 2, $y + $h, $z - 1, Block::SANDSTONE, 2); $this->placeBlock($x - 2, $y + $h, $z, Block::STAINED_HARDENED_CLAY, 1); } - foreach([ - 3, - 5 - ] as $h ) { + foreach ([ + 3, + 5 + ] as $h) { $this->placeBlock($x - 2, $y + $h, $z - 1, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 2, $y + $h, $z + 1, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 2, $y + $h, $z, Block::SANDSTONE, 1); @@ -656,12 +647,12 @@ class Temple extends Object { $this->placeBlock($x - 2, $y + 7, $z, Block::SANDSTONE, 2); $this->placeBlock($x - 2, $y + 7, $z + 1, Block::SANDSTONE, 2); break; - + case self::DIRECTION_PLUSZ : // z+ (2) - // Stairs + // Stairs switch ($direction2) { case self::DIRECTION_PLUSX : - for($xx = $x + 1; $xx >= $x; $xx --) { + for ($xx = $x + 1; $xx >= $x; $xx--) { $this->placeBlock($xx, $y + 1, $z - 1); $this->placeBlock($xx, $y + 2, $z - 1); } @@ -669,19 +660,19 @@ class Temple extends Object { $this->placeBlock($x + 1, $y + 1, $z); $this->placeSlab($x + 1, $y + 2, $z); // Pattern - foreach([ - 1, - 2, - 4 - ] as $h ) { + foreach ([ + 1, + 2, + 4 + ] as $h) { $this->placeBlock($x + 2, $y + $h, $z + 1, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y + $h, $z - 1, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y + $h, $z, Block::STAINED_HARDENED_CLAY, 1); } - foreach([ - 3, - 5 - ] as $h ) { + foreach ([ + 3, + 5 + ] as $h) { $this->placeBlock($x + 2, $y + $h, $z + 1, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + 2, $y + $h, $z - 1, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + 2, $y + $h, $z, Block::SANDSTONE, 1); @@ -693,11 +684,11 @@ class Temple extends Object { $this->placeBlock($x + 2, $y + 7, $z, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y + 7, $z + 1, Block::SANDSTONE, 2); // Building entrance to second floor. - BuildingUtils::fill($this->level, new Vector3($x - 4, $y + 5, $z - 9 ), new Vector3($x - 5, $y + 7, $z - 7 ), Block::get(Block::SANDSTONE, 2 )); - BuildingUtils::fill($this->level, new Vector3($x - 4, $y + 5, $z - 8 ), new Vector3($x - 5, $y + 6, $z - 8 ), Block::get(Block::AIR )); + BuildingUtils::fill($this->level, new Vector3($x - 4, $y + 5, $z - 9), new Vector3($x - 5, $y + 7, $z - 7), Block::get(Block::SANDSTONE, 2)); + BuildingUtils::fill($this->level, new Vector3($x - 4, $y + 5, $z - 8), new Vector3($x - 5, $y + 6, $z - 8), Block::get(Block::AIR)); break; case self::DIRECTION_MINX : - for($xx = $x - 1; $xx <= $x; $xx ++) { + for ($xx = $x - 1; $xx <= $x; $xx++) { $this->placeBlock($xx, $y + 1, $z - 1); $this->placeBlock($xx, $y + 2, $z - 1); } @@ -705,19 +696,19 @@ class Temple extends Object { $this->placeBlock($x - 1, $y + 1, $z); $this->placeSlab($x - 1, $y + 2, $z); // Pattern - foreach([ - 1, - 2, - 4 - ] as $h ) { + foreach ([ + 1, + 2, + 4 + ] as $h) { $this->placeBlock($x - 2, $y + $h, $z - 1, Block::SANDSTONE, 2); $this->placeBlock($x - 2, $y + $h, $z + 1, Block::SANDSTONE, 2); $this->placeBlock($x - 2, $y + $h, $z, Block::STAINED_HARDENED_CLAY, 1); } - foreach([ - 3, - 5 - ] as $h ) { + foreach ([ + 3, + 5 + ] as $h) { $this->placeBlock($x - 2, $y + $h, $z - 1, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 2, $y + $h, $z + 1, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 2, $y + $h, $z, Block::SANDSTONE, 1); @@ -729,11 +720,11 @@ class Temple extends Object { $this->placeBlock($x - 2, $y + 7, $z, Block::SANDSTONE, 2); $this->placeBlock($x - 2, $y + 7, $z + 1, Block::SANDSTONE, 2); // Building entrance to second floor. - BuildingUtils::fill($this->level, new Vector3($x + 4, $y + 5, $z - 9 ), new Vector3($x + 5, $y + 7, $z - 7 ), Block::get(Block::SANDSTONE, 2 )); - BuildingUtils::fill($this->level, new Vector3($x + 4, $y + 5, $z - 8 ), new Vector3($x + 5, $y + 6, $z - 8 ), Block::get(Block::AIR )); + BuildingUtils::fill($this->level, new Vector3($x + 4, $y + 5, $z - 9), new Vector3($x + 5, $y + 7, $z - 7), Block::get(Block::SANDSTONE, 2)); + BuildingUtils::fill($this->level, new Vector3($x + 4, $y + 5, $z - 8), new Vector3($x + 5, $y + 6, $z - 8), Block::get(Block::AIR)); break; } - + // Finishing stairs system $this->placeBlock($x, $y + 3, $z - 2, Block::SANDSTONE_STAIRS, 3); $this->placeBlock($x, $y + 4, $z - 3, Block::SANDSTONE_STAIRS, 3); @@ -741,22 +732,22 @@ class Temple extends Object { $this->placeBlock($x, $y + 5, $z - 2, Block::AIR); $this->placeBlock($x, $y + 6, $z - 2, Block::AIR); // Making path from stairs to first floor. - BuildingUtils::fill($this->level, new Vector3($x + 2, $y, $z - 4 ), new Vector3($x - 2, $y + 4, $z - 9 ), Block::get(Block::SANDSTONE )); - + BuildingUtils::fill($this->level, new Vector3($x + 2, $y, $z - 4), new Vector3($x - 2, $y + 4, $z - 9), Block::get(Block::SANDSTONE)); + // Other side pattern - foreach([ - 1, - 2, - 4 - ] as $h ) { + foreach ([ + 1, + 2, + 4 + ] as $h) { $this->placeBlock($x + 1, $y + $h, $z + 2, Block::SANDSTONE, 2); $this->placeBlock($x - 1, $y + $h, $z + 2, Block::SANDSTONE, 2); $this->placeBlock($x, $y + $h, $z + 2, Block::STAINED_HARDENED_CLAY, 1); } - foreach([ - 3, - 5 - ] as $h ) { + foreach ([ + 3, + 5 + ] as $h) { $this->placeBlock($x + 1, $y + $h, $z + 2, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 1, $y + $h, $z + 2, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x, $y + $h, $z + 2, Block::SANDSTONE, 1); @@ -768,12 +759,12 @@ class Temple extends Object { $this->placeBlock($x, $y + 7, $z + 2, Block::SANDSTONE, 2); $this->placeBlock($x + 1, $y + 7, $z + 2, Block::SANDSTONE, 2); break; - + case self::DIRECTION_MINZ : // z- (3) - // Stairs + // Stairs switch ($direction2) { case self::DIRECTION_PLUSX : - for($xx = $x + 1; $xx >= $x; $xx --) { + for ($xx = $x + 1; $xx >= $x; $xx--) { $this->placeBlock($xx, $y + 1, $z + 1); $this->placeBlock($xx, $y + 2, $z + 1); } @@ -781,19 +772,19 @@ class Temple extends Object { $this->placeBlock($x + 1, $y + 1, $z); $this->placeSlab($x + 1, $y + 2, $z); // Pattern - foreach([ - 1, - 2, - 4 - ] as $h ) { + foreach ([ + 1, + 2, + 4 + ] as $h) { $this->placeBlock($x + 2, $y + $h, $z + 1, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y + $h, $z - 1, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y + $h, $z, Block::STAINED_HARDENED_CLAY, 1); } - foreach([ - 3, - 5 - ] as $h ) { + foreach ([ + 3, + 5 + ] as $h) { $this->placeBlock($x + 2, $y + $h, $z + 1, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + 2, $y + $h, $z - 1, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + 2, $y + $h, $z, Block::SANDSTONE, 1); @@ -805,11 +796,11 @@ class Temple extends Object { $this->placeBlock($x + 2, $y + 7, $z, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y + 7, $z + 1, Block::SANDSTONE, 2); // Building entrance to second floor. - BuildingUtils::fill($this->level, new Vector3($x - 4, $y + 5, $z + 9 ), new Vector3($x - 5, $y + 7, $z + 7 ), Block::get(Block::SANDSTONE, 2 )); - BuildingUtils::fill($this->level, new Vector3($x - 4, $y + 5, $z + 8 ), new Vector3($x - 5, $y + 6, $z + 8 ), Block::get(Block::AIR )); + BuildingUtils::fill($this->level, new Vector3($x - 4, $y + 5, $z + 9), new Vector3($x - 5, $y + 7, $z + 7), Block::get(Block::SANDSTONE, 2)); + BuildingUtils::fill($this->level, new Vector3($x - 4, $y + 5, $z + 8), new Vector3($x - 5, $y + 6, $z + 8), Block::get(Block::AIR)); break; case self::DIRECTION_MINX : - for($xx = $x - 1; $xx <= $x; $xx ++) { + for ($xx = $x - 1; $xx <= $x; $xx++) { $this->placeBlock($xx, $y + 1, $z + 1); $this->placeBlock($xx, $y + 2, $z + 1); } @@ -817,19 +808,19 @@ class Temple extends Object { $this->placeBlock($x - 1, $y + 1, $z); $this->placeSlab($x - 1, $y + 2, $z); // Pattern - foreach([ - 1, - 2, - 4 - ] as $h ) { + foreach ([ + 1, + 2, + 4 + ] as $h) { $this->placeBlock($x - 2, $y + $h, $z - 1, Block::SANDSTONE, 2); $this->placeBlock($x - 2, $y + $h, $z + 1, Block::SANDSTONE, 2); $this->placeBlock($x - 2, $y + $h, $z, Block::STAINED_HARDENED_CLAY, 1); } - foreach([ - 3, - 5 - ] as $h ) { + foreach ([ + 3, + 5 + ] as $h) { $this->placeBlock($x - 2, $y + $h, $z - 1, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 2, $y + $h, $z + 1, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 2, $y + $h, $z, Block::SANDSTONE, 1); @@ -841,11 +832,11 @@ class Temple extends Object { $this->placeBlock($x - 2, $y + 7, $z, Block::SANDSTONE, 2); $this->placeBlock($x - 2, $y + 7, $z + 1, Block::SANDSTONE, 2); // Building entrance to second floor. - BuildingUtils::fill($this->level, new Vector3($x + 4, $y + 5, $z + 9 ), new Vector3($x + 5, $y + 7, $z + 7 ), Block::get(Block::SANDSTONE, 2 )); - BuildingUtils::fill($this->level, new Vector3($x + 4, $y + 5, $z + 8 ), new Vector3($x + 5, $y + 6, $z + 8 ), Block::get(Block::AIR )); + BuildingUtils::fill($this->level, new Vector3($x + 4, $y + 5, $z + 9), new Vector3($x + 5, $y + 7, $z + 7), Block::get(Block::SANDSTONE, 2)); + BuildingUtils::fill($this->level, new Vector3($x + 4, $y + 5, $z + 8), new Vector3($x + 5, $y + 6, $z + 8), Block::get(Block::AIR)); break; } - + // Finishing stairs system $this->placeBlock($x, $y + 3, $z + 2, Block::SANDSTONE_STAIRS, 2); $this->placeBlock($x, $y + 4, $z + 3, Block::SANDSTONE_STAIRS, 2); @@ -853,22 +844,22 @@ class Temple extends Object { $this->placeBlock($x, $y + 5, $z + 2, Block::AIR); $this->placeBlock($x, $y + 6, $z + 2, Block::AIR); // Making path from stairs to first floor. - BuildingUtils::fill($this->level, new Vector3($x + 2, $y, $z + 4 ), new Vector3($x - 2, $y + 4, $z + 9 ), Block::get(Block::SANDSTONE )); - + BuildingUtils::fill($this->level, new Vector3($x + 2, $y, $z + 4), new Vector3($x - 2, $y + 4, $z + 9), Block::get(Block::SANDSTONE)); + // Other side pattern - foreach([ - 1, - 2, - 4 - ] as $h ) { + foreach ([ + 1, + 2, + 4 + ] as $h) { $this->placeBlock($x + 1, $y + $h, $z - 2, Block::SANDSTONE, 2); $this->placeBlock($x - 1, $y + $h, $z - 2, Block::SANDSTONE, 2); $this->placeBlock($x, $y + $h, $z - 2, Block::STAINED_HARDENED_CLAY, 1); } - foreach([ - 3, - 5 - ] as $h ) { + foreach ([ + 3, + 5 + ] as $h) { $this->placeBlock($x + 1, $y + $h, $z - 2, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 1, $y + $h, $z - 2, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x, $y + $h, $z - 2, Block::SANDSTONE, 1); @@ -881,20 +872,36 @@ class Temple extends Object { $this->placeBlock($x + 1, $y + 7, $z - 2, Block::SANDSTONE, 2); break; } - + // Making top - BuildingUtils::top($this->level, new Vector3($x - 1, $y + 9, $z - 1 ), new Vector3($x + 1, $y, $z + 1 ), Block::get(Block::SANDSTONE )); + BuildingUtils::top($this->level, new Vector3($x - 1, $y + 9, $z - 1), new Vector3($x + 1, $y, $z + 1), Block::get(Block::SANDSTONE)); $this->placeBlock($x - 2, $y + 9, $z, Block::SANDSTONE_STAIRS, 0); $this->placeBlock($x + 2, $y + 9, $z, Block::SANDSTONE_STAIRS, 1); $this->placeBlock($x, $y + 9, $z - 2, Block::SANDSTONE_STAIRS, 2); $this->placeBlock($x, $y + 9, $z + 2, Block::SANDSTONE_STAIRS, 3); } - + + /* + * Places one of the towers. Out is inversed $direction1, stairs come from inversed $direction2 to $direction2, patterns are on $direction1 and $direction2 + * @param $x int + * @param $y int + * @param $z int + * @param $direction1 int + * @param $direction2 int + * @return void + */ + + protected function placeSlab($x, $y, $z) { + $this->level->setBlockIdAt($x, $y, $z, 44); + $this->level->setBlockDataAt($x, $y, $z, 1); + } + /* * Inverses a direction * @param $direction int * @return int */ + protected function getInversedDirection(int $direction): int { switch ($direction) { case self::DIRECTION_PLUSX : // x+ (0) @@ -910,7 +917,7 @@ class Temple extends Object { return self::DIRECTION_PLUSZ; break; default : - return - 1; + return -1; break; } } From 413371a3c1a5b7ea84013a02657af6baf37fe308 Mon Sep 17 00:00:00 2001 From: thebigsmileXD Date: Fri, 12 May 2017 14:51:21 +0200 Subject: [PATCH 7/8] Enhance temple even more, fix some placement issues #3 TODO: Add the inner decorations/pillars TODO: Fix second floor entrance --- src/Ad5001/BetterGen/Main.php | 2 +- src/Ad5001/BetterGen/structure/Temple.php | 144 +++++++++++----------- 2 files changed, 72 insertions(+), 74 deletions(-) diff --git a/src/Ad5001/BetterGen/Main.php b/src/Ad5001/BetterGen/Main.php index 2dce547..24da8a0 100644 --- a/src/Ad5001/BetterGen/Main.php +++ b/src/Ad5001/BetterGen/Main.php @@ -182,7 +182,7 @@ class Main extends PluginBase implements Listener { if($sender instanceof ConsoleCommandSender) return false; /** @var Player $sender */ $temple = new Temple(); - $temple->placeObject($sender->getLevel(), $sender->x, $sender->y, $sender->z, new Random()); + $temple->placeObject($sender->getLevel(), $sender->x, $sender->y, $sender->z, new Random(microtime())); return true; } } diff --git a/src/Ad5001/BetterGen/structure/Temple.php b/src/Ad5001/BetterGen/structure/Temple.php index 4ad1e18..91ef77d 100644 --- a/src/Ad5001/BetterGen/structure/Temple.php +++ b/src/Ad5001/BetterGen/structure/Temple.php @@ -149,53 +149,49 @@ class Temple extends Object { $firstPos = new Vector3($x + 10, $y, $z + 10); $sndPos = new Vector3($x - 10, $y, $z - 10); for ($i = 0; $i <= 9; $i++) { - // Building sides - BuildingUtils::walls($level, $firstPos, $sndPos, Block::get(Block::SANDSTONE)); - - // Next floor - $firstPos->x--; - $firstPos->z--; - $firstPos->y = $y + $i; - $sndPos->x++; - $sndPos->z++; - $sndPos->y = $y + $i; + // Building diagonal sides + BuildingUtils::walls($level, $firstPos->add(-$i, $i, -$i), $sndPos->add($i, $i, $i), Block::get(Block::SANDSTONE)); } - // Floors - for ($xx = $x + 9; $xx >= $x - 9; $xx--) - for ($zz = $z + 9; $zz >= $z - 9; $zz--) - $this->placeBlock($xx, $y, $zz); - for ($xx = $x + 5; $xx >= $x - 5; $xx--) - for ($zz = $z + 5; $zz >= $z - 5; $zz--) - $this->placeBlock($xx, $y + 4, $zz); + + // Floor top + BuildingUtils::fill($level, new Vector3($x - 5, $y + 4, $z - 5), new Vector3($x + 5, $y + 4, $z + 5), Block::get(Block::SANDSTONE)); + #for ($xx = $x + 5; $xx >= $x - 5; $xx--) + # for ($zz = $z + 5; $zz >= $z - 5; $zz--) + # $this->placeBlock($xx, $y + 4, $zz); // Creating hole - for ($xx = $x - 1; $xx <= $x + 1; $xx++) - for ($yy = $y - 11; $yy <= $y + 4; $yy++) - for ($zz = $z - 1; $zz <= $z + 1; $zz++) - $this->placeBlock($xx, $yy, $zz, 0); + BuildingUtils::fill($level, new Vector3($x - 1, $y - 11, $z - 1), new Vector3($x + 1, $y + 4, $z + 1), Block::get(Block::AIR)); + #for ($xx = $x - 1; $xx <= $x + 1; $xx++) + # for ($yy = $y - 11; $yy <= $y + 4; $yy++) + # for ($zz = $z - 1; $zz <= $z + 1; $zz++) + # $this->placeBlock($xx, $yy, $zz, Block::AIR); - // Floor patern - foreach ($this->directions as $dir) { + // Hole walls + BuildingUtils::walls($level, new Vector3($x - 2, $y - 1, $z - 2), new Vector3($x + 2, $y - 8, $z + 2), Block::get(Block::SANDSTONE)); + + //Floor bottom + BuildingUtils::fill($level, new Vector3($x - 9, $y, $z - 9), new Vector3($x + 9, $y, $z + 9), Block::get(Block::SANDSTONE)); + #for ($xx = $x + 9; $xx >= $x - 9; $xx--) + # for ($zz = $z + 9; $zz >= $z - 9; $zz--) + # $this->placeBlock($xx, $y, $zz); + + // Floor pattern + for($i=-2;$i<=1;$i++){//straight + $xextra = ($i + 1) % 2; + $zextra = ($i) % 2; + // Orange hardened clay + $this->placeBlock($x + ($xextra * 3), $y, $z + ($zextra * 3), Block::STAINED_HARDENED_CLAY, 1);//OUTER out + $this->placeBlock($x + ($xextra * 2), $y, $z + ($zextra * 2), Block::STAINED_HARDENED_CLAY, 1);//OUTER in + } + foreach($this->directions as $direction) {//Diagonals // Building pillar for ($yy = $y + 1; $yy <= $y + 3; $yy++) - $this->placeBlock($x + ($dir [0] * 2), $yy, $z + ($dir [1] * 2), Block::SANDSTONE, 2); - // Orange hardened clay - $this->placeBlock($x + $dir [0], $y, $z + $dir [1], Block::STAINED_HARDENED_CLAY, 1); - $this->placeBlock($x + ($dir [0] * 2), $y, $z, Block::STAINED_HARDENED_CLAY, 1); - $this->placeBlock($x + ($dir [0] * 3), $y, $z, Block::STAINED_HARDENED_CLAY, 1); - $this->placeBlock($x, $y, $z + ($dir [1] * 2), Block::STAINED_HARDENED_CLAY, 1); - $this->placeBlock($x, $y, $z + ($dir [1] * 3), Block::STAINED_HARDENED_CLAY, 1); - $this->placeBlock($x + ($dir [0] * 2), $yy, $z + ($dir [1]), Block::STAINED_HARDENED_CLAY, 1); - $this->placeBlock($x + ($dir [0]), $yy, $z + ($dir [1] * 2), Block::STAINED_HARDENED_CLAY, 1); - - // Sandstone - $this->placeBlock($x + $dir [0], $y, $z); - $this->placeBlock($x, $y, $z + $dir [1]); + $this->placeBlock($x + ($direction[0] * 2), $yy, $z + ($direction[1] * 2), Block::SANDSTONE, 2); + $this->placeBlock($x + $direction[0], $y, $z + $direction[1], Block::STAINED_HARDENED_CLAY, 1);//Diagonal } // Blue hardened clay (center) $this->placeBlock($x, $y, $z, Block::STAINED_HARDENED_CLAY, 11); - // Hole walls - BuildingUtils::walls($level, new Vector3($x - 2, $y, $z - 2), new Vector3($x + 2, $y - 8, $z + 2), Block::get(Block::SANDSTONE)); + // Floor pattern end // Last step like this for ($xx = $x - 2; $xx <= $x + 2; $xx++) { @@ -222,7 +218,7 @@ class Temple extends Object { $this->placeBlock($x, $y - 11, $z, Block::STONE_PRESSURE_PLATE); // Chests - LootTable::buildLootTable(new Vector3($x, $y - 11, $z + 2), LootTable::LOOT_DESERT_TEMPLE, $random); + LootTable::buildLootTable(new Vector3($x, $y - 11, $z + 2), LootTable::LOOT_DESERT_TEMPLE, $random);//TODO: Improve using addon LootTable::buildLootTable(new Vector3($x, $y - 11, $z - 2), LootTable::LOOT_DESERT_TEMPLE, $random); LootTable::buildLootTable(new Vector3($x + 2, $y - 11, $z), LootTable::LOOT_DESERT_TEMPLE, $random); LootTable::buildLootTable(new Vector3($x - 2, $y - 11, $z), LootTable::LOOT_DESERT_TEMPLE, $random); @@ -236,7 +232,7 @@ class Temple extends Object { // Creating rectangular parallelepiped of sandstone. BuildingUtils::fill($level, new Vector3($x + 6, $y + 1, $z - 6), new Vector3($x + 9, $y + 4, $z + 6), Block::get(Block::SANDSTONE)); // Creating a path to the entrance - BuildingUtils::fill($level, new Vector3($x + 6, $y + 1, $z - 1), new Vector3($x + 9, $y + 4, $z + 1), Block::get(Block::AIR)); + BuildingUtils::fill($level, new Vector3($x + 6, $y + 1, $z - 1), new Vector3($x + 9, $y + 4, $z + 1), Block::get(Block::AIR));//this clears the entrance // Creating path to towers. for ($yy = $y + 1; $yy <= $y + 2; $yy++) for ($zz = $z - 6; $zz <= $z + 6; $zz++) @@ -314,6 +310,7 @@ class Temple extends Object { break; case self::DIRECTION_PLUSZ : // z+ (2) + //TODO: Build pillars inside // Building towers. $this->placeTower($x + 8, $y, $z + 8, self::DIRECTION_PLUSZ, self::DIRECTION_PLUSX); $this->placeTower($x - 8, $y, $z + 8, self::DIRECTION_PLUSZ, self::DIRECTION_MINX); @@ -394,31 +391,33 @@ class Temple extends Object { } } - /* - * Places a slab + /** + * Places a block * @param $x int * @param $y int * @param $z int - * @return void + * @param int $id + * @param int $meta */ - protected function placeBlock($x, $y, $z, $id = Block::SANDSTONE, $meta = 0) { $this->level->setBlockIdAt($x, $y, $z, $id); $this->level->setBlockDataAt($x, $y, $z, $meta); } - /* - * Places a slab + + /** + * Places one of the towers. Out is inversed $direction1, stairs come from inversed $direction2 to $direction2, patterns are on $direction1 and $direction2 * @param $x int * @param $y int * @param $z int - * @param $id int - * @param $meta int + * @param $direction1 int + * @param $direction2 int * @return void */ - public function placeTower($x, $y, $z, $direction1 = self::DIRECTION_PLUSX, $direction2 = self::DIRECTION_PLUSZ) { BuildingUtils::walls($this->level, new Vector3($x + 2, $y, $z + 2), new Vector3($x - 2, $y + 8, $z - 2), Block::get(Block::SANDSTONE)); + //Clear insides + BuildingUtils::fill($this->level, new Vector3($x + 1, $y + 1, $z + 1), new Vector3($x - 1, $y + 7, $z - 1), Block::get(Block::AIR)); switch ($direction1) { case self::DIRECTION_PLUSX : // x+ (0) // Stairs @@ -456,7 +455,7 @@ class Temple extends Object { $this->placeBlock($x, $y + 7, $z + 2, Block::SANDSTONE, 2); $this->placeBlock($x + 1, $y + 7, $z + 2, Block::SANDSTONE, 2); - // Building entrance to second floor. + // Building entrance to second floor. //TODO BuildingUtils::fill($this->level, new Vector3($x - 9, $y + 5, $z - 4), new Vector3($x - 7, $y + 7, $z - 5), Block::get(Block::SANDSTONE, 2)); BuildingUtils::fill($this->level, new Vector3($x - 8, $y + 5, $z - 4), new Vector3($x - 8, $y + 6, $z - 5), Block::get(Block::AIR)); break; @@ -495,7 +494,7 @@ class Temple extends Object { break; } - // Building entrance to second floor. + // Building entrance to second floor. //TODO BuildingUtils::fill($this->level, new Vector3($x - 9, $y + 5, $z + 4), new Vector3($x - 7, $y + 7, $z + 5), Block::get(Block::SANDSTONE, 2)); BuildingUtils::fill($this->level, new Vector3($x - 8, $y + 5, $z + 4), new Vector3($x - 8, $y + 6, $z + 5), Block::get(Block::AIR)); @@ -506,7 +505,7 @@ class Temple extends Object { $this->placeBlock($x - 2, $y + 5, $z, Block::AIR); $this->placeBlock($x - 2, $y + 6, $z, Block::AIR); // Making path from stairs to first floor. - BuildingUtils::fill($this->level, new Vector3($x - 4, $y, $z + 2), new Vector3($x - 9, $y + 4, $z - 2), Block::get(Block::SANDSTONE)); + BuildingUtils::fill($this->level, new Vector3($x - 3, $y, $z + 1 + ($direction2 === self::DIRECTION_PLUSZ ? 2 : 0)), new Vector3($x - 8, $y + 4, $z - 1 + ($direction2 === self::DIRECTION_MINZ ? -2 : 0)), Block::get(Block::SANDSTONE)); // Other side pattern foreach ([ @@ -570,7 +569,7 @@ class Temple extends Object { $this->placeBlock($x, $y + 7, $z + 2, Block::SANDSTONE, 2); $this->placeBlock($x + 1, $y + 7, $z + 2, Block::SANDSTONE, 2); - // Building entrance to second floor. + // Building entrance to second floor. //TODO BuildingUtils::fill($this->level, new Vector3($x + 9, $y + 5, $z - 4), new Vector3($x + 7, $y + 7, $z - 5), Block::get(Block::SANDSTONE, 2)); BuildingUtils::fill($this->level, new Vector3($x + 8, $y + 5, $z - 4), new Vector3($x + 8, $y + 6, $z - 5), Block::get(Block::AIR)); break; @@ -607,7 +606,7 @@ class Temple extends Object { $this->placeBlock($x, $y + 6, $z - 2, Block::SANDSTONE, 2); $this->placeBlock($x + 1, $y + 6, $z - 2, Block::SANDSTONE, 2); - // Building entrance to second floor. + // Building entrance to second floor. //TODO BuildingUtils::fill($this->level, new Vector3($x + 9, $y + 5, $z + 4), new Vector3($x + 7, $y + 7, $z + 5), Block::get(Block::SANDSTONE, 2)); BuildingUtils::fill($this->level, new Vector3($x + 8, $y + 5, $z + 4), new Vector3($x + 8, $y + 6, $z + 5), Block::get(Block::AIR)); break; @@ -620,7 +619,7 @@ class Temple extends Object { $this->placeBlock($x + 2, $y + 5, $z, Block::AIR); $this->placeBlock($x + 2, $y + 6, $z, Block::AIR); // Making path from stairs to first floor. - BuildingUtils::fill($this->level, new Vector3($x + 4, $y, $z + 2), new Vector3($x + 9, $y + 4, $z - 2), Block::get(Block::SANDSTONE)); + BuildingUtils::fill($this->level, new Vector3($x + 3, $y, $z + 1 + ($direction2 === self::DIRECTION_PLUSZ ? 2 : 0)), new Vector3($x + 8, $y + 4, $z - 1 + ($direction2 === self::DIRECTION_MINZ ? -2 : 0)), Block::get(Block::SANDSTONE)); // Other side pattern foreach ([ @@ -683,7 +682,7 @@ class Temple extends Object { $this->placeBlock($x + 2, $y + 7, $z - 1, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y + 7, $z, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y + 7, $z + 1, Block::SANDSTONE, 2); - // Building entrance to second floor. + // Building entrance to second floor. //TODO BuildingUtils::fill($this->level, new Vector3($x - 4, $y + 5, $z - 9), new Vector3($x - 5, $y + 7, $z - 7), Block::get(Block::SANDSTONE, 2)); BuildingUtils::fill($this->level, new Vector3($x - 4, $y + 5, $z - 8), new Vector3($x - 5, $y + 6, $z - 8), Block::get(Block::AIR)); break; @@ -719,7 +718,7 @@ class Temple extends Object { $this->placeBlock($x - 2, $y + 7, $z - 1, Block::SANDSTONE, 2); $this->placeBlock($x - 2, $y + 7, $z, Block::SANDSTONE, 2); $this->placeBlock($x - 2, $y + 7, $z + 1, Block::SANDSTONE, 2); - // Building entrance to second floor. + // Building entrance to second floor. //TODO BuildingUtils::fill($this->level, new Vector3($x + 4, $y + 5, $z - 9), new Vector3($x + 5, $y + 7, $z - 7), Block::get(Block::SANDSTONE, 2)); BuildingUtils::fill($this->level, new Vector3($x + 4, $y + 5, $z - 8), new Vector3($x + 5, $y + 6, $z - 8), Block::get(Block::AIR)); break; @@ -732,7 +731,7 @@ class Temple extends Object { $this->placeBlock($x, $y + 5, $z - 2, Block::AIR); $this->placeBlock($x, $y + 6, $z - 2, Block::AIR); // Making path from stairs to first floor. - BuildingUtils::fill($this->level, new Vector3($x + 2, $y, $z - 4), new Vector3($x - 2, $y + 4, $z - 9), Block::get(Block::SANDSTONE)); + BuildingUtils::fill($this->level, new Vector3($x + 1 + ($direction2 === self::DIRECTION_PLUSX ? 2 : 0), $y, $z - 3), new Vector3($x - 1 + ($direction2 === self::DIRECTION_MINX ? -2 : 0), $y + 4, $z - 8), Block::get(Block::SANDSTONE)); // Other side pattern foreach ([ @@ -795,7 +794,7 @@ class Temple extends Object { $this->placeBlock($x + 2, $y + 7, $z - 1, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y + 7, $z, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y + 7, $z + 1, Block::SANDSTONE, 2); - // Building entrance to second floor. + // Building entrance to second floor. //TODO BuildingUtils::fill($this->level, new Vector3($x - 4, $y + 5, $z + 9), new Vector3($x - 5, $y + 7, $z + 7), Block::get(Block::SANDSTONE, 2)); BuildingUtils::fill($this->level, new Vector3($x - 4, $y + 5, $z + 8), new Vector3($x - 5, $y + 6, $z + 8), Block::get(Block::AIR)); break; @@ -831,7 +830,7 @@ class Temple extends Object { $this->placeBlock($x - 2, $y + 7, $z - 1, Block::SANDSTONE, 2); $this->placeBlock($x - 2, $y + 7, $z, Block::SANDSTONE, 2); $this->placeBlock($x - 2, $y + 7, $z + 1, Block::SANDSTONE, 2); - // Building entrance to second floor. + // Building entrance to second floor. //TODO BuildingUtils::fill($this->level, new Vector3($x + 4, $y + 5, $z + 9), new Vector3($x + 5, $y + 7, $z + 7), Block::get(Block::SANDSTONE, 2)); BuildingUtils::fill($this->level, new Vector3($x + 4, $y + 5, $z + 8), new Vector3($x + 5, $y + 6, $z + 8), Block::get(Block::AIR)); break; @@ -844,7 +843,7 @@ class Temple extends Object { $this->placeBlock($x, $y + 5, $z + 2, Block::AIR); $this->placeBlock($x, $y + 6, $z + 2, Block::AIR); // Making path from stairs to first floor. - BuildingUtils::fill($this->level, new Vector3($x + 2, $y, $z + 4), new Vector3($x - 2, $y + 4, $z + 9), Block::get(Block::SANDSTONE)); + BuildingUtils::fill($this->level, new Vector3($x + 1 + ($direction2 === self::DIRECTION_PLUSX ? 2 : 0) , $y, $z + 3), new Vector3($x - 1 + ($direction2 === self::DIRECTION_MINX ? -2 : 0), $y + 4, $z + 8), Block::get(Block::SANDSTONE)); // Other side pattern foreach ([ @@ -881,28 +880,27 @@ class Temple extends Object { $this->placeBlock($x, $y + 9, $z + 2, Block::SANDSTONE_STAIRS, 3); } - /* - * Places one of the towers. Out is inversed $direction1, stairs come from inversed $direction2 to $direction2, patterns are on $direction1 and $direction2 + + /** + * Places a slab * @param $x int * @param $y int * @param $z int - * @param $direction1 int - * @param $direction2 int + * @param $id int + * @param $meta int * @return void */ - - protected function placeSlab($x, $y, $z) { - $this->level->setBlockIdAt($x, $y, $z, 44); - $this->level->setBlockDataAt($x, $y, $z, 1); + protected function placeSlab($x, $y, $z, $id = 44, $meta = 1, $top = false) { + if($top) $meta &= 0x08; + $this->placeBlock($x, $y, $z, $id, $meta); } - /* - * Inverses a direction + /** + * Inverts a direction * @param $direction int * @return int */ - - protected function getInversedDirection(int $direction): int { + protected function getInvertedDirection(int $direction): int { switch ($direction) { case self::DIRECTION_PLUSX : // x+ (0) return self::DIRECTION_MINX; From 3fa14b9b1bb80a3cee30e8c3c606871b80681d0e Mon Sep 17 00:00:00 2001 From: thebigsmileXD Date: Fri, 12 May 2017 15:03:36 +0200 Subject: [PATCH 8/8] Fix chestspaces --- src/Ad5001/BetterGen/structure/Temple.php | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/Ad5001/BetterGen/structure/Temple.php b/src/Ad5001/BetterGen/structure/Temple.php index 91ef77d..b99aee9 100644 --- a/src/Ad5001/BetterGen/structure/Temple.php +++ b/src/Ad5001/BetterGen/structure/Temple.php @@ -14,7 +14,6 @@ namespace Ad5001\BetterGen\structure; -use Ad5001\BetterGen\loot\LootTable; use Ad5001\BetterGen\utils\BuildingUtils; use pocketmine\block\Block; use pocketmine\level\ChunkManager; @@ -176,14 +175,14 @@ class Temple extends Object { # $this->placeBlock($xx, $y, $zz); // Floor pattern - for($i=-2;$i<=1;$i++){//straight + for ($i = -2; $i <= 1; $i++) {//straight $xextra = ($i + 1) % 2; $zextra = ($i) % 2; // Orange hardened clay $this->placeBlock($x + ($xextra * 3), $y, $z + ($zextra * 3), Block::STAINED_HARDENED_CLAY, 1);//OUTER out $this->placeBlock($x + ($xextra * 2), $y, $z + ($zextra * 2), Block::STAINED_HARDENED_CLAY, 1);//OUTER in } - foreach($this->directions as $direction) {//Diagonals + foreach ($this->directions as $direction) {//Diagonals // Building pillar for ($yy = $y + 1; $yy <= $y + 3; $yy++) $this->placeBlock($x + ($direction[0] * 2), $yy, $z + ($direction[1] * 2), Block::SANDSTONE, 2); @@ -217,11 +216,20 @@ class Temple extends Object { $this->placeBlock($xx, $y - 13, $zz, Block::TNT); $this->placeBlock($x, $y - 11, $z, Block::STONE_PRESSURE_PLATE); + //TODO TILES + $this->placeBlock($x, $y - 11, $z + 2, Block::CHEST, 4); + $this->placeBlock($x, $y - 11, $z - 2, Block::CHEST, 2); + $this->placeBlock($x + 2, $y - 11, $z, Block::CHEST, 5); + $this->placeBlock($x - 2, $y - 11, $z, Block::CHEST, 3); + $this->placeBlock($x, $y - 10, $z + 2, Block::AIR); + $this->placeBlock($x, $y - 10, $z - 2, Block::AIR); + $this->placeBlock($x + 2, $y - 10, $z, Block::AIR); + $this->placeBlock($x - 2, $y - 10, $z, Block::AIR); // Chests - LootTable::buildLootTable(new Vector3($x, $y - 11, $z + 2), LootTable::LOOT_DESERT_TEMPLE, $random);//TODO: Improve using addon + /*LootTable::buildLootTable(new Vector3($x, $y - 11, $z + 2), LootTable::LOOT_DESERT_TEMPLE, $random);//TODO: Improve using addon LootTable::buildLootTable(new Vector3($x, $y - 11, $z - 2), LootTable::LOOT_DESERT_TEMPLE, $random); LootTable::buildLootTable(new Vector3($x + 2, $y - 11, $z), LootTable::LOOT_DESERT_TEMPLE, $random); - LootTable::buildLootTable(new Vector3($x - 2, $y - 11, $z), LootTable::LOOT_DESERT_TEMPLE, $random); + LootTable::buildLootTable(new Vector3($x - 2, $y - 11, $z), LootTable::LOOT_DESERT_TEMPLE, $random);*/ // Entrance is a rectangular parallelepiped switch ($this->direction) { @@ -843,7 +851,7 @@ class Temple extends Object { $this->placeBlock($x, $y + 5, $z + 2, Block::AIR); $this->placeBlock($x, $y + 6, $z + 2, Block::AIR); // Making path from stairs to first floor. - BuildingUtils::fill($this->level, new Vector3($x + 1 + ($direction2 === self::DIRECTION_PLUSX ? 2 : 0) , $y, $z + 3), new Vector3($x - 1 + ($direction2 === self::DIRECTION_MINX ? -2 : 0), $y + 4, $z + 8), Block::get(Block::SANDSTONE)); + BuildingUtils::fill($this->level, new Vector3($x + 1 + ($direction2 === self::DIRECTION_PLUSX ? 2 : 0), $y, $z + 3), new Vector3($x - 1 + ($direction2 === self::DIRECTION_MINX ? -2 : 0), $y + 4, $z + 8), Block::get(Block::SANDSTONE)); // Other side pattern foreach ([ @@ -891,7 +899,7 @@ class Temple extends Object { * @return void */ protected function placeSlab($x, $y, $z, $id = 44, $meta = 1, $top = false) { - if($top) $meta &= 0x08; + if ($top) $meta &= 0x08; $this->placeBlock($x, $y, $z, $id, $meta); }