Fix generation issues

This commit is contained in:
thebigsmileXD 2017-05-11 16:41:42 +02:00
parent 4ccd95196f
commit a7b8469c9c
16 changed files with 47 additions and 37 deletions

View file

@ -438,7 +438,7 @@ class BetterNormal extends Generator {
* @param $z int * @param $z int
*/ */
protected function getHighestWorkableBlock($x, $z) { 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); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) { if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
break; break;

View file

@ -62,7 +62,7 @@ class BushPopulator extends AmountPopulator {
* @param $z int * @param $z int
*/ */
protected function getHighestWorkableBlock($x, $z) { 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); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) { if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
break; break;

View file

@ -59,7 +59,7 @@ class CactusPopulator extends AmountPopulator {
* @param $z int * @param $z int
*/ */
protected function getHighestWorkableBlock($x, $z) { 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); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) { if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) {
break; break;

View file

@ -66,7 +66,7 @@ class CavePopulator extends AmountPopulator {
* @param $z int * @param $z int
*/ */
protected function getHighestWorkableBlock($x, $z) { 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); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL or $b === Block::SAND or $b === Block::SNOW_BLOCK or $b === Block::SANDSTONE) { if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL or $b === Block::SAND or $b === Block::SNOW_BLOCK or $b === Block::SANDSTONE) {
break; break;

View file

@ -14,8 +14,10 @@
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use Ad5001\BetterGen\generator\BetterBiomeSelector;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use pocketmine\level\generator\biome\Biome;
use pocketmine\level\Level; use pocketmine\level\Level;
use pocketmine\utils\Random; use pocketmine\utils\Random;
@ -36,26 +38,31 @@ class DeadbushPopulator extends AmountPopulator {
for($i = 0; $i < $amount; $i++) { for($i = 0; $i < $amount; $i++) {
$x = $random->nextRange($chunkX * 16, $chunkX * 16 + 15); $x = $random->nextRange($chunkX * 16, $chunkX * 16 + 15);
$z = $random->nextRange($chunkZ * 16, $chunkZ * 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); $y = $this->getHighestWorkableBlock($x, $z);
if ($y !== -1 && $level->getBlockIdAt($x, $y - 1, $z ) == Block::SAND) { if ($y !== -1) {
$level->setBlockIdAt($x, $y + 1, $z, Block::DEAD_BUSH); $level->setBlockIdAt($x, $y, $z, Block::DEAD_BUSH);
$level->setBlockDataAt($x, $y + 1, $z, 1); $level->setBlockDataAt($x, $y, $z, 1);
} }
} }
} }
/* /**
* Gets the top block (y) on an x and z axes * Gets the top block (y) on an x and z axes
* @param $x int * @param $x
* @param $z int * @param $z
* @return int
*/ */
protected function getHighestWorkableBlock($x, $z) { private 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); $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; break;
}elseif($b !== Block::AIR){
return -1;
} }
} }
return $y === 0 ? - 1 : ++$y;
return ++$y;
} }
} }

View file

@ -65,13 +65,16 @@ class FallenTreePopulator extends AmountPopulator {
* @param $z * @param $z
* @return int * @return int
*/ */
protected function getHighestWorkableBlock($x, $z) { private 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); $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; break;
}elseif($b !== Block::AIR and $b !== Block::SNOW_LAYER){
return -1;
} }
} }
return $y === 0 ? - 1 : ++$y;
return ++$y;
} }
} }

View file

@ -69,7 +69,7 @@ class FloatingIslandPopulator extends AmountPopulator {
* @param $z int * @param $z int
*/ */
protected function getHighestWorkableBlock($x, $z) { 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); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL or $b === Block::SAND) { if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL or $b === Block::SAND) {
break; break;

View file

@ -49,7 +49,7 @@ class IglooPopulator extends AmountPopulator {
* @param $z int * @param $z int
*/ */
protected function getHighestWorkableBlock($x, $z) { 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); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) { if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
break; break;

View file

@ -58,7 +58,7 @@ class LakePopulator extends AmountPopulator {
* @param $z int * @param $z int
*/ */
protected function getHighestWorkableBlock($x, $z) { 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); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) { if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
break; break;

View file

@ -75,7 +75,7 @@ class RavinePopulator extends AmountPopulator {
* @param $z int * @param $z int
*/ */
protected function getHighestWorkableBlock($x, $z) { 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); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL or $b === Block::SAND or $b === Block::SNOW_BLOCK or $b === Block::SANDSTONE) { if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL or $b === Block::SAND or $b === Block::SNOW_BLOCK or $b === Block::SANDSTONE) {
break; break;

View file

@ -58,7 +58,7 @@ class SugarCanePopulator extends AmountPopulator {
* @param $z int * @param $z int
*/ */
protected function getHighestWorkableBlock($x, $z) { 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); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) { if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) {
break; break;

View file

@ -49,7 +49,7 @@ class TemplePopulator extends AmountPopulator {
* @param $z int * @param $z int
*/ */
protected function getHighestWorkableBlock($x, $z) { 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); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b === Block::SAND) { if ($b === Block::SAND) {
break; break;

View file

@ -77,7 +77,7 @@ class TreePopulator extends AmountPopulator {
* @param $z int * @param $z int
*/ */
protected function getHighestWorkableBlock($x, $z) { 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); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) { if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
break; break;

View file

@ -49,7 +49,7 @@ class WellPopulator extends AmountPopulator {
* @param $z int * @param $z int
*/ */
protected function getHighestWorkableBlock($x, $z) { 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); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b === Block::SAND) { if ($b === Block::SAND) {
break; break;

View file

@ -569,7 +569,7 @@ class SakuraTree extends Tree {
$sideLen = $totalLength ** 2; // Side length $sideLen = $totalLength ** 2; // Side length
//TODO CHECK WHAT THIS IS SUPPOSED TO BE //TODO CHECK WHAT THIS IS SUPPOSED TO BE
$numForward = $sideLen; $numForward = ($totalLength % 2 == 0) ? $totalLength - 1 : $totalLength;
//TODO END //TODO END
$lX1 = $lZ1 = $lX = $lZ = 0; $lX1 = $lZ1 = $lX = $lZ = 0;
@ -589,7 +589,6 @@ class SakuraTree extends Tree {
} }
// Second branch part. + second leave part // 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); $lX = $lX1 + ($xd * $i);
$lZ = $lZ1 + ($zd * $i); $lZ = $lZ1 + ($zd * $i);

View file

@ -14,13 +14,13 @@
namespace Ad5001\BetterGen\structure; namespace Ad5001\BetterGen\structure;
use Ad5001\BetterGen\loot\LootTable;
use Ad5001\BetterGen\utils\BuildingUtils;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use pocketmine\level\generator\object\Object;
use pocketmine\math\Vector3;
use pocketmine\utils\Random; 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 { class Temple extends Object {
const DIRECTION_PLUSX = 0; const DIRECTION_PLUSX = 0;
@ -109,7 +109,6 @@ class Temple extends Object {
1 1
] ]
]; ];
private $direction;
/* /*
* Checks if a temple is placeable * Checks if a temple is placeable
@ -172,7 +171,7 @@ class Temple extends Object {
for($zz = $z - 1; $zz <= $z + 1; $zz ++) for($zz = $z - 1; $zz <= $z + 1; $zz ++)
$this->placeBlock($xx, $yy, $zz, 0); $this->placeBlock($xx, $yy, $zz, 0);
// Floor pattern // Floor patern
foreach($this->directions as $dir ) { foreach($this->directions as $dir ) {
// Building pillar // Building pillar
for($yy = $y + 1; $yy <= $y + 3; $yy ++) 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 + ($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] * 2), Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x, $y, $z + ($dir [1] * 3), 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 // Sandstone
$this->placeBlock($x + $dir [0], $y, $z); $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 $x int
* @param $y int * @param $y int
* @param $z int * @param $z int
@ -894,7 +895,7 @@ class Temple extends Object {
* @param $direction int * @param $direction int
* @return int * @return int
*/ */
protected function getInvertedDirection(int $direction): int { protected function getInversedDirection(int $direction): int {
switch ($direction) { switch ($direction) {
case self::DIRECTION_PLUSX : // x+ (0) case self::DIRECTION_PLUSX : // x+ (0)
return self::DIRECTION_MINX; return self::DIRECTION_MINX;