Big update !

- Updating headers,
- Adding first setting, deleteBiomes, wiki comming soon
This commit is contained in:
Adsooi 2017-05-10 17:03:04 +02:00
parent acd3273c72
commit b73d3c981c
37 changed files with 534 additions and 275 deletions

View file

@ -1,17 +1,31 @@
--- ---
# Base generated with ImagicalPlugCreator by Ad5001 (C) 2017 for Ad5001 # ____ __ __ ____
# link: https://ad5001.eu # /\ _`\ /\ \__ /\ \__ /\ _`\
# \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
# \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
# \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
# \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
# \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
# Tommorow's pocketmine generator.
# @author Ad5001
# @link https://github.com/Ad5001/BetterGen
name: BetterGen name: BetterGen
author: Ad5001 author: Ad5001
main: Ad5001\BetterGen\Main main: Ad5001\BetterGen\Main
version: 1.0 version: 1.1
api: [3.0.1, 3.0.0-ALPHA3] api: [3.0.1, 3.0.0-ALPHA3]
commands: commands:
createworld: createworld:
description: Generates a new world. description: Generates a new world.
usage: "/createworld <name> [generator = betternormal] [seed = rand()] [options (json)]" usage: "/createworld <name> [generator = betternormal] [seed = rand()] [options (json)]"
permission: bettergen.cmd.createworld permission: bettergen.cmd.createworld
worldtp:
description: Teleports you to an another world
usage: "/worldtp <world name>"
permission: bettergen.cmd.worldtp
permissions: permissions:
bettergen.cmd.createworld: bettergen.cmd.createworld:
default: op default: op
bettergen.cmd.worldtp:
default: op
... ...

View file

@ -1,10 +1,15 @@
<?php <?php
/**
/* * ____ __ __ ____
* Main from BetterGen * /\ _`\ /\ \__ /\ \__ /\ _`\
* Copyright(C) Ad5001 2017 * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* @author ad5001 * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen; namespace Ad5001\BetterGen;
@ -112,6 +117,7 @@ class Main extends PluginBase implements \pocketmine\event\Listener {
return true; return true;
} }
$generatorName = strtolower($args [1]); $generatorName = strtolower($args [1]);
if($args[2] == "rand") $args[2] = $this->generateRandomSeed();
if(preg_match("[^\d]", $args [2]) !== false) { if(preg_match("[^\d]", $args [2]) !== false) {
$parts = str_split($args [2]); $parts = str_split($args [2]);
foreach($parts as $key => $str) { foreach($parts as $key => $str) {
@ -123,12 +129,17 @@ class Main extends PluginBase implements \pocketmine\event\Listener {
} }
unset($args [0], $args [1], $args [2]); unset($args [0], $args [1], $args [2]);
$options = json_decode($args [3], true); $options = json_decode($args [3], true);
if(! is_array($json)) { if(! is_array($options)) {
$sender->sendMessage(Main::PREFIX . "§4Invalid JSON for options."); $sender->sendMessage(Main::PREFIX . "§4Invalid JSON for options.");
return true; return true;
} }
break; break;
} }
$options["preset"] = json_encode($options);
if((int) $seed == 0/*String*/){
$seed = $this->generateRandomSeed();
echo "Rechoosen seed";
}
$this->getServer()->broadcastMessage(Main::PREFIX . "§aGenerating level $name with generator $generatorName and seed $seed.."); $this->getServer()->broadcastMessage(Main::PREFIX . "§aGenerating level $name with generator $generatorName and seed $seed..");
$this->getServer()->generateLevel($name, $seed, $generator, $options); $this->getServer()->generateLevel($name, $seed, $generator, $options);
$this->getServer()->loadLevel($name); $this->getServer()->loadLevel($name);
@ -161,10 +172,6 @@ class Main extends PluginBase implements \pocketmine\event\Listener {
* @return void * @return void
*/ */
public static function registerBiome(int $id, Biome $biome) { public static function registerBiome(int $id, Biome $biome) {
$reflection = new \ReflectionClass('pocketmine\\level\\generator\\biome\\Biome');
$register = $reflection->getMethod('register');
$register->setAccessible(true);
$register->invoke(null, $id, $biome);
BetterNormal::registerBiome($biome); BetterNormal::registerBiome($biome);
} }
@ -173,7 +180,7 @@ class Main extends PluginBase implements \pocketmine\event\Listener {
* @return int * @return int
*/ */
public function generateRandomSeed(): int { public function generateRandomSeed(): int {
return(int) round(time() * rand(0, time()) / memory_get_usage()); return (int) round(rand(0, round(time()) / memory_get_usage(true)) * (int) str_shuffle("127469453645108") / (int) str_shuffle("12746945364"));
} }
// Listener // Listener

View file

@ -1,10 +1,15 @@
<?php <?php
/**
/* * ____ __ __ ____
* BetterDesert from BetterGen * /\ _`\ /\ \__ /\ \__ /\ _`\
* Copyright (C) Ad5001 2017 * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* @author ad5001 * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\biome; namespace Ad5001\BetterGen\biome;
@ -67,7 +72,7 @@ class BetterDesert extends SandyBiome implements Mountainable {
]); ]);
} }
public function getName(): string { public function getName(): string {
return "Better Desert"; return "BetterDesert";
} }
/* /*

View file

@ -1,11 +1,18 @@
<?php <?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 * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* @author ad5001 * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\biome; namespace Ad5001\BetterGen\biome;
use pocketmine\level\generator\normal\biome\ForestBiome; use pocketmine\level\generator\normal\biome\ForestBiome;
@ -49,7 +56,7 @@ class BetterForest extends ForestBiome implements Mountainable {
$this->rainfall = $infos [1]; $this->rainfall = $infos [1];
} }
public function getName() { public function getName() {
return self::$types [$this->type]; return str_ireplace(" ", "", self::$types[$this->type]);
} }
/* /*

View file

@ -1,10 +1,15 @@
<?php <?php
/**
/* * ____ __ __ ____
* BetterIcePlains from BetterGen * /\ _`\ /\ \__ /\ \__ /\ _`\
* Copyright (C) Ad5001 2017 * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* @author ad5001 * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\biome; namespace Ad5001\BetterGen\biome;
@ -38,7 +43,7 @@ class BetterIcePlains extends SnowyBiome implements Mountainable {
$this->rainfall = 0.8; $this->rainfall = 0.8;
} }
public function getName() { public function getName() {
return "Better Ice Plains"; return "BetterIcePlains";
} }
/* /*

View file

@ -1,10 +1,15 @@
<?php <?php
/**
/* * ____ __ __ ____
* BetterMesa from BetterGen * /\ _`\ /\ \__ /\ \__ /\ _`\
* Copyright (C) Ad5001 2017 * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* @author ad5001 * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\biome; namespace Ad5001\BetterGen\biome;
@ -102,7 +107,7 @@ class BetterMesa extends SandyBiome {
]); ]);
} }
public function getName(): string { public function getName(): string {
return "Better Mesa"; return "BetterMesa";
} }
/* /*

View file

@ -1,11 +1,17 @@
<?php <?php
/**
/* * ____ __ __ ____
* BetterMesaPlains from BetterGen * /\ _`\ /\ \__ /\ \__ /\ _`\
* Copyright (C) Ad5001 2017 * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* @author ad5001 * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\biome; namespace Ad5001\BetterGen\biome;
use pocketmine\level\generator\normal\biome\SandyBiome; use pocketmine\level\generator\normal\biome\SandyBiome;
@ -96,7 +102,7 @@ class BetterMesaPlains extends SandyBiome {
]); ]);
} }
public function getName(): string { public function getName(): string {
return "Better Mesa Plains"; return "BetterMesaPlains";
} }
/* /*

View file

@ -1,10 +1,15 @@
<?php <?php
/**
/* * ____ __ __ ____
* BetterRiver from BetterGen * /\ _`\ /\ \__ /\ \__ /\ _`\
* Copyright (C) Ad5001 2017 * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* @author ad5001 * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\biome; namespace Ad5001\BetterGen\biome;
@ -36,7 +41,7 @@ class BetterRiver extends Biome {
$this->rainfall = 0.7; $this->rainfall = 0.7;
} }
public function getName() { public function getName() {
return "Better River"; return "BetterRiver";
} }
/* /*

View file

@ -1,10 +1,15 @@
<?php <?php
/**
/* * ____ __ __ ____
* Mountainable from BetterGen * /\ _`\ /\ \__ /\ \__ /\ _`\
* Copyright (C) Ad5001 2017 * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* @author ad5001 * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\biome; namespace Ad5001\BetterGen\biome;

View file

@ -1,11 +1,16 @@
<?php <?php
/**
/* * ____ __ __ ____
* BetterBiomeSelector from BetterGen * /\ _`\ /\ \__ /\ \__ /\ _`\
* Copyright (C) Ad5001 2017 * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* @author ad5001 * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
*/ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/
namespace Ad5001\BetterGen\generator; namespace Ad5001\BetterGen\generator;
use pocketmine\level\generator\biome\BiomeSelector; use pocketmine\level\generator\biome\BiomeSelector;
@ -59,7 +64,6 @@ class BetterBiomeSelector extends BiomeSelector {
$rainfall = ($this->getRainfall($x, $z )); $rainfall = ($this->getRainfall($x, $z ));
$biomeId = BetterNormal::getBiome($temperature, $rainfall); $biomeId = BetterNormal::getBiome($temperature, $rainfall);
// $biomeId = new \Ad5001\BetterGen\biome\BetterDesert();
$b = (($biomeId instanceof Biome) ? $biomeId : ($this->biomes [$biomeId] ?? $this->fallback)); $b = (($biomeId instanceof Biome) ? $biomeId : ($this->biomes [$biomeId] ?? $this->fallback));
return $b; return $b;
} }

View file

@ -1,11 +1,17 @@
<?php <?php
/**
* ____ __ __ ____
* /\ _`\ /\ \__ /\ \__ /\ _`\
* \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/
/*
* BetterNormal 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\generator; namespace Ad5001\BetterGen\generator;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
@ -64,6 +70,10 @@ class BetterNormal extends Generator {
public static $levels = [ ]; public static $levels = [ ];
protected static $GAUSSIAN_KERNEL = null; // From main class protected static $GAUSSIAN_KERNEL = null; // From main class
protected static $SMOOTH_SIZE = 2; protected static $SMOOTH_SIZE = 2;
protected static $options = [
"deleteBiomes" => [
]
];
protected $waterHeight = 63; protected $waterHeight = 63;
/* /*
@ -91,6 +101,13 @@ class BetterNormal extends Generator {
} }
return $b; return $b;
} }
/**
* Inits the class for the var
* @param ChunkManager $level
* @param Random $random
* @return void
*/
public function init(ChunkManager $level, Random $random) { public function init(ChunkManager $level, Random $random) {
$this->level = $level; $this->level = $level;
$this->random = $random; $this->random = $random;
@ -139,10 +156,16 @@ class BetterNormal extends Generator {
$cover = Main::isOtherNS() ? new \pocketmine\level\generator\normal\populator\GroundCover() : new \pocketmine\level\generator\populator\GroundCover(); $cover = Main::isOtherNS() ? new \pocketmine\level\generator\normal\populator\GroundCover() : new \pocketmine\level\generator\populator\GroundCover();
$this->generationPopulators [] = $cover; $this->generationPopulators [] = $cover;
// https://twitter.com/Ad5001P4F/status/859430935468670976
// $lake = new LakePopulator ();
// $lake->setBaseAmount(0);
// $lake->setRandomAmount(1);
// $this->generationPopulators [] = $lake;
$cave = new CavePopulator (); $cave = new CavePopulator ();
$cave->setBaseAmount(0); $cave->setBaseAmount(0);
$cave->setRandomAmount(2); $cave->setRandomAmount(2);
$this->populators [] = $cave; $this->generationPopulators [] = $cave;
$ravine = new RavinePopulator (); $ravine = new RavinePopulator ();
$ravine->setBaseAmount(0); $ravine->setBaseAmount(0);
@ -153,12 +176,6 @@ class BetterNormal extends Generator {
$mineshaft->setBaseAmount(0); $mineshaft->setBaseAmount(0);
$mineshaft->setRandomAmount(102); $mineshaft->setRandomAmount(102);
$this->populators [] = $mineshaft; $this->populators [] = $mineshaft;
// https://twitter.com/Ad5001P4F/status/859430935468670976
// $lake = new LakePopulator ();
// $lake->setBaseAmount(0);
// $lake->setRandomAmount(1);
// $this->generationPopulators [] = $lake;
$fisl = new FloatingIslandPopulator(); $fisl = new FloatingIslandPopulator();
@ -196,11 +213,12 @@ class BetterNormal extends Generator {
* @return bool * @return bool
*/ */
public static function registerBiome(Biome $biome): bool { public static function registerBiome(Biome $biome): bool {
foreach(self::$levels as $lvl ) if(\Ad5001\BetterGen\utils\CommonUtils::in_arrayi($biome->getName(), self::$options["deleteBiomes"])) {
if (isset($lvl->selector )) echo "Removing " . $biome->getName() . "...\n";
$lvl->selector->addBiome($biome); // If no selector created, it would cause errors. These will be added when selectoes return false;
if (! isset(self::$biomes [( string ) $biome->getRainfall ()] )) }
self::$biomes [( string ) $biome->getRainfall ()] = [ ]; foreach(self::$levels as $lvl ) if(isset($lvl->selector)) $lvl->selector->addBiome($biome); // If no selector created, it would cause errors. These will be added when selectoes
if (! isset(self::$biomes[(string) $biome->getRainfall ()] )) self::$biomes [( string ) $biome->getRainfall ()] = [ ];
self::$biomes [( string ) $biome->getRainfall ()] [( string ) $biome->getTemperature ()] = $biome; self::$biomes [( string ) $biome->getRainfall ()] [( string ) $biome->getTemperature ()] = $biome;
ksort(self::$biomes [( string ) $biome->getRainfall ()]); ksort(self::$biomes [( string ) $biome->getRainfall ()]);
ksort(self::$biomes); ksort(self::$biomes);
@ -256,7 +274,6 @@ class BetterNormal extends Generator {
* @param $chunkZ int * @param $chunkZ int
*/ */
public function generateChunk($chunkX, $chunkZ) { public function generateChunk($chunkX, $chunkZ) {
$this->reRegisterBiomes ();
$this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed ()); $this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed ());
@ -343,7 +360,7 @@ class BetterNormal extends Generator {
} }
$chunk = $this->level->getChunk($chunkX, $chunkZ); $chunk = $this->level->getChunk($chunkX, $chunkZ);
$biome = Biome::getBiome($chunk->getBiomeId(7, 7 )); $biome = self::getBiomeById($chunk->getBiomeId(7, 7 ));
$biome->populateChunk($this->level, $chunkX, $chunkZ, $this->random); $biome->populateChunk($this->level, $chunkX, $chunkZ, $this->random);
} }
@ -352,6 +369,18 @@ class BetterNormal extends Generator {
* @param $options array * @param $options array
*/ */
public function __construct(array $options = []) { public function __construct(array $options = []) {
self::$options["preset"] = $options["preset"];
$options = (array) json_decode($options["preset"]);
if(isset($options["deleteBiomes"]) && is_string($options["deleteBiomes"])) {
$options["deleteBiomes"] = explode(",", $options["deleteBiomes"]);
if(count($options["deleteBiomes"]) !== 0) {
self::$options["deleteBiomes"] = $options["deleteBiomes"];
}
}
if(isset($options["deleteBiomes"]) && count($options["deleteBiomes"]) !== 0) {
self::$options["deleteBiomes"] = $options["deleteBiomes"];
}
if (self::$GAUSSIAN_KERNEL === null) { if (self::$GAUSSIAN_KERNEL === null) {
self::generateKernel (); self::generateKernel ();
} }
@ -387,7 +416,7 @@ class BetterNormal extends Generator {
* @return array * @return array
*/ */
public function getSettings(): array { public function getSettings(): array {
return [ ]; return self::$options;
} }
public function getSpawn() { public function getSpawn() {
return new Vector3(127.5, 128, 127.5); return new Vector3(127.5, 128, 127.5);
@ -417,18 +446,4 @@ class BetterNormal extends Generator {
return $y++; return $y++;
} }
/*
* Re registers all biomes for async
*/
public function reRegisterBiomes() {
$reflection = new \ReflectionClass('pocketmine\\level\\generator\\biome\\Biome');
$register = $reflection->getMethod('register');
$register->setAccessible(true);
foreach(self::$biomes as $rainfall => $arr ) {
foreach($arr as $tmp => $biome ) {
$register->invoke(null, $biome->getId (), $biome);
}
}
}
} }

View file

@ -1,10 +1,15 @@
<?php <?php
/**
/* * ____ __ __ ____
* LootTable from BetterGen * /\ _`\ /\ \__ /\ \__ /\ _`\
* Copyright (C) Ad5001 2017 * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* @author ad5001 * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\loot; namespace Ad5001\BetterGen\loot;

View file

@ -1,10 +1,15 @@
<?php <?php
/**
/* * ____ __ __ ____
* AmountPopulator from BetterGen * /\ _`\ /\ \__ /\ \__ /\ _`\
* Copyright (C) Ad5001 2017 * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* @author ad5001 * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;

View file

@ -1,11 +1,17 @@
<?php <?php
/**
/* * ____ __ __ ____
* BushPopulator from BetterGen * /\ _`\ /\ \__ /\ \__ /\ _`\
* Copyright (C) Ad5001 2017 * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* @author ad5001 * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use pocketmine\utils\Random; use pocketmine\utils\Random;

View file

@ -1,12 +1,18 @@
<?php <?php
/**
/* * ____ __ __ ____
* CactusPopulator from BetterGen * /\ _`\ /\ \__ /\ \__ /\ _`\
* Copyright (C) Ad5001 2017 * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* @author ad5001 * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use pocketmine\block\Block; use pocketmine\block\Block;

View file

@ -1,11 +1,17 @@
<?php <?php
/**
/* * ____ __ __ ____
* CavePopulator from BetterGen * /\ _`\ /\ \__ /\ \__ /\ _`\
* Copyright (C) Ad5001 2017 * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* @author ad5001 * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use pocketmine\utils\Random; use pocketmine\utils\Random;

View file

@ -1,10 +1,15 @@
<?php <?php
/**
/* * ____ __ __ ____
* DeadbushPopulator from BetterGen * /\ _`\ /\ \__ /\ \__ /\ _`\
* Copyright (C) Ad5001 2017 * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* @author ad5001 * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;

View file

@ -1,10 +1,15 @@
<?php <?php
/**
/* * ____ __ __ ____
* FallenTreePopulator from BetterGen * /\ _`\ /\ \__ /\ \__ /\ _`\
* Copyright (C) Ad5001 2017 * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* @author ad5001 * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;

View file

@ -1,5 +1,17 @@
<?php <?php
/**
* ____ __ __ ____
* /\ _`\ /\ \__ /\ \__ /\ _`\
* \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
@ -17,13 +29,6 @@ use pocketmine\block\GoldOre;
use pocketmine\block\DiamondOre; use pocketmine\block\DiamondOre;
use Ad5001\BetterGen\Main; use Ad5001\BetterGen\Main;
/*
* FloatingIslandPopulator 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
*/
class FloatingIslandPopulator extends AmountPopulator { class FloatingIslandPopulator extends AmountPopulator {

View file

@ -1,11 +1,17 @@
<?php <?php
/**
/* * ____ __ __ ____
* IglooPopulator from BetterGen * /\ _`\ /\ \__ /\ \__ /\ _`\
* Copyright (C) Ad5001 2017 * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* @author ad5001 * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use pocketmine\utils\Random; use pocketmine\utils\Random;

View file

@ -1,11 +1,17 @@
<?php <?php
/**
/* * ____ __ __ ____
* LakePopulator from BetterGen * /\ _`\ /\ \__ /\ \__ /\ _`\
* Copyright (C) Ad5001 2017 * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* @author ad5001 * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use pocketmine\utils\Random; use pocketmine\utils\Random;

View file

@ -1,11 +1,17 @@
<?php <?php
/**
/* * ____ __ __ ____
* MineshaftPopulator from BetterGen * /\ _`\ /\ \__ /\ \__ /\ _`\
* Copyright (C) Ad5001 2017 * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* @author ad5001 * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;

View file

@ -1,11 +1,17 @@
<?php <?php
/**
/* * ____ __ __ ____
* RavinePopulator from BetterGen * /\ _`\ /\ \__ /\ \__ /\ _`\
* Copyright (C) Ad5001 2017 * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* @author ad5001 * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use pocketmine\utils\Random; use pocketmine\utils\Random;

View file

@ -1,10 +1,15 @@
<?php <?php
/**
/* * ____ __ __ ____
* SugarCanePopulator from BetterGen * /\ _`\ /\ \__ /\ \__ /\ _`\
* Copyright (C) Ad5001 2017 * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* @author ad5001 * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;

View file

@ -1,11 +1,17 @@
<?php <?php
/**
/* * ____ __ __ ____
* TemplePopulator from BetterGen * /\ _`\ /\ \__ /\ \__ /\ _`\
* Copyright (C) Ad5001 2017 * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* @author ad5001 * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use pocketmine\utils\Random; use pocketmine\utils\Random;

View file

@ -1,10 +1,15 @@
<?php <?php
/**
/* * ____ __ __ ____
* TreePopulator from BetterGen * /\ _`\ /\ \__ /\ \__ /\ _`\
* Copyright (C) Ad5001 2017 * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* @author ad5001 * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
@ -57,10 +62,9 @@ class TreePopulator extends AmountPopulator {
if ($y === -1) { if ($y === -1) {
continue; continue;
} }
$tree = new self::$types [$this->type] (); $treeC = self::$types [$this->type];
if ($tree->canPlaceObject($level, $x, $y, $z, $random )) { $tree = new $treeC();
$tree->placeObject($level, $x, $y, $z, $random); $tree->placeObject($level, $x, $y, $z, $random);
}
} }
} }

View file

@ -1,11 +1,17 @@
<?php <?php
/**
/* * ____ __ __ ____
* WellPopulator from BetterGen * /\ _`\ /\ \__ /\ \__ /\ _`\
* Copyright (C) Ad5001 2017 * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* @author ad5001 * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use pocketmine\utils\Random; use pocketmine\utils\Random;

View file

@ -1,10 +1,15 @@
<?php <?php
/**
/* * ____ __ __ ____
* Bush from BetterGen * /\ _`\ /\ \__ /\ \__ /\ _`\
* Copyright (C) Ad5001 2017 * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* @author ad5001 * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\structure; namespace Ad5001\BetterGen\structure;

View file

@ -1,13 +1,17 @@
<?php <?php
/**
/* * ____ __ __ ____
* Cactus from BetterGen * /\ _`\ /\ \__ /\ \__ /\ _`\
* Copyright (C) Ad5001 2017 * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* @author ad5001 * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\structure; namespace Ad5001\BetterGen\structure;
use pocketmine\block\Block; use pocketmine\block\Block;

View file

@ -1,10 +1,15 @@
<?php <?php
/**
/* * ____ __ __ ____
* FallenTree from BetterGen * /\ _`\ /\ \__ /\ \__ /\ _`\
* Copyright (C) Ad5001 2017 * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* @author ad5001 * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\structure; namespace Ad5001\BetterGen\structure;
@ -35,6 +40,7 @@ class FallenTree extends Object {
]; ];
protected $tree; protected $tree;
protected $direction; protected $direction;
protected $random;
/* /*
* Constructs the class * Constructs the class
@ -60,6 +66,7 @@ class FallenTree extends Object {
$randomHeight = round($random->nextBoundedInt(6) - 3); $randomHeight = round($random->nextBoundedInt(6) - 3);
$this->length = $this->tree->trunkHeight + $randomHeight; $this->length = $this->tree->trunkHeight + $randomHeight;
$this->direction = $random->nextBoundedInt(4); $this->direction = $random->nextBoundedInt(4);
$this->random = $random;
switch($this->direction) { switch($this->direction) {
case 0: case 0:
case 1:// Z+ case 1:// Z+
@ -70,7 +77,7 @@ class FallenTree extends Object {
} }
break; break;
case 2: case 2:
case 3: case 3: // X+
if(in_array(false, BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x + $this->length, $y, $z), function($v3, $level) { if(in_array(false, BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x + $this->length, $y, $z), function($v3, $level) {
if(!in_array($level->getBlockIdAt($v3->x, $v3->y, $v3->z), \Ad5001\BetterGen\structure\FallenTree::$overridable)) return false; if(!in_array($level->getBlockIdAt($v3->x, $v3->y, $v3->z), \Ad5001\BetterGen\structure\FallenTree::$overridable)) return false;
}, $level))) { }, $level))) {
@ -96,13 +103,17 @@ class FallenTree extends Object {
$z += 2; $z += 2;
case 1:// Z+ case 1:// Z+
BuildingUtils::fill($level, new Vector3($x, $y, $z), new Vector3($x, $y, $z + $this->length), Block::get($this->tree->trunkBlock, $this->tree->type + 4)); BuildingUtils::fill($level, new Vector3($x, $y, $z), new Vector3($x, $y, $z + $this->length), Block::get($this->tree->trunkBlock, $this->tree->type + 4));
BuildingUtils::fillRandom($level, new Vector3($x + 1, $y, $z), new Vector3($x, $y, $z + $this->length), Block::get(Block::VINE), $this->random);
BuildingUtils::fillRandom($level, new Vector3($x - 1, $y, $z), new Vector3($x, $y, $z + $this->length), Block::get(Block::VINE), $this->random);
break; break;
case 2: case 2:
$level->setBlockIdAt($x, $y, $z, $this->tree->trunkBlock); $level->setBlockIdAt($x, $y, $z, $this->tree->trunkBlock);
$level->setBlockDataAt($x, $y, $z, $this->tree->type); $level->setBlockDataAt($x, $y, $z, $this->tree->type);
$x += 2; $x += 2;
case 3: case 3: // X+
BuildingUtils::fill($level, new Vector3($x, $y, $z), new Vector3($x, $y, $z + $this->length), Block::get($this->tree->trunkBlock, $this->tree->type + 4)); BuildingUtils::fill($level, new Vector3($x, $y, $z), new Vector3($x + $this->length, $y, $z), Block::get($this->tree->trunkBlock, $this->tree->type + 8));
BuildingUtils::fillRandom($level, new Vector3($x, $y, $z + 1), new Vector3($x + $this->length, $y, $z), Block::get(Block::VINE), $this->random);
BuildingUtils::fillRandom($level, new Vector3($x, $y, $z - 1), new Vector3($x + $this->length, $y, $z), Block::get(Block::VINE), $this->random);
break; break;
} }
// Second call to build the last wood block // Second call to build the last wood block

View file

@ -1,10 +1,15 @@
<?php <?php
/**
/* * ____ __ __ ____
* Cactus from BetterGen * /\ _`\ /\ \__ /\ \__ /\ _`\
* Copyright (C) Ad5001 2017 * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* @author ad5001 * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\structure; namespace Ad5001\BetterGen\structure;

View file

@ -1,10 +1,15 @@
<?php <?php
/**
/* * ____ __ __ ____
* SakuraTree from BetterGen * /\ _`\ /\ \__ /\ \__ /\ _`\
* Copyright (C) Ad5001 2017 * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* @author ad5001 * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\structure; namespace Ad5001\BetterGen\structure;

View file

@ -1,10 +1,15 @@
<?php <?php
/**
/* * ____ __ __ ____
* SugarCane from BetterGen * /\ _`\ /\ \__ /\ \__ /\ _`\
* Copyright (C) Ad5001 2017 * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* @author ad5001 * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/ */

View file

@ -1,10 +1,15 @@
<?php <?php
/**
/* * ____ __ __ ____
* Temple from BetterGen * /\ _`\ /\ \__ /\ \__ /\ _`\
* Copyright (C) Ad5001 2017 * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* @author ad5001 * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\structure; namespace Ad5001\BetterGen\structure;

View file

@ -1,11 +1,15 @@
<?php <?php
/**
* ____ __ __ ____
/* * /\ _`\ /\ \__ /\ \__ /\ _`\
* Well from BetterGen * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* Copyright (C) Ad5001 2017 * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* @author ad5001 * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/ */

View file

@ -1,11 +1,16 @@
<?php <?php
/**
/* * ____ __ __ ____
* BuildingUtils from BetterGen * /\ _`\ /\ \__ /\ \__ /\ _`\
* Copyright (C) Ad5001 2017 * \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory * \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* @author ad5001 * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
*/ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/
namespace Ad5001\BetterGen\utils; namespace Ad5001\BetterGen\utils;
@ -34,12 +39,29 @@ class BuildingUtils {
* @return void * @return void
*/ */
public static function fill(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block = null) { public static function fill(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block = null) {
if ($block == null) if ($block == null) $block = Block::get(Block::AIR);
$block = Block::get(Block::AIR);
list($pos1, $pos2 ) = self::minmax($pos1, $pos2); list($pos1, $pos2 ) = self::minmax($pos1, $pos2);
for($x = $pos1->x; $x >= $pos2->x; $x --) for($x = $pos1->x; $x >= $pos2->x; $x --) for($y = $pos1->y; $y >= $pos2->y; $y --) for($z = $pos1->z; $z >= $pos2->z; $z --) {
for($y = $pos1->y; $y >= $pos2->y; $y --) $level->setBlockIdAt($x, $y, $z, $block->getId ());
for($z = $pos1->z; $z >= $pos2->z; $z --) { $level->setBlockDataAt($x, $y, $z, $block->getDamage ());
}
}
/*
* Fills an area randomly
* @param $level pocketmine\level\ChunkManager
* @param $pos1 pocketmine\math\Vector3
* @param $pos2 pocketmine\math\Vector3
* @param $block pocketmine\block\Block
* @param $random pocketmine\utils
* @param $randMax pocketmine\utils
* @return void
*/
public static function fillRandom(ChunkManager $level, Vector3 $pos1, Vector3 $pos2, Block $block = null, Random $random = null, $randMax = 3) {
if ($block == null) $block = Block::get(Block::AIR);
list($pos1, $pos2 ) = self::minmax($pos1, $pos2);
for($x = $pos1->x; $x >= $pos2->x; $x --) for($y = $pos1->y; $y >= $pos2->y; $y --) for($z = $pos1->z; $z >= $pos2->z; $z --) if($random !== null ? $random->nextBoundedInt($randMax) == 0 : rand(0, $randMax) == 0) {
$level->setBlockIdAt($x, $y, $z, $block->getId ()); $level->setBlockIdAt($x, $y, $z, $block->getId ());
$level->setBlockDataAt($x, $y, $z, $block->getDamage ()); $level->setBlockDataAt($x, $y, $z, $block->getDamage ());
} }
@ -56,9 +78,7 @@ class BuildingUtils {
public static function fillCallback(Vector3 $pos1, Vector3 $pos2, callable $call, ...$params) : array { public static function fillCallback(Vector3 $pos1, Vector3 $pos2, callable $call, ...$params) : array {
list($pos1, $pos2 ) = self::minmax($pos1, $pos2); list($pos1, $pos2 ) = self::minmax($pos1, $pos2);
$return = []; $return = [];
for($x = $pos1->x; $x >= $pos2->x; $x --) for($x = $pos1->x; $x >= $pos2->x; $x --) for($y = $pos1->y; $y >= $pos2->y; $y --) for($z = $pos1->z; $z >= $pos2->z; $z --) {
for($y = $pos1->y; $y >= $pos2->y; $y --)
for($z = $pos1->z; $z >= $pos2->z; $z --) {
$return[] = call_user_func($call, new Vector3($x, $y, $z ), ...$params); $return[] = call_user_func($call, new Vector3($x, $y, $z ), ...$params);
} }
return $return; return $return;

View file

@ -0,0 +1,29 @@
<?php
/**
* ____ __ __ ____
* /\ _`\ /\ \__ /\ \__ /\ _`\
* \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/
namespace Ad5001\BetterGen\utils;
# Communs utils under no namespace made for a specific usage
class CommonUtils {
/**
* Searches case insensitivly array $haystack for $needle.
* src: http://php.net/manual/en/function.in-array.php#89256
* @param mixed $needle
* @param array $haystack
* @return bool
*/
static function in_arrayi($needle, array $haystack) :bool {
return in_array(strtolower($needle), array_map('strtolower', $haystack));
}
}