2017-04-23 14:42:51 +00:00
|
|
|
<?php
|
2017-05-10 15:03:04 +00:00
|
|
|
/**
|
|
|
|
* ____ __ __ ____
|
|
|
|
* /\ _`\ /\ \__ /\ \__ /\ _`\
|
|
|
|
* \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
|
|
|
|
* \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
|
|
|
|
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
|
|
|
|
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
|
|
|
|
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
|
|
|
|
* Tommorow's pocketmine generator.
|
|
|
|
* @author Ad5001
|
|
|
|
* @link https://github.com/Ad5001/BetterGen
|
2017-04-23 14:42:51 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
namespace Ad5001\BetterGen\structure;
|
|
|
|
|
|
|
|
use pocketmine\block\Block;
|
|
|
|
use pocketmine\level\ChunkManager;
|
|
|
|
use pocketmine\utils\Random;
|
|
|
|
use pocketmine\level\generator\object\Object;
|
|
|
|
|
|
|
|
|
|
|
|
class Well extends Object {
|
|
|
|
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
|
|
|
|
]
|
|
|
|
];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Checks if a well is placeable
|
|
|
|
* @param $level pocketmine\level\ChunkManager
|
|
|
|
* @param $x int
|
|
|
|
* @param $y int
|
|
|
|
* @param $z int
|
|
|
|
* @param $random pocketmine\utils\Random
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) {
|
|
|
|
for($xx = $x - 2; $xx <= $x + 2; $xx ++)
|
|
|
|
for($yy = $y; $yy <= $y + 3; $yy ++)
|
|
|
|
for($zz = $z - 2; $zz <= $z + 2; $zz ++)
|
2017-04-29 09:59:44 +00:00
|
|
|
if (! isset($this->overridable [$level->getBlockIdAt($xx, $yy, $zz )] ))
|
2017-04-23 14:42:51 +00:00
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Places a well
|
|
|
|
* @param $level pocketmine\level\ChunkManager
|
|
|
|
* @param $x int
|
|
|
|
* @param $y int
|
|
|
|
* @param $z int
|
|
|
|
* @param $random pocketmine\utils\Random
|
|
|
|
*/
|
|
|
|
public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) {
|
|
|
|
$this->level = $level;
|
2017-04-29 09:59:44 +00:00
|
|
|
foreach($this->directions as $direction ) {
|
2017-04-23 14:42:51 +00:00
|
|
|
// Building pillard
|
|
|
|
for($yy = $y; $yy < $y + 3; $yy ++)
|
2017-04-29 09:59:44 +00:00
|
|
|
$this->placeBlock($x + $direction [0], $yy, $z + $direction [1], Block::SANDSTONE);
|
2017-04-23 14:42:51 +00:00
|
|
|
|
|
|
|
// Building corners
|
2017-04-29 09:59:44 +00:00
|
|
|
$this->placeBlock($x + ($direction [0] * 2), $y, $z + $direction [1], Block::SANDSTONE);
|
|
|
|
$this->placeBlock($x + $direction [0], $y, $z + ($direction [1] * 2), Block::SANDSTONE);
|
|
|
|
$this->placeBlock($x + ($direction [0] * 2), $y, $z + ($direction [1] * 2), Block::SANDSTONE);
|
2017-04-23 14:42:51 +00:00
|
|
|
|
|
|
|
// Building slabs on the sides. Places two times due to all directions.
|
2017-04-29 09:59:44 +00:00
|
|
|
$this->placeSlab($x + ($direction [0] * 2), $y, $z);
|
|
|
|
$this->placeSlab($x, $y, $z + ($direction [1] * 2));
|
2017-04-23 14:42:51 +00:00
|
|
|
|
|
|
|
// Placing water.Places two times due to all directions.
|
2017-04-29 09:59:44 +00:00
|
|
|
$this->placeBlock($x + $direction [0], $y, $z, Block::WATER);
|
|
|
|
$this->placeBlock($x, $y, $z + $direction [1], Block::WATER);
|
2017-04-23 14:42:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Finitions
|
|
|
|
for($xx = $x - 1; $xx <= $x + 1; $xx ++)
|
|
|
|
for($zz = $z - 1; $zz <= $z + 1; $zz ++)
|
2017-04-29 09:59:44 +00:00
|
|
|
$this->placeSlab($xx, $y + 3, $zz);
|
|
|
|
$this->placeSlab($x, $y + 3, $z, Block::SANDSTONE);
|
|
|
|
$this->placeSlab($x, $y, $z, Block::WATER);
|
2017-04-23 14:42:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Places a slab
|
|
|
|
* @param $x int
|
|
|
|
* @param $y int
|
|
|
|
* @param $z int
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function placeSlab($x, $y, $z) {
|
2017-04-29 09:59:44 +00:00
|
|
|
$this->level->setBlockIdAt($x, $y, $z, 44);
|
|
|
|
$this->level->setBlockDataAt($x, $y, $z, 1);
|
2017-04-23 14:42:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Places a slab
|
|
|
|
* @param $x int
|
|
|
|
* @param $y int
|
|
|
|
* @param $z int
|
|
|
|
* @param $id int
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function placeBlock($x, $y, $z, $id) {
|
2017-04-29 09:59:44 +00:00
|
|
|
$this->level->setBlockIdAt($x, $y, $z, $id);
|
2017-04-23 14:42:51 +00:00
|
|
|
}
|
|
|
|
}
|