2017-05-22 17:08:00 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* ____ __ __ ____
|
|
|
|
* /\ _`\ /\ \__ /\ \__ /\ _`\
|
|
|
|
* \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
|
|
|
|
* \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
|
|
|
|
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
|
|
|
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
|
|
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
|
|
|
* Tomorrow's pocketmine generator.
|
|
|
|
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
|
|
|
|
* @link https://github.com/Ad5001/BetterGen
|
|
|
|
* @category World Generator
|
|
|
|
* @api 3.0.0
|
|
|
|
* @version 1.1
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Ad5001\BetterGen\structure;
|
|
|
|
|
|
|
|
use Ad5001\BetterGen\utils\BuildingUtils;
|
|
|
|
use pocketmine\block\Block;
|
|
|
|
use pocketmine\level\ChunkManager;
|
2017-10-31 14:57:05 +00:00
|
|
|
use pocketmine\level\generator\object\PopulatorObject;
|
2017-05-22 17:08:00 +00:00
|
|
|
use pocketmine\math\Vector3;
|
|
|
|
use pocketmine\utils\Random;
|
|
|
|
|
2017-10-31 14:57:05 +00:00
|
|
|
class Dungeons extends PopulatorObject {
|
2017-05-22 17:08:00 +00:00
|
|
|
public $overridable = [
|
|
|
|
Block::AIR => true,
|
|
|
|
17 => true,
|
|
|
|
Block::SNOW_LAYER => true,
|
|
|
|
Block::LOG2 => true
|
|
|
|
];
|
|
|
|
/** @var int */
|
|
|
|
protected $height;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Places a bush
|
|
|
|
*
|
|
|
|
* @param ChunkManager $level
|
|
|
|
* @param int $x
|
|
|
|
* @param int $y
|
|
|
|
* @param int $z
|
|
|
|
* @param Random $random
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) {
|
2017-11-13 18:49:01 +00:00
|
|
|
$xDepth = 3 + $random->nextBoundedInt(3);
|
|
|
|
$zDepth = 3 + $random->nextBoundedInt(3);
|
|
|
|
// echo "Building dungeon at $x, $y, $z\n";
|
|
|
|
// Building walls
|
|
|
|
list($pos1, $pos2) = BuildingUtils::minmax(new Vector3($x + $xDepth, $y, $z + $zDepth), new Vector3($x - $xDepth, $y + 5, $z - $zDepth));
|
|
|
|
for($y = $pos1->y; $y >= $pos2->y; $y--) {
|
|
|
|
for($x = $pos1->x; $x >= $pos2->x; $x--) {
|
|
|
|
for($z = $pos1->z; $z >= $pos2->z; $z--) { // Cleaning the area first
|
|
|
|
$level->setBlockIdAt($x, $y, $z, Block::AIR);
|
|
|
|
}
|
|
|
|
// Starting random walls.
|
|
|
|
if($random->nextBoolean()) {
|
|
|
|
$level->setBlockIdAt($x, $y, $pos1->z, Block::MOSS_STONE);
|
|
|
|
} else {
|
|
|
|
$level->setBlockIdAt($x, $y, $pos1->z, Block::COBBLESTONE);
|
|
|
|
}
|
|
|
|
if($random->nextBoolean()) {
|
|
|
|
$level->setBlockIdAt($x, $y, $pos2->z, Block::MOSS_STONE);
|
|
|
|
} else {
|
|
|
|
$level->setBlockIdAt($x, $y, $pos2->z, Block::COBBLESTONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for($z = $pos1->z; $z >= $pos2->z; $z--) {
|
|
|
|
if($random->nextBoolean()) {
|
|
|
|
$level->setBlockIdAt($pos1->x, $y, $z, Block::MOSS_STONE);
|
|
|
|
} else {
|
|
|
|
$level->setBlockIdAt($pos1->x, $y, $z, Block::COBBLESTONE);
|
|
|
|
}
|
|
|
|
if($random->nextBoolean()) {
|
|
|
|
$level->setBlockIdAt($pos2->x, $y, $z, Block::MOSS_STONE);
|
|
|
|
} else {
|
|
|
|
$level->setBlockIdAt($pos2->x, $y, $z, Block::COBBLESTONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Bottom & top
|
|
|
|
for($x = $pos1->x; $x >= $pos2->x; $x--) {
|
|
|
|
for($z = $pos1->z; $z >= $pos2->z; $z--) {
|
|
|
|
if($random->nextBoolean()) {
|
|
|
|
$level->setBlockIdAt($x, $pos1->y, $z, Block::MOSS_STONE);
|
|
|
|
} else {
|
|
|
|
$level->setBlockIdAt($x, $pos1->y, $z, Block::COBBLESTONE);
|
|
|
|
}
|
2017-05-22 17:08:00 +00:00
|
|
|
if($random->nextBoolean()) {
|
2017-11-13 18:49:01 +00:00
|
|
|
$level->setBlockIdAt($x, $pos2->y, $z, Block::MOSS_STONE);
|
2017-05-22 17:08:00 +00:00
|
|
|
} else {
|
2017-11-13 18:49:01 +00:00
|
|
|
$level->setBlockIdAt($x, $pos2->y, $z, Block::COBBLESTONE);
|
2017-05-22 17:08:00 +00:00
|
|
|
}
|
|
|
|
}
|
2017-11-13 18:49:01 +00:00
|
|
|
}
|
|
|
|
// Setting the spawner
|
2017-05-22 17:08:00 +00:00
|
|
|
$level->setBlockIdAt($x, $y + 1, $z, Block::MOB_SPAWNER);
|
|
|
|
}
|
|
|
|
}
|