BetterGen/src/Ad5001/BetterGen/biome/BetterForest.php

106 lines
3.6 KiB
PHP
Raw Normal View History

2017-04-23 14:42:51 +00:00
<?php
/**
* ____ __ __ ____
* /\ _`\ /\ \__ /\ \__ /\ _`\
* \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tomorrow's pocketmine generator.
2017-05-14 18:13:15 +00:00
* @author Ad5001 <mail@ad5001.eu>, XenialDan <https://github.com/thebigsmileXD>
* @link https://github.com/Ad5001/BetterGen
2017-05-14 18:13:15 +00:00
* @category World Generator
* @api 3.0.0
* @version 1.1
2017-04-23 14:42:51 +00:00
*/
2017-04-23 14:42:51 +00:00
namespace Ad5001\BetterGen\biome;
use Ad5001\BetterGen\Main;
use Ad5001\BetterGen\populator\BushPopulator;
2017-05-11 05:46:44 +00:00
use Ad5001\BetterGen\populator\FallenTreePopulator;
2017-05-11 12:07:26 +00:00
use Ad5001\BetterGen\populator\TreePopulator;
2017-05-14 17:27:03 +00:00
use Ad5001\BetterGen\generator\BetterNormal;
2017-05-11 12:07:26 +00:00
use pocketmine\level\generator\biome\Biome;
use pocketmine\level\generator\normal\biome\ForestBiome;
2017-05-11 05:46:44 +00:00
2017-04-23 14:42:51 +00:00
class BetterForest extends ForestBiome implements Mountainable {
2017-05-14 19:03:47 +00:00
/** @var string[] **/
2017-04-23 14:42:51 +00:00
static $types = [
"Oak Forest",
"Birch Forest",
"Sakura Forest"
];
2017-05-14 19:03:47 +00:00
/** @var int[] **/
2017-04-23 14:42:51 +00:00
static $ids = [
Biome::FOREST,
Biome::BIRCH_FOREST,
Main::SAKURA_FOREST
];
2017-05-14 19:03:47 +00:00
/**
* Constructs the class
*
* @param int $type = 0
* @param array $infos
*/
2017-04-23 14:42:51 +00:00
public function __construct($type = 0, array $infos = [0.6, 0.5]) {
2017-04-29 09:59:44 +00:00
parent::__construct($type);
2017-04-23 14:42:51 +00:00
$this->clearPopulators ();
$this->type = $type;
2017-04-29 09:59:44 +00:00
$bush = new BushPopulator($type);
$bush->setBaseAmount(10);
if(!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Bushes", BetterNormal::$options["delStruct"])) $this->addPopulator($bush);
2017-05-11 05:46:44 +00:00
$ft = new FallenTreePopulator($type);
$ft->setBaseAmount(0);
$ft->setRandomAmount(4);
if(!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("FallenTrees", BetterNormal::$options["delStruct"])) $this->addPopulator($ft);
2017-05-11 05:46:44 +00:00
2017-04-29 09:59:44 +00:00
$trees = new TreePopulator($type);
2017-05-13 21:42:44 +00:00
$trees->setBaseAmount((null !== @constant(TreePopulator::$types[$type] . "::maxPerChunk")) ? constant(TreePopulator::$types[$type] . "::maxPerChunk") : 5);
if(!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("Trees", BetterNormal::$options["delStruct"])) $this->addPopulator($trees);
2017-04-23 14:42:51 +00:00
$tallGrass = Main::isOtherNS() ? new \pocketmine\level\generator\normal\populator\TallGrass () : new \pocketmine\level\generator\populator\TallGrass();
2017-04-29 09:59:44 +00:00
$tallGrass->setBaseAmount(3);
2017-04-23 14:42:51 +00:00
if(!\Ad5001\BetterGen\utils\CommonUtils::in_arrayi("TallGrass", BetterNormal::$options["delStruct"])) $this->addPopulator($tallGrass);
2017-04-23 14:42:51 +00:00
2017-05-11 05:46:44 +00:00
$this->setElevation(63, 69);
2017-04-23 14:42:51 +00:00
2017-05-13 21:42:44 +00:00
$this->temperature = $infos[0];
$this->rainfall = $infos[1];
2017-04-23 14:42:51 +00:00
}
public function getName() {
return str_ireplace(" ", "", self::$types[$this->type]);
2017-04-23 14:42:51 +00:00
}
/**
* Returns the ID relatively.
2017-05-14 19:03:47 +00:00
*
* @return int
2017-04-23 14:42:51 +00:00
*/
public function getId() {
2017-05-13 21:42:44 +00:00
return self::$ids[$this->type];
2017-04-23 14:42:51 +00:00
}
/**
2017-05-14 19:03:47 +00:00
* Registers a forest
*
* @param string $name
* @param string $treeClass
* @param array $infos
2017-04-23 14:42:51 +00:00
* @return bool
*/
public static function registerForest(string $name, string $treeClass, array $infos): bool {
2017-05-13 21:42:44 +00:00
self::$types[] = str_ireplace("tree", "", explode("\\", $treeClass)[count(explode("\\", $treeClass))]) . " Forest";
TreePopulator::$types[] = $treeClass;
self::$ids[] = Main::SAKURA_FOREST + (count(self::$types) - 2);
2017-05-13 21:27:10 +00:00
Main::register(Main::SAKURA_FOREST + (count(self::$types) - 2), new BetterForest(count(self::$types) - 1, $infos));
return true;
2017-04-23 14:42:51 +00:00
}
}