2017-04-23 14:42:51 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* BetterForest from BetterGen
|
|
|
|
* Copyright (C) Ad5001 2017
|
|
|
|
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory
|
|
|
|
* @author ad5001
|
|
|
|
*/
|
|
|
|
namespace Ad5001\BetterGen\biome;
|
|
|
|
|
|
|
|
use pocketmine\level\generator\normal\biome\ForestBiome;
|
|
|
|
use pocketmine\level\generator\biome\Biome;
|
|
|
|
use pocketmine\level\generator\populator\TallGrass;
|
|
|
|
use Ad5001\BetterGen\Main;
|
|
|
|
use Ad5001\BetterGen\populator\TreePopulator;
|
|
|
|
use Ad5001\BetterGen\populator\BushPopulator;
|
|
|
|
|
|
|
|
class BetterForest extends ForestBiome implements Mountainable {
|
|
|
|
static $types = [
|
|
|
|
"Oak Forest",
|
|
|
|
"Birch Forest",
|
|
|
|
"Sakura Forest"
|
|
|
|
];
|
|
|
|
static $ids = [
|
|
|
|
Biome::FOREST,
|
|
|
|
Biome::BIRCH_FOREST,
|
|
|
|
Main::SAKURA_FOREST
|
|
|
|
];
|
|
|
|
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);
|
|
|
|
$this->addPopulator($bush);
|
|
|
|
$trees = new TreePopulator($type);
|
|
|
|
$trees->setBaseAmount((null !== @constant(TreePopulator::$types [$type] . "::maxPerChunk" )) ? constant(TreePopulator::$types [$type] . "::maxPerChunk" ) : 5);
|
|
|
|
$this->addPopulator($trees);
|
2017-04-23 14:42:51 +00:00
|
|
|
|
|
|
|
$tallGrass = new TallGrass ();
|
2017-04-29 09:59:44 +00:00
|
|
|
$tallGrass->setBaseAmount(3);
|
2017-04-23 14:42:51 +00:00
|
|
|
|
2017-04-29 09:59:44 +00:00
|
|
|
$this->addPopulator($tallGrass);
|
2017-04-23 14:42:51 +00:00
|
|
|
|
2017-04-29 09:59:44 +00:00
|
|
|
$this->setElevation(63, 81);
|
2017-04-23 14:42:51 +00:00
|
|
|
|
|
|
|
$this->temperature = $infos [0];
|
|
|
|
$this->rainfall = $infos [1];
|
|
|
|
}
|
|
|
|
public function getName() {
|
|
|
|
return self::$types [$this->type];
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Returns the ID relativly.
|
|
|
|
*/
|
|
|
|
public function getId() {
|
|
|
|
return self::$ids [$this->type];
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Registers a forest type. Don't use this method directly use the one from the main class.
|
|
|
|
* @param $name string
|
|
|
|
* @param $treeClass string
|
|
|
|
* @param
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public static function registerForest(string $name, string $treeClass, array $infos): bool {
|
2017-04-29 09:59:44 +00:00
|
|
|
self::$types [] = str_ireplace("tree", "", explode("\\", $treeClass ) [count(explode("\\", $treeClass ) )] ) . " Forest";
|
2017-04-23 14:42:51 +00:00
|
|
|
TreePopulator::$types [] = $treeClass;
|
2017-04-29 09:59:44 +00:00
|
|
|
self::$ids [] = Main::SAKURA_FOREST + (count(self::$types ) - 2);
|
|
|
|
Main::register(Main::SAKURA_FOREST + (count(self::$types ) - 2), new BetterForest(count(self::$types ) - 1, $infos ));
|
2017-04-23 14:42:51 +00:00
|
|
|
}
|
|
|
|
}
|