From 4ccd95196f88a31350b7eb4ba3d5d13b4ed09310 Mon Sep 17 00:00:00 2001 From: thebigsmileXD Date: Thu, 11 May 2017 15:12:17 +0200 Subject: [PATCH] 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;