Final touches
This commit is contained in:
parent
055014aa88
commit
4ccd95196f
17 changed files with 44 additions and 39 deletions
1
processingLoots.json
Normal file
1
processingLoots.json
Normal file
|
@ -0,0 +1 @@
|
||||||
|
[]
|
|
@ -447,6 +447,6 @@ class BetterNormal extends Generator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $y++;
|
return ++$y;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -71,6 +71,6 @@ class BushPopulator extends AmountPopulator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $y++;
|
return ++$y;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -65,6 +65,6 @@ class CactusPopulator extends AmountPopulator {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $y === 0 ? - 1 : $y++;
|
return $y === 0 ? - 1 : ++$y;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -75,7 +75,7 @@ class CavePopulator extends AmountPopulator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $y++;
|
return ++$y;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -56,6 +56,6 @@ class DeadbushPopulator extends AmountPopulator {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $y === 0 ? - 1 : $y++;
|
return $y === 0 ? - 1 : ++$y;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -46,7 +46,9 @@ class FallenTreePopulator extends AmountPopulator {
|
||||||
$this->level = $level;
|
$this->level = $level;
|
||||||
$amount = $this->getAmount($random);
|
$amount = $this->getAmount($random);
|
||||||
$tree = TreePopulator::$types[$this->type];
|
$tree = TreePopulator::$types[$this->type];
|
||||||
$fallenTree = new FallenTree(new $tree());
|
$fallenTree = new \Ad5001\BetterGen\structure\FallenTree(
|
||||||
|
new $tree()
|
||||||
|
);
|
||||||
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);
|
||||||
|
@ -57,10 +59,11 @@ class FallenTreePopulator extends AmountPopulator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* 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) {
|
protected function getHighestWorkableBlock($x, $z) {
|
||||||
for($y = Level::Y_MAX; $y >= 0; -- $y) {
|
for($y = Level::Y_MAX; $y >= 0; -- $y) {
|
||||||
|
@ -69,6 +72,6 @@ class FallenTreePopulator extends AmountPopulator {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $y === 0 ? - 1 : $y++;
|
return $y === 0 ? - 1 : ++$y;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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 $pos pocketmine\math\Vector3
|
||||||
* @param $radius int
|
* @param $radius int
|
||||||
* @param $random pocketmine\utils\Random
|
* @param $random pocketmine\utils\Random
|
||||||
* @return void
|
* @return int lowest ore point
|
||||||
*/
|
*/
|
||||||
public function buildIslandBottomShape(ChunkManager $level, Vector3 $pos, int $radius, Random $random) {
|
public function buildIslandBottomShape(ChunkManager $level, Vector3 $pos, int $radius, Random $random) {
|
||||||
$pos = $pos->round();
|
$pos = $pos->round();
|
||||||
|
@ -122,13 +122,13 @@ class FloatingIslandPopulator extends AmountPopulator {
|
||||||
$oldHB = $hBound;
|
$oldHB = $hBound;
|
||||||
$hBound = $random->nextFloat();
|
$hBound = $random->nextFloat();
|
||||||
if($current >= $currentLen + $hBound) {
|
if($current >= $currentLen + $hBound) {
|
||||||
if($radius == 0) return;
|
if($radius == 0) return $pos->y;
|
||||||
$current = 0;
|
$current = 0;
|
||||||
$currentLen += 0.3 * ($random->nextFloat() + 0.5);
|
$currentLen += 0.3 * ($random->nextFloat() + 0.5);
|
||||||
$radius--;
|
$radius--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//return $pos->y - 1 - $y;//void
|
return $pos->y - 1 - $y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,6 @@ class IglooPopulator extends AmountPopulator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $y++;
|
return ++$y;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -67,6 +67,6 @@ class LakePopulator extends AmountPopulator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $y++;
|
return ++$y;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -84,7 +84,7 @@ class RavinePopulator extends AmountPopulator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $y++;
|
return ++$y;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -64,6 +64,6 @@ class SugarCanePopulator extends AmountPopulator {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $y === 0 ? - 1 : $y++;
|
return $y === 0 ? - 1 : ++$y;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -56,6 +56,6 @@ class TemplePopulator extends AmountPopulator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $y++;
|
return ++$y;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -86,6 +86,6 @@ class TreePopulator extends AmountPopulator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $y++;
|
return ++$y;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -56,6 +56,6 @@ class WellPopulator extends AmountPopulator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $y++;
|
return ++$y;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -18,7 +18,7 @@ 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\level\generator\object\Object;
|
||||||
use pocketmine\level\generator\object\Tree;
|
use pocketmine\level\generator\object\Tree as ObjectTree;
|
||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
|
|
||||||
|
@ -36,18 +36,17 @@ class FallenTree extends Object {
|
||||||
Block::LEAVES2 => true,
|
Block::LEAVES2 => true,
|
||||||
Block::CACTUS => true
|
Block::CACTUS => true
|
||||||
];
|
];
|
||||||
/** @var Tree */
|
|
||||||
protected $tree;
|
protected $tree;
|
||||||
protected $direction;
|
protected $direction;
|
||||||
protected $random;
|
protected $random;
|
||||||
private $length;
|
private $length = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Constructs the class
|
* Constructs the class
|
||||||
* @param $tree Tree
|
* @param $tree ObjectTree
|
||||||
* @throws Exception
|
* @throws Exeption
|
||||||
*/
|
*/
|
||||||
public function __construct(Tree $tree) {
|
public function __construct(ObjectTree $tree) {
|
||||||
$this->tree = $tree;
|
$this->tree = $tree;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,14 +60,15 @@ class FallenTree extends Object {
|
||||||
*/
|
*/
|
||||||
public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) {
|
public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) {
|
||||||
$randomHeight = round($random->nextBoundedInt(6) - 3);
|
$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->direction = $random->nextBoundedInt(4);
|
||||||
$this->random = $random;
|
$this->random = $random;
|
||||||
switch ($this->direction) {
|
switch ($this->direction) {
|
||||||
case 0:
|
case 0:
|
||||||
case 1:// Z+
|
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(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))) {
|
}, $level))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,8 @@ class FallenTree extends Object {
|
||||||
case 2:
|
case 2:
|
||||||
case 3: // X+
|
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(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))) {
|
}, $level))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -136,7 +137,7 @@ class FallenTree extends Object {
|
||||||
*/
|
*/
|
||||||
public function placeBlock($x, $y, $z, ChunkManager $level) {
|
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)])) {
|
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);
|
$level->setBlockDataAt($x, $y, $z, $this->tree->type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 = 0;
|
$numForward = $sideLen;
|
||||||
//TODO END
|
//TODO END
|
||||||
$lX1 = $lZ1 = $lX = $lZ = 0;
|
$lX1 = $lZ1 = $lX = $lZ = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue