diff --git a/README.md b/README.md index bb31282..3bf6db7 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,10 @@

PocketMine's Tomorrow's World Generator.

Welcome user to the home of a new PocketMine World Generator which features 9 new/modified biomes: + ------ -# Commun: -### Commun structures to all biomes features: +# Common: +### Common structures to all biomes features: 1.

Mineshafts:

2.

Ravines:

@@ -12,8 +13,6 @@ Welcome user to the home of a new PocketMine World Generator which features 9 ne 4.

Floating islands:

- - ----- # [NEW BIOME] Sakura forests: @@ -23,7 +22,7 @@ Welcome user to the home of a new PocketMine World Generator which features 9 ne ----- # [NEW BIOMES] Mesa Mountains & Plains -### These biomes are inspired (but not completly taken) from Minecraft PC. +### These biomes are inspired (but not completely taken) from Minecraft PC. @@ -31,13 +30,13 @@ Welcome user to the home of a new PocketMine World Generator which features 9 ne # Better Desert: ### The desert has been reworked and now includes the Minecraft PC's temples and wells ! -### Additionaly, deadbush, sugar cane and cactus are here too ! +### Additionally, deadbush, sugar cane and cactus are here too ! ----- # Better Ice Plains -### Ice plains got redisigned ! There is now snow instead of grass at it's bottom ! On the plus side, Igloos were imported from Minecraft PC ! +### Ice plains got redesigned ! There is now snow instead of grass at it's bottom ! On the plus side, Igloos were imported from Minecraft PC ! diff --git a/plugin.yml b/plugin.yml index db56c8c..8c90a65 100644 --- a/plugin.yml +++ b/plugin.yml @@ -6,7 +6,7 @@ # \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ # \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ # \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ -# Tommorow's pocketmine generator. +# Tomorrow's pocketmine generator. # @author Ad5001 # @link https://github.com/Ad5001/BetterGen name: BetterGen diff --git a/resources/loots/mineshaft.json b/resources/loots/mineshaft.json index 4d65d11..9f326e5 100644 --- a/resources/loots/mineshaft.json +++ b/resources/loots/mineshaft.json @@ -45,7 +45,7 @@ "id": 263, "data": 0 }, - "beethroot seeds": { + "beetroot seeds": { "percentage": 32, "minCount": 2, "maxCount": 4, diff --git a/src/Ad5001/BetterGen/Main.php b/src/Ad5001/BetterGen/Main.php index 8fe39cd..55d69cb 100644 --- a/src/Ad5001/BetterGen/Main.php +++ b/src/Ad5001/BetterGen/Main.php @@ -7,13 +7,16 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ namespace Ad5001\BetterGen; +use pocketmine\command\Command; +use pocketmine\command\CommandSender; +use pocketmine\event\Listener; use pocketmine\plugin\PluginBase; use pocketmine\level\generator\biome\Biome; use pocketmine\level\generator\Generator; @@ -35,7 +38,7 @@ use pocketmine\item\Item; use pocketmine\event\player\PlayerInteractEvent; use pocketmine\event\block\BlockBreakEvent; -class Main extends PluginBase implements \pocketmine\event\Listener { +class Main extends PluginBase implements Listener { const PREFIX = "§l§o§b[§r§l§2Better§aGen§o§b]§r§f "; const SAKURA_FOREST = 100; // Letting some place for future biomes. @@ -45,7 +48,7 @@ class Main extends PluginBase implements \pocketmine\event\Listener { public function onEnable() { $this->getServer()->getPluginManager()->registerEvents($this, $this); Generator::addGenerator(BetterNormal::class, "betternormal"); - if($this->isOtherNS()) $this->getLogger()->warning("Tesseract detected. Note that some parts of the generator could not work properly"); + if($this->isOtherNS()) $this->getLogger()->warning("Tesseract detected. Note that Tesseract is not up to date with the generation structure and some generation features may be limited or not working"); @mkdir($this->getDataFolder()); if(! file_exists(LootTable::getPluginFolder(). "processingLoots.json")) file_put_contents(LootTable::getPluginFolder(). "processingLoots.json", "{}"); @@ -65,7 +68,7 @@ class Main extends PluginBase implements \pocketmine\event\Listener { * @param $args array * return bool */ - public function onCommand(\pocketmine\command\CommandSender $sender, \pocketmine\command\Command $cmd, $label, array $args): bool { + public function onCommand(CommandSender $sender, Command $cmd, $label, array $args): bool { switch($cmd->getName()) { case "createworld" : // /createworld [generator = betternormal] [seed = rand()] [options(json)] switch(count($args)) { @@ -145,6 +148,7 @@ class Main extends PluginBase implements \pocketmine\event\Listener { return true; break; } + return false; } /* diff --git a/src/Ad5001/BetterGen/biome/BetterDesert.php b/src/Ad5001/BetterGen/biome/BetterDesert.php index b4e715d..f33e7fc 100644 --- a/src/Ad5001/BetterGen/biome/BetterDesert.php +++ b/src/Ad5001/BetterGen/biome/BetterDesert.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -24,6 +24,7 @@ use Ad5001\BetterGen\populator\SugarCanePopulator; class BetterDesert extends SandyBiome implements Mountainable { public function __construct() { + parent::__construct(); $deadBush = new DeadbushPopulator (); $deadBush->setBaseAmount(1); $deadBush->setRandomAmount(2); diff --git a/src/Ad5001/BetterGen/biome/BetterForest.php b/src/Ad5001/BetterGen/biome/BetterForest.php index eaffb3b..69db0e0 100644 --- a/src/Ad5001/BetterGen/biome/BetterForest.php +++ b/src/Ad5001/BetterGen/biome/BetterForest.php @@ -8,7 +8,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -66,25 +66,25 @@ class BetterForest extends ForestBiome implements Mountainable { public function getName() { return str_ireplace(" ", "", self::$types[$this->type]); } - - /* - * Returns the ID relativly. + + /** + * Returns the ID relatively. + * @return int */ 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 + /** + * @param string $name + * @param string $treeClass + * @param array $infos * @return bool */ public static function registerForest(string $name, string $treeClass, array $infos): bool { self::$types [] = str_ireplace("tree", "", explode("\\", $treeClass ) [count(explode("\\", $treeClass ) )] ) . " Forest"; TreePopulator::$types [] = $treeClass; 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 )); + self::register(Main::SAKURA_FOREST + (count(self::$types ) - 2), new BetterForest(count(self::$types ) - 1, $infos )); + return true; } } \ No newline at end of file diff --git a/src/Ad5001/BetterGen/biome/BetterIcePlains.php b/src/Ad5001/BetterGen/biome/BetterIcePlains.php index 5b58eb1..e4e5529 100644 --- a/src/Ad5001/BetterGen/biome/BetterIcePlains.php +++ b/src/Ad5001/BetterGen/biome/BetterIcePlains.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -46,8 +46,9 @@ class BetterIcePlains extends SnowyBiome implements Mountainable { return "BetterIcePlains"; } - /* - * Returns biome's id. + /** + * Returns the biomes' id. + * @return int biome id */ public function getId() { return Biome::ICE_PLAINS; diff --git a/src/Ad5001/BetterGen/biome/BetterMesa.php b/src/Ad5001/BetterGen/biome/BetterMesa.php index f49eaf6..2976d70 100644 --- a/src/Ad5001/BetterGen/biome/BetterMesa.php +++ b/src/Ad5001/BetterGen/biome/BetterMesa.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -28,6 +28,7 @@ use Ad5001\BetterGen\populator\SugarCanePopulator; class BetterMesa extends SandyBiome { public function __construct() { + parent::__construct(); $deadBush = new DeadbushPopulator (); $deadBush->setBaseAmount(1); $deadBush->setRandomAmount(2); diff --git a/src/Ad5001/BetterGen/biome/BetterMesaPlains.php b/src/Ad5001/BetterGen/biome/BetterMesaPlains.php index 326bacd..cb700f3 100644 --- a/src/Ad5001/BetterGen/biome/BetterMesaPlains.php +++ b/src/Ad5001/BetterGen/biome/BetterMesaPlains.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -26,6 +26,7 @@ use Ad5001\BetterGen\Main; class BetterMesaPlains extends SandyBiome { public function __construct() { + parent::__construct(); $deadBush = new DeadbushPopulator (); $deadBush->setBaseAmount(1); $deadBush->setRandomAmount(2); diff --git a/src/Ad5001/BetterGen/biome/BetterRiver.php b/src/Ad5001/BetterGen/biome/BetterRiver.php index d6d97d5..ea18996 100644 --- a/src/Ad5001/BetterGen/biome/BetterRiver.php +++ b/src/Ad5001/BetterGen/biome/BetterRiver.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -45,7 +45,7 @@ class BetterRiver extends Biome { } /* - * Returns the ID relativly. + * Returns the ID relatively. */ public function getId() { return Biome::RIVER; diff --git a/src/Ad5001/BetterGen/biome/Mountainable.php b/src/Ad5001/BetterGen/biome/Mountainable.php index 6c47f0d..f2175a0 100644 --- a/src/Ad5001/BetterGen/biome/Mountainable.php +++ b/src/Ad5001/BetterGen/biome/Mountainable.php @@ -7,13 +7,13 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ namespace Ad5001\BetterGen\biome; -// Class to iplement when the biome can be set as a mountain +// Class to implement when the biome can be set as a mountain interface Mountainable { } \ No newline at end of file diff --git a/src/Ad5001/BetterGen/generator/BetterBiomeSelector.php b/src/Ad5001/BetterGen/generator/BetterBiomeSelector.php index 86c1b3c..48debb5 100644 --- a/src/Ad5001/BetterGen/generator/BetterBiomeSelector.php +++ b/src/Ad5001/BetterGen/generator/BetterBiomeSelector.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -33,6 +33,7 @@ class BetterBiomeSelector extends BiomeSelector { private $map = [ ]; private $lookup; public function __construct(Random $random, callable $lookup, Biome $fallback) { + parent::__construct($random, $lookup, $fallback); $this->fallback = $fallback; $this->lookup = $lookup; $this->temperature = new Simplex($random, 2, 1 / 16, 1 / 512); diff --git a/src/Ad5001/BetterGen/generator/BetterNormal.php b/src/Ad5001/BetterGen/generator/BetterNormal.php index 5a59a19..3b88849 100644 --- a/src/Ad5001/BetterGen/generator/BetterNormal.php +++ b/src/Ad5001/BetterGen/generator/BetterNormal.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -48,7 +48,7 @@ use Ad5001\BetterGen\populator\FloatingIslandPopulator; use Ad5001\BetterGen\Main; class BetterNormal extends Generator { - const NOT_OVERWRITABLE = [ + const NOT_OVERWRITABLE = [ Block::STONE, Block::GRAVEL, Block::BEDROCK, @@ -68,6 +68,7 @@ class BetterNormal extends Generator { protected $populators = [ ]; protected $generationPopulators = [ ]; public static $biomes = [ ]; + /** @var Biome[] */ public static $biomeById = [ ]; public static $levels = [ ]; protected static $GAUSSIAN_KERNEL = null; // From main class @@ -233,6 +234,7 @@ class BetterNormal extends Generator { * @param $rainfall float */ public static function getBiome($temperature, $rainfall) { + $ret = null; if (! isset(self::$biomes [( string ) round($rainfall, 1 )] )) { while(! isset(self::$biomes [( string ) round($rainfall, 1 )] ) ) { if (abs($rainfall - round($rainfall, 1 ) ) >= 0.05) @@ -254,9 +256,8 @@ class BetterNormal extends Generator { } if (is_string($ret )) { $ret = new $ret (); - } else { - return $ret; } + return $ret; } /* @@ -265,7 +266,7 @@ class BetterNormal extends Generator { * @return Biome */ public function getBiomeById(int $id): Biome { - return self::$biomeById[$id] ?? self::$biomeById(Biome::OCEAN); + return self::$biomeById[$id] ?? self::$biomeById[Biome::OCEAN]; } /* @@ -388,7 +389,7 @@ class BetterNormal extends Generator { } /* - * Generates the genration kernel based on smooth size (here 2) + * Generates the generation kernel based on smooth size (here 2) */ private static function generateKernel() { self::$GAUSSIAN_KERNEL = [ ]; diff --git a/src/Ad5001/BetterGen/loot/LootTable.php b/src/Ad5001/BetterGen/loot/LootTable.php index cd0798f..2f1ab26 100644 --- a/src/Ad5001/BetterGen/loot/LootTable.php +++ b/src/Ad5001/BetterGen/loot/LootTable.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -23,7 +23,7 @@ use pocketmine\nbt\NBT; /* * This class is used for loot setting. - * Please note that they AREN'T as powerfull as PC ones due to some implementations limitations. + * Please note that they AREN'T as powerful as PC ones due to some implementations limitations. * Loot table format: * { * "max": Max number of loots (storable amount) @@ -33,9 +33,9 @@ use pocketmine\nbt\NBT; * "maxCount": Maximal count * "id": Id of the item * "data": Item damage - * "tags": {"display": {"Name": "Example NBT data"}}. This parameter is optionnal - * "minStacks": If choosen, the minimum amount of stacks that can be found - * "maxStacks": If choosen the maximum number of stacks that can be choosen + * "tags": {"display": {"Name": "Example NBT data"}}. This parameter is optional + * "minStacks": If chosen, the minimum amount of stacks that can be found + * "maxStacks": If chosen the maximum number of stacks that can be chosen * } * } */ @@ -55,7 +55,7 @@ class LootTable { const LOOT_MINESHAFT = 2; /* - * Asyncronous loot table choosing + * Asynchronous loot table choosing * @param $place pocketmine\math\Vector3 * @param $type int * @param $random pocketmine\utils\Random @@ -80,7 +80,7 @@ class LootTable { } /* - * Syncronous inventory filling with loot table. + * Synchronous inventory filling with loot table. * @param $inv pocketmine\inventory\BaseInventory * @param $pos pocketmine\math\Vector3 * @return void @@ -96,7 +96,7 @@ class LootTable { for($i = 0; $i <= $randCount; $i++) { $rand = rand(0, count($loots)); $items[$rand] = Item::get($loot["id"], $loot["data"], rand($loot["minCount"], $loot["maxCount"])); - if(isset($loot["tags"])) $items[$rand]->setCompoundTag(NBT::fromJSON($loot["tags"])); + if(isset($loot["tags"])) $items[$rand]->setCompoundTag(NBT::parseJSON($loot["tags"])); } } $inv->setContents($items); diff --git a/src/Ad5001/BetterGen/populator/AmountPopulator.php b/src/Ad5001/BetterGen/populator/AmountPopulator.php index 43a85e2..6ae8765 100644 --- a/src/Ad5001/BetterGen/populator/AmountPopulator.php +++ b/src/Ad5001/BetterGen/populator/AmountPopulator.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ diff --git a/src/Ad5001/BetterGen/populator/BushPopulator.php b/src/Ad5001/BetterGen/populator/BushPopulator.php index 3d80926..765166c 100644 --- a/src/Ad5001/BetterGen/populator/BushPopulator.php +++ b/src/Ad5001/BetterGen/populator/BushPopulator.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ diff --git a/src/Ad5001/BetterGen/populator/CactusPopulator.php b/src/Ad5001/BetterGen/populator/CactusPopulator.php index f9345a2..d1802a4 100644 --- a/src/Ad5001/BetterGen/populator/CactusPopulator.php +++ b/src/Ad5001/BetterGen/populator/CactusPopulator.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ diff --git a/src/Ad5001/BetterGen/populator/CavePopulator.php b/src/Ad5001/BetterGen/populator/CavePopulator.php index 943d0b4..fb5ab45 100644 --- a/src/Ad5001/BetterGen/populator/CavePopulator.php +++ b/src/Ad5001/BetterGen/populator/CavePopulator.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -123,7 +123,7 @@ class CavePopulator extends AmountPopulator { $y --; } $z += round(($random->nextBoundedInt(round(30 * ($depth / 10) ) + 1 ) / 10 - 1)); - return [ ]; + return; } } $repeat = $random->nextBoundedInt(25 ) + 15; diff --git a/src/Ad5001/BetterGen/populator/DeadbushPopulator.php b/src/Ad5001/BetterGen/populator/DeadbushPopulator.php index 392f66a..edf583e 100644 --- a/src/Ad5001/BetterGen/populator/DeadbushPopulator.php +++ b/src/Ad5001/BetterGen/populator/DeadbushPopulator.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ diff --git a/src/Ad5001/BetterGen/populator/FallenTreePopulator.php b/src/Ad5001/BetterGen/populator/FallenTreePopulator.php index 890dc6f..a16bcde 100644 --- a/src/Ad5001/BetterGen/populator/FallenTreePopulator.php +++ b/src/Ad5001/BetterGen/populator/FallenTreePopulator.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ diff --git a/src/Ad5001/BetterGen/populator/FloatingIslandPopulator.php b/src/Ad5001/BetterGen/populator/FloatingIslandPopulator.php index c58f251..35c0e3a 100644 --- a/src/Ad5001/BetterGen/populator/FloatingIslandPopulator.php +++ b/src/Ad5001/BetterGen/populator/FloatingIslandPopulator.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -54,7 +54,7 @@ class FloatingIslandPopulator extends AmountPopulator { $height = $this->buildIslandBottomShape($level, new Vector3($x, $y, $z), $radius, $random); $this->populateOres($level, new Vector3($x, $y - 1, $z), $radius * 2, $height, $random); $chunk = $level->getChunk($chunkX, $chunkZ); - $biome = BetterNormal::getBiomeById($chunk->getBiomeId($x % 16, $z % 16));//static call + $biome = BetterNormal::$biomeById[$chunk->getBiomeId($x % 16, $z % 16)]; $populators = $biome->getPopulators(); foreach($populators as $populator) { $populator->populate($level, $chunkX, $chunkZ, $random); @@ -94,10 +94,7 @@ class FloatingIslandPopulator extends AmountPopulator { */ public function buildIslandBottomShape(ChunkManager $level, Vector3 $pos, int $radius, Random $random) { $pos = $pos->round(); - $xx = $pos->x; - $zz = $z; //undefined $currentLen = 1; - $isEdge = false; $hBound = 0; $current = 0; for($y = $pos->y - 1; $radius > 0; $y--) { @@ -110,7 +107,7 @@ class FloatingIslandPopulator extends AmountPopulator { } if(abs(abs($x - $pos->x) ** 2) + abs(abs($z - $pos->z) ** 2) <= ($radius ** 2) * 0.67 && $y < 128) { if($chunk = $level->getChunk($x >> 4, $z >> 4)) { - $biome = BetterNormal::getBiomeById($chunk->getBiomeId($x % 16, $z % 16));//static call + $biome = BetterNormal::$biomeById[$chunk->getBiomeId($x % 16, $z % 16)]; $block = $biome->getGroundCover()[$pos->y - $y - 1] ?? Block::get(Block::STONE); $block = $block->getId(); } elseif($random->nextBoundedInt(5) == 0 && $isEdge) { @@ -132,7 +129,7 @@ class FloatingIslandPopulator extends AmountPopulator { $radius--; } } - return $pos->y - 1 - $y; + //return $pos->y - 1 - $y;//void } diff --git a/src/Ad5001/BetterGen/populator/IglooPopulator.php b/src/Ad5001/BetterGen/populator/IglooPopulator.php index 292669c..cc49f2e 100644 --- a/src/Ad5001/BetterGen/populator/IglooPopulator.php +++ b/src/Ad5001/BetterGen/populator/IglooPopulator.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ diff --git a/src/Ad5001/BetterGen/populator/LakePopulator.php b/src/Ad5001/BetterGen/populator/LakePopulator.php index 7957cc0..018e465 100644 --- a/src/Ad5001/BetterGen/populator/LakePopulator.php +++ b/src/Ad5001/BetterGen/populator/LakePopulator.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ diff --git a/src/Ad5001/BetterGen/populator/MineshaftPopulator.php b/src/Ad5001/BetterGen/populator/MineshaftPopulator.php index 3f740f8..78e639b 100644 --- a/src/Ad5001/BetterGen/populator/MineshaftPopulator.php +++ b/src/Ad5001/BetterGen/populator/MineshaftPopulator.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -23,6 +23,7 @@ use Ad5001\BetterGen\loot\LootTable; class MineshaftPopulator extends AmountPopulator { protected $maxPath; + /** @var ChunkManager */ protected $level; const DIR_XPLUS = 0; const DIR_XMIN = 1; @@ -69,15 +70,14 @@ class MineshaftPopulator extends AmountPopulator { } } } - - /* + + /** * Builds a mineshaft part and return applicable directions - * @param $x int - * @param $y int - * @param $z int - * @param $dir int - * @param $random pocketmine\utils\Random - * @param $deepneth int + * @param int $x + * @param int $y + * @param int $z + * @param int $dir + * @param Random $random */ public function generateMineshaftPart(int $x, int $y, int $z, int $dir, Random $random) { if ($this->maxPath -- < 1) @@ -91,18 +91,18 @@ class MineshaftPopulator extends AmountPopulator { // First, filling everything blank. BuildingUtils::fill($this->level, new Vector3($x, $y, $z - 1 ), new Vector3($x + 4, $y + 2, $z + 1 ), Block::get(Block::AIR )); // Then, making sure the floor is solid. - BuildingUtils::fillCallback(new Vector3($x, $y - 1, $z - 1 ), new Vector3($x + 4, $y - 1, $z + 1 ), function ($v3, $level) { + BuildingUtils::fillCallback(new Vector3($x, $y - 1, $z - 1 ), new Vector3($x + 4, $y - 1, $z + 1 ), function ($v3, ChunkManager $level) { if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR) $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); }, $this->level); // Putting rails - BuildingUtils::fillCallback(new Vector3($x, $y, $z ), new Vector3($x + 4, $y, $z ), function ($v3, $level, $random) { + BuildingUtils::fillCallback(new Vector3($x, $y, $z ), new Vector3($x + 4, $y, $z ), function ($v3, ChunkManager $level, Random $random) { if ($random->nextBoundedInt(3 ) !== 0) { $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL); $level->setBlockDataAt($v3->x, $v3->y, $v3->z, 1); } }, $this->level, $random); - // After this, building the floor maintener (the wood structure) + // After this, building the floor maintainer (the wood structure) $level->setBlockIdAt($x, $y, $z - 1, Block::FENCE); $level->setBlockIdAt($x, $y, $z + 1, Block::FENCE); $level->setBlockIdAt($x, $y + 1, $z - 1, Block::FENCE); @@ -143,7 +143,7 @@ class MineshaftPopulator extends AmountPopulator { $level->setBlockDataAt($v3->x, $v3->y, $v3->z, 1); } }, $this->level, $random); - // After this, building the floor maintener (the wood structure) + // After this, building the floor maintainer (the wood structure) $level->setBlockIdAt($x, $y, $z - 1, Block::FENCE); $level->setBlockIdAt($x, $y, $z + 1, Block::FENCE); $level->setBlockIdAt($x, $y + 1, $z - 1, Block::FENCE); @@ -162,7 +162,7 @@ class MineshaftPopulator extends AmountPopulator { if ($direction2 == 0) $direction2 = 2; if ($direction2 == 1) - $direction2 = + $direction2 = 4; LootTable::buildLootTable(new Vector3($x - $direction2, $y, $z + $direction ), LootTable::LOOT_MINESHAFT, $random); } if ($random->nextBoundedInt(30 ) !== 0) @@ -172,19 +172,19 @@ class MineshaftPopulator extends AmountPopulator { // First, filling everything blank. BuildingUtils::fill($this->level, new Vector3($x - 1, $y, $z ), new Vector3($x + 1, $y + 2, $z + 4 )); // Then, making sure the floor is solid. - BuildingUtils::fillCallback(new Vector3($x - 1, $y - 1, $z ), new Vector3($x + 1, $y - 1, $z + 4 ), function ($v3, $level) { + BuildingUtils::fillCallback(new Vector3($x - 1, $y - 1, $z ), new Vector3($x + 1, $y - 1, $z + 4 ), function ($v3, ChunkManager $level) { if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR) $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); }, $this->level); // Putting rails - BuildingUtils::fillCallback(new Vector3($x, $y, $z ), new Vector3($x, $y, $z + 4 ), function ($v3, $level, $random) { + BuildingUtils::fillCallback(new Vector3($x, $y, $z ), new Vector3($x, $y, $z + 4 ), function ($v3, ChunkManager $level, Random $random) { if ($random->nextBoundedInt(3 ) !== 0) { $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL); $level->setBlockDataAt($v3->x, $v3->y, $v3->z, 0); } }, $this->level, $random); - // After this, building the floor maintener (the wood structure) + // After this, building the floor maintainer (the wood structure) $level->setBlockIdAt($x - 1, $y, $z, Block::FENCE); $level->setBlockIdAt($x + 1, $y, $z, Block::FENCE); $level->setBlockIdAt($x - 1, $y + 1, $z, Block::FENCE); @@ -225,7 +225,7 @@ class MineshaftPopulator extends AmountPopulator { $level->setBlockDataAt($v3->x, $v3->y, $v3->z, 0); } }, $this->level, $random); - // After this, building the floor maintener (the wood structure) + // After this, building the floor maintainer (the wood structure) $level->setBlockIdAt($x - 1, $y, $z, Block::FENCE); $level->setBlockIdAt($x + 1, $y, $z, Block::FENCE); $level->setBlockIdAt($x - 1, $y + 1, $z, Block::FENCE); @@ -288,7 +288,7 @@ class MineshaftPopulator extends AmountPopulator { } // Then, making sure the floor is solid. - BuildingUtils::fillCallback(new Vector3($x + 1, $y - 1, $z - 1 ), new Vector3($x - 1, $y - 1, $z + 1 ), function ($v3, $level) { + BuildingUtils::fillCallback(new Vector3($x + 1, $y - 1, $z - 1 ), new Vector3($x - 1, $y - 1, $z + 1 ), function ($v3, ChunkManager $level) { if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR) $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); @@ -315,7 +315,7 @@ class MineshaftPopulator extends AmountPopulator { $choose = $random->nextBoundedInt(4); unset($possiblePathes [$chooseNew] [$choose]); } - // Buidling pathes + // Building pathes foreach($possiblePathes [0] as $path ) { switch ($path) { case self::DIR_XPLUS : diff --git a/src/Ad5001/BetterGen/populator/RavinePopulator.php b/src/Ad5001/BetterGen/populator/RavinePopulator.php index a15f32c..ce1c47c 100644 --- a/src/Ad5001/BetterGen/populator/RavinePopulator.php +++ b/src/Ad5001/BetterGen/populator/RavinePopulator.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ diff --git a/src/Ad5001/BetterGen/populator/SugarCanePopulator.php b/src/Ad5001/BetterGen/populator/SugarCanePopulator.php index 4fde840..1ac6c15 100644 --- a/src/Ad5001/BetterGen/populator/SugarCanePopulator.php +++ b/src/Ad5001/BetterGen/populator/SugarCanePopulator.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ diff --git a/src/Ad5001/BetterGen/populator/TemplePopulator.php b/src/Ad5001/BetterGen/populator/TemplePopulator.php index d957405..24d1d52 100644 --- a/src/Ad5001/BetterGen/populator/TemplePopulator.php +++ b/src/Ad5001/BetterGen/populator/TemplePopulator.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ diff --git a/src/Ad5001/BetterGen/populator/TreePopulator.php b/src/Ad5001/BetterGen/populator/TreePopulator.php index d01952d..d8edd40 100644 --- a/src/Ad5001/BetterGen/populator/TreePopulator.php +++ b/src/Ad5001/BetterGen/populator/TreePopulator.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ diff --git a/src/Ad5001/BetterGen/populator/WellPopulator.php b/src/Ad5001/BetterGen/populator/WellPopulator.php index 5dd0398..664b242 100644 --- a/src/Ad5001/BetterGen/populator/WellPopulator.php +++ b/src/Ad5001/BetterGen/populator/WellPopulator.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ diff --git a/src/Ad5001/BetterGen/structure/Bush.php b/src/Ad5001/BetterGen/structure/Bush.php index af1c2e6..022ba97 100644 --- a/src/Ad5001/BetterGen/structure/Bush.php +++ b/src/Ad5001/BetterGen/structure/Bush.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -22,7 +22,7 @@ use pocketmine\math\Vector3; use pocketmine\level\generator\object\Object; class Bush extends Object { - public $overridable = [ + public $overridable = [ Block::AIR => true, 17 => true, Block::SNOW_LAYER => true, diff --git a/src/Ad5001/BetterGen/structure/Cactus.php b/src/Ad5001/BetterGen/structure/Cactus.php index e2ff8a7..4e01f0d 100644 --- a/src/Ad5001/BetterGen/structure/Cactus.php +++ b/src/Ad5001/BetterGen/structure/Cactus.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ diff --git a/src/Ad5001/BetterGen/structure/FallenTree.php b/src/Ad5001/BetterGen/structure/FallenTree.php index 8efdba3..661a4c8 100644 --- a/src/Ad5001/BetterGen/structure/FallenTree.php +++ b/src/Ad5001/BetterGen/structure/FallenTree.php @@ -1,54 +1,56 @@ 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 + 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 ]; + /** @var Tree */ protected $tree; protected $direction; protected $random; - + private $length; + /* * Constructs the class * @param $tree Tree - * @throws Exeption + * @throws Exception */ public function __construct(Tree $tree) { $this->tree = $tree; } - + /* * Places a fallen tree * @param $level pocketmine\level\ChunkManager @@ -62,27 +64,27 @@ class FallenTree extends Object { $this->length = $this->tree->trunkHeight + $randomHeight; $this->direction = $random->nextBoundedInt(4); $this->random = $random; - switch($this->direction) { + switch ($this->direction) { case 0: case 1:// Z+ - if(in_array(false, BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x, $y, $z + $this->length), function($v3, $level) { - if(!in_array($level->getBlockIdAt($v3->x, $v3->y, $v3->z), $this->overridable)) return false; - }, $level))) { - return false; - } - break; + if (in_array(false, BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x, $y, $z + $this->length), function ($v3, ChunkManager $level) { + if (!in_array($level->getBlockIdAt($v3->x, $v3->y, $v3->z), $this->overridable)) return false; else return true; + }, $level))) { + return false; + } + break; case 2: 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($level->getBlockIdAt($v3->x, $v3->y, $v3->z), $this->overridable)) return false; - }, $level))) { - return false; - } - break; + if (in_array(false, BuildingUtils::fillCallback(new Vector3($x, $y, $z), new Vector3($x + $this->length, $y, $z), function ($v3, ChunkManager $level) { + if (!in_array($level->getBlockIdAt($v3->x, $v3->y, $v3->z), $this->overridable)) return false; else return true; + }, $level))) { + return false; + } + break; } return true; } - + /* * Places a fallen tree * @param $level pocketmine\level\ChunkManager @@ -92,37 +94,39 @@ class FallenTree extends Object { */ public function placeObject(ChunkManager $level, $x, $y, $z) { echo "Placing at $x $y $z FallenTree\n"; - switch($this->direction) { + switch ($this->direction) { case 0: - $level->setBlockIdAt($x, $y, $z, $this->tree->trunkBlock); - $level->setBlockDataAt($x, $y, $z, $this->tree->type); - $z += 2; + $level->setBlockIdAt($x, $y, $z, $this->tree->trunkBlock); + $level->setBlockDataAt($x, $y, $z, $this->tree->type); + $z += 2; + break; 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::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; + 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; case 2: - $level->setBlockIdAt($x, $y, $z, $this->tree->trunkBlock); - $level->setBlockDataAt($x, $y, $z, $this->tree->type); - $x += 2; + $level->setBlockIdAt($x, $y, $z, $this->tree->trunkBlock); + $level->setBlockDataAt($x, $y, $z, $this->tree->type); + $x += 2; + break; case 3: // X+ - 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; + 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; } // Second call to build the last wood block - switch($this->direction) { + switch ($this->direction) { case 1: - $level->setBlockIdAt($x, $y, $z + $this->length + 2, $this->tree->trunkBlock); - break; + $level->setBlockIdAt($x, $y, $z + $this->length + 2, $this->tree->trunkBlock); + break; case 3: - $level->setBlockIdAt($x + $this->length + 2, $y, $z, $this->tree->trunkBlock); - break; + $level->setBlockIdAt($x + $this->length + 2, $y, $z, $this->tree->trunkBlock); + break; } } - + /* * Places a Block * @param $x int @@ -131,9 +135,9 @@ class FallenTree extends Object { * @param $level pocketmine\level\ChunkManager */ public function placeBlock($x, $y, $z, ChunkManager $level) { - if (isset($this->overridable [$level->getBlockIdAt($x, $y, $z )] ) && ! isset($this->overridable [$level->getBlockIdAt($x, $y - 1, $z )] )) { - $level->setBlockIdAt($x, $y, $z, $this->trunk [0]); - $level->setBlockDataAt($x, $y, $z, $this->trunk [1]); + if (isset($this->overridable [$level->getBlockIdAt($x, $y, $z)]) && !isset($this->overridable [$level->getBlockIdAt($x, $y - 1, $z)])) { + $level->setBlockIdAt($x, $y, $z, $this->tree->trunkBlock); + $level->setBlockDataAt($x, $y, $z, $this->tree->type); } } } \ No newline at end of file diff --git a/src/Ad5001/BetterGen/structure/Igloo.php b/src/Ad5001/BetterGen/structure/Igloo.php index 71a231f..8617d4b 100644 --- a/src/Ad5001/BetterGen/structure/Igloo.php +++ b/src/Ad5001/BetterGen/structure/Igloo.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -59,7 +59,7 @@ class Igloo extends Object { if (! isset($this->overridable [$level->getBlockIdAt($xx, $yy, $zz )] )) return false; break; - case 2 : // Entrence is z+ + case 2 : // Entrance is z+ for($xx = $x - 3; $xx <= $x + 3; $xx ++) for($yy = $y + 1; $yy <= $y + 4; $yy ++) for($zz = $z - 3; $zz <= $z + 4; $zz ++) @@ -84,6 +84,7 @@ class Igloo extends Object { * @param $y int * @param $z int * @param $random pocketmine\utils\Random + * @return bool placed */ public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) { if (! isset($this->direction ) && ! $this->canPlaceObject($level, $x, $y, $z, $random )) @@ -150,7 +151,7 @@ class Igloo extends Object { $level->setBlockIdAt($xx, $y + 1, $zz, Block::CARPET); } - // Other furnitures + // Other furniture // Bed $level->setBlockIdAt($x - 1, $y + 1, $z + 2, Block::BED_BLOCK); $level->setBlockIdAt($x, $y + 1, $z + 2, Block::BED_BLOCK); @@ -225,7 +226,7 @@ class Igloo extends Object { $level->setBlockIdAt($xx, $y + 1, $zz, Block::CARPET); } - // Other furnitures + // Other furniture // Bed $level->setBlockIdAt($x + 1, $y + 1, $z + 2, Block::BED_BLOCK); $level->setBlockIdAt($x, $y + 1, $z + 2, Block::BED_BLOCK); @@ -238,7 +239,7 @@ class Igloo extends Object { break; // Third direction - case 2 : // Entrence is z+ + case 2 : // Entrance is z+ // Ground for($xx = $x - 3; $xx <= $x + 3; $xx ++) for($zz = $z - 3; $zz <= $z + 4; $zz ++) @@ -299,7 +300,7 @@ class Igloo extends Object { $level->setBlockIdAt($xx, $y + 1, $zz, Block::CARPET); } - // Other furnitures + // Other furniture // Bed $level->setBlockIdAt($x + 2, $y + 1, $z - 1, Block::BED_BLOCK); $level->setBlockIdAt($x + 2, $y + 1, $z, Block::BED_BLOCK); @@ -373,7 +374,7 @@ class Igloo extends Object { $level->setBlockIdAt($xx, $y + 1, $zz, Block::CARPET); } - // Other furnitures + // Other furniture // Bed $level->setBlockIdAt($x + 2, $y + 1, $z + 1, Block::BED_BLOCK); $level->setBlockIdAt($x + 2, $y + 1, $z, Block::BED_BLOCK); @@ -385,5 +386,6 @@ class Igloo extends Object { $level->setBlockIdAt($x - 2, $y + 1, $z + 1, Block::FURNACE); break; } + return true; } } \ No newline at end of file diff --git a/src/Ad5001/BetterGen/structure/SakuraTree.php b/src/Ad5001/BetterGen/structure/SakuraTree.php index d32da10..d40cb06 100644 --- a/src/Ad5001/BetterGen/structure/SakuraTree.php +++ b/src/Ad5001/BetterGen/structure/SakuraTree.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -26,7 +26,7 @@ if(Main::isOtherNS()) { } class SakuraTree extends Tree { - const TRUNK_POS = [ // Checks for trees trunks. Not automaticly generated but there is no point of making more or less + const TRUNK_POS = [ // Checks for trees trunks. Not automatically generated but there is no point of making more or less 7 => [ 0, 1 @@ -495,7 +495,7 @@ class SakuraTree extends Tree { $z ]; - // Filling horisontally + // Filling horizontally if ($hParts > 0) { for($i = 0; $i < $hParts; $i ++) { $lastX += $xDiff * 2; @@ -512,7 +512,7 @@ class SakuraTree extends Tree { $lastZ += $zDiff; $this->setLog($level, $lastX, $lastY, $lastZ); - // Filling verticaly + // Filling vertically if ($vParts > 0) { for($i = 0; $i < $vParts; $i ++) { $lastX += $xDiff; @@ -530,7 +530,7 @@ class SakuraTree extends Tree { $this->setLog($level, $lastX, $lastY + $i, $lastZ); } $lastY ++; - // FIlling the branches. + // Filling the branches. $branchLen2 = function ($base) { return ceil($base / 2); }; @@ -629,7 +629,7 @@ class SakuraTree extends Tree { break; } - // Leaves falling from the tree diagonaly + // Leaves falling from the tree diagonally foreach(self::DIAG_LEAVES [$trunkHeight] as $pos ) { $numDown = $random->nextBoundedInt(3 ) + 1; for($y = $lastY + 1; $y > $lastY - $numDown; $y --) diff --git a/src/Ad5001/BetterGen/structure/SugarCane.php b/src/Ad5001/BetterGen/structure/SugarCane.php index 3e150d2..44b6f2f 100644 --- a/src/Ad5001/BetterGen/structure/SugarCane.php +++ b/src/Ad5001/BetterGen/structure/SugarCane.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ diff --git a/src/Ad5001/BetterGen/structure/Temple.php b/src/Ad5001/BetterGen/structure/Temple.php index 41ded3d..a43e0cd 100644 --- a/src/Ad5001/BetterGen/structure/Temple.php +++ b/src/Ad5001/BetterGen/structure/Temple.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -77,6 +77,8 @@ class Temple extends Object { - 2 ] ]; + /** @var ChunkManager */ + private $level; public $overridable = [ Block::AIR => true, 6 => true, @@ -107,7 +109,7 @@ class Temple extends Object { 1 ] ]; - + /* * Checks if a temple is placeable * @param $level pocketmine\level\ChunkManager @@ -118,6 +120,7 @@ class Temple extends Object { * @return bool */ public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) { + $this->level = $level; $this->direction = $random->nextBoundedInt(4); for($xx = $x - 10; $xx <= $x + 10; $xx ++) for($yy = $y + 1; $yy <= $y + 11; $yy ++) @@ -168,7 +171,7 @@ class Temple extends Object { for($zz = $z - 1; $zz <= $z + 1; $zz ++) $this->placeBlock($xx, $yy, $zz, 0); - // Floor patern + // Floor pattern foreach($this->directions as $dir ) { // Building pillar for($yy = $y + 1; $yy <= $y + 3; $yy ++) @@ -413,7 +416,7 @@ class Temple extends Object { } /* - * Places one of the towers. Out is inversed $direction1, stairs come from inversed $direction2 to $direction2, patterns are on $direction1 and $direction2 + * Places one of the towers. Out is inverted $direction1, stairs come from inverted $direction2 to $direction2, patterns are on $direction1 and $direction2 * @param $x int * @param $y int * @param $z int @@ -497,12 +500,12 @@ class Temple extends Object { $this->placeBlock($x, $y + 7, $z - 2, Block::SANDSTONE, 2); $this->placeBlock($x + 1, $y + 7, $z - 2, Block::SANDSTONE, 2); break; - - // Building entrance to second floor. - BuildingUtils::fill($this->level, new Vector3($x - 9, $y + 5, $z + 4 ), new Vector3($x - 7, $y + 7, $z + 5 ), Block::get(Block::SANDSTONE, 2 )); - BuildingUtils::fill($this->level, new Vector3($x - 8, $y + 5, $z + 4 ), new Vector3($x - 8, $y + 6, $z + 5 ), Block::get(Block::AIR )); } - + + // Building entrance to second floor. + BuildingUtils::fill($this->level, new Vector3($x - 9, $y + 5, $z + 4 ), new Vector3($x - 7, $y + 7, $z + 5 ), Block::get(Block::SANDSTONE, 2 )); + BuildingUtils::fill($this->level, new Vector3($x - 8, $y + 5, $z + 4 ), new Vector3($x - 8, $y + 6, $z + 5 ), Block::get(Block::AIR )); + // Finishing stairs system $this->placeBlock($x - 2, $y + 3, $z, Block::SANDSTONE_STAIRS, 1); $this->placeBlock($x - 3, $y + 4, $z, Block::SANDSTONE_STAIRS, 1); @@ -890,7 +893,7 @@ class Temple extends Object { * @param $direction int * @return int */ - protected function getInversedDirection(int $direction): int { + protected function getInvertedDirection(int $direction): int { switch ($direction) { case self::DIRECTION_PLUSX : // x+ (0) return self::DIRECTION_MINX; diff --git a/src/Ad5001/BetterGen/structure/Well.php b/src/Ad5001/BetterGen/structure/Well.php index a9421e5..4bd6ee6 100644 --- a/src/Ad5001/BetterGen/structure/Well.php +++ b/src/Ad5001/BetterGen/structure/Well.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ @@ -22,6 +22,8 @@ use pocketmine\level\generator\object\Object; class Well extends Object { + /** @var ChunkManager */ + private $level; public $overridable = [ Block::AIR => true, 6 => true, @@ -52,17 +54,18 @@ class Well extends Object { 1 ] ]; - + /* * Checks if a well is placeable - * @param $level pocketmine\level\ChunkManager + * @param $level ChunkManager * @param $x int * @param $y int * @param $z int - * @param $random pocketmine\utils\Random + * @param $random Random * @return bool */ public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) { + $this->level = $level; for($xx = $x - 2; $xx <= $x + 2; $xx ++) for($yy = $y; $yy <= $y + 3; $yy ++) for($zz = $z - 2; $zz <= $z + 2; $zz ++) @@ -73,16 +76,16 @@ class Well extends Object { /* * Places a well - * @param $level pocketmine\level\ChunkManager + * @param $level ChunkManager * @param $x int * @param $y int * @param $z int - * @param $random pocketmine\utils\Random + * @param $random Random */ public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) { $this->level = $level; foreach($this->directions as $direction ) { - // Building pillard + // Building pillars for($yy = $y; $yy < $y + 3; $yy ++) $this->placeBlock($x + $direction [0], $yy, $z + $direction [1], Block::SANDSTONE); @@ -92,32 +95,20 @@ class Well extends Object { $this->placeBlock($x + ($direction [0] * 2), $y, $z + ($direction [1] * 2), Block::SANDSTONE); // Building slabs on the sides. Places two times due to all directions. - $this->placeSlab($x + ($direction [0] * 2), $y, $z); - $this->placeSlab($x, $y, $z + ($direction [1] * 2)); + $this->placeBlock($x + ($direction [0] * 2), $y, $z, Block::SANDSTONE, 1); + $this->placeBlock($x, $y, $z + ($direction [1] * 2), Block::SANDSTONE, 1); // Placing water.Places two times due to all directions. $this->placeBlock($x + $direction [0], $y, $z, Block::WATER); $this->placeBlock($x, $y, $z + $direction [1], Block::WATER); } - // Finitions + // Final things for($xx = $x - 1; $xx <= $x + 1; $xx ++) for($zz = $z - 1; $zz <= $z + 1; $zz ++) - $this->placeSlab($xx, $y + 3, $zz); - $this->placeSlab($x, $y + 3, $z, Block::SANDSTONE); - $this->placeSlab($x, $y, $z, Block::WATER); - } - - /* - * Places a slab - * @param $x int - * @param $y int - * @param $z int - * @return void - */ - public function placeSlab($x, $y, $z) { - $this->level->setBlockIdAt($x, $y, $z, 44); - $this->level->setBlockDataAt($x, $y, $z, 1); + $this->placeBlock($xx, $y + 3, $zz); + $this->placeBlock($x, $y + 3, $z, Block::SANDSTONE, 1); + $this->placeBlock($x, $y, $z, Block::WATER); } /* @@ -128,7 +119,8 @@ class Well extends Object { * @param $id int * @return void */ - public function placeBlock($x, $y, $z, $id) { + public function placeBlock($x, $y, $z, $id = 0, $meta = 0) { $this->level->setBlockIdAt($x, $y, $z, $id); + $this->level->setBlockDataAt($x, $y, $z, $meta); } } \ No newline at end of file diff --git a/src/Ad5001/BetterGen/utils/BuildingUtils.php b/src/Ad5001/BetterGen/utils/BuildingUtils.php index c987582..8a74a34 100644 --- a/src/Ad5001/BetterGen/utils/BuildingUtils.php +++ b/src/Ad5001/BetterGen/utils/BuildingUtils.php @@ -7,7 +7,7 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow's pocketmine generator. * @author Ad5001 * @link https://github.com/Ad5001/BetterGen */ diff --git a/src/Ad5001/BetterGen/utils/CommonUtils.php b/src/Ad5001/BetterGen/utils/CommonUtils.php index edf21db..13af710 100644 --- a/src/Ad5001/BetterGen/utils/CommonUtils.php +++ b/src/Ad5001/BetterGen/utils/CommonUtils.php @@ -7,17 +7,17 @@ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ - * Tommorow's pocketmine generator. + * Tomorrow'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 + # Common utils under no namespace made for a specific usage class CommonUtils { /** - * Searches case insensitivly array $haystack for $needle. + * Searches case insensitively array $haystack for $needle. * src: http://php.net/manual/en/function.in-array.php#89256 * @param mixed $needle * @param array $haystack