Merge pull request #18 from thebigsmileXD/master

Create PR, fixing tons of bugs
This commit is contained in:
Adsooi 2017-05-13 16:42:25 +02:00 committed by GitHub
commit d954937dde
41 changed files with 1436 additions and 1351 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.idea/*

View file

@ -1,9 +1,10 @@
<img src="https://raw.githubusercontent.com/Ad5001/BetterGen/master/imgs/banner.png"></img> <img src="https://raw.githubusercontent.com/Ad5001/BetterGen/master/imgs/banner.png"></img>
<center><h1>PocketMine's Tomorrow's World Generator.</h1></center> <center><h1>PocketMine's Tomorrow's World Generator.</h1></center>
Welcome user to the home of a new PocketMine World Generator which features 9 new/modified biomes: Welcome user to the home of a new PocketMine World Generator which features 9 new/modified biomes:
------ ------
# Commun: # Common:
### Commun structures to all biomes features: ### Common structures to all biomes features:
1. <h3>Mineshafts:</h3> 1. <h3>Mineshafts:</h3>
<img src="https://raw.githubusercontent.com/Ad5001/BetterGen/master/imgs/Mineshaft.jpg" style="width: 500px"></img> <img src="https://raw.githubusercontent.com/Ad5001/BetterGen/master/imgs/Mineshaft.jpg" style="width: 500px"></img>
2. <h3>Ravines:</h3> 2. <h3>Ravines:</h3>
@ -12,8 +13,6 @@ Welcome user to the home of a new PocketMine World Generator which features 9 ne
<img src="https://raw.githubusercontent.com/Ad5001/BetterGen/master/imgs/cave.jpg" style="width: 500px"></img> <img src="https://raw.githubusercontent.com/Ad5001/BetterGen/master/imgs/cave.jpg" style="width: 500px"></img>
4. <h3>Floating islands:</h3> 4. <h3>Floating islands:</h3>
<img src="https://raw.githubusercontent.com/Ad5001/BetterGen/master/imgs/Island.jpg" style="width: 500px"></img> <img src="https://raw.githubusercontent.com/Ad5001/BetterGen/master/imgs/Island.jpg" style="width: 500px"></img>
----- -----
# [NEW BIOME] Sakura forests: # [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 # [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.
<img src="https://raw.githubusercontent.com/Ad5001/BetterGen/master/imgs/mesa.png" style="width: 500px"></img> <img src="https://raw.githubusercontent.com/Ad5001/BetterGen/master/imgs/mesa.png" style="width: 500px"></img>
@ -31,13 +30,13 @@ Welcome user to the home of a new PocketMine World Generator which features 9 ne
# Better Desert: # Better Desert:
### The desert has been reworked and now includes the Minecraft PC's temples and wells ! ### 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 !
<img src="https://raw.githubusercontent.com/Ad5001/BetterGen/master/imgs/temple.png" style="width: 500px"></img> <img src="https://raw.githubusercontent.com/Ad5001/BetterGen/master/imgs/temple.png" style="width: 500px"></img>
----- -----
# Better Ice Plains # 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 !
<img src="https://raw.githubusercontent.com/Ad5001/BetterGen/master/imgs/igloo.jpg" style="width: 500px"></img> <img src="https://raw.githubusercontent.com/Ad5001/BetterGen/master/imgs/igloo.jpg" style="width: 500px"></img>

View file

@ -6,7 +6,7 @@
# \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ # \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
# \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ # \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
# \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ # \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
# Tommorow's pocketmine generator. # Tomorrow's pocketmine generator.
# @author Ad5001 # @author Ad5001
# @link https://github.com/Ad5001/BetterGen # @link https://github.com/Ad5001/BetterGen
name: BetterGen name: BetterGen
@ -24,9 +24,15 @@ commands:
description: Teleports you to an another world description: Teleports you to an another world
usage: "/worldtp <world name>" usage: "/worldtp <world name>"
permission: bettergen.cmd.worldtp permission: bettergen.cmd.worldtp
temple:
description: Spawns a temple for debugging
usage: "/temple"
permission: bettergen.cmd.debug
permissions: permissions:
bettergen.cmd.createworld: bettergen.cmd.createworld:
default: op default: op
bettergen.cmd.worldtp: bettergen.cmd.worldtp:
default: op default: op
bettergen.cmd.debug:
default: op
... ...

1
processingLoots.json Normal file
View file

@ -0,0 +1 @@
[]

View file

@ -45,7 +45,7 @@
"id": 263, "id": 263,
"data": 0 "data": 0
}, },
"beethroot seeds": { "beetroot seeds": {
"percentage": 32, "percentage": 32,
"minCount": 2, "minCount": 2,
"maxCount": 4, "maxCount": 4,

View file

@ -7,54 +7,61 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen; namespace Ad5001\BetterGen;
use pocketmine\plugin\PluginBase; use Ad5001\BetterGen\biome\BetterForest;
use Ad5001\BetterGen\generator\BetterNormal;
use Ad5001\BetterGen\loot\LootTable;
use Ad5001\BetterGen\structure\Temple;
use pocketmine\block\Block;
use pocketmine\command\Command;
use pocketmine\command\CommandSender;
use pocketmine\command\ConsoleCommandSender;
use pocketmine\event\block\BlockBreakEvent;
use pocketmine\event\level\ChunkPopulateEvent;
use pocketmine\event\Listener;
use pocketmine\event\player\PlayerInteractEvent;
use pocketmine\level\generator\biome\Biome; use pocketmine\level\generator\biome\Biome;
use pocketmine\level\generator\Generator; use pocketmine\level\generator\Generator;
use pocketmine\level\generator\normal\Normal;
use pocketmine\event\level\ChunkPopulateEvent;
use Ad5001\BetterGen\generator\BetterNormal;
use Ad5001\BetterGen\biome\BetterForest;
use Ad5001\BetterGen\loot\LootTable;
use pocketmine\utils\Config;
use pocketmine\block\Block;
use pocketmine\tile\Chest;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\ListTag; use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\StringTag; use pocketmine\nbt\tag\StringTag;
use pocketmine\nbt\tag\IntTag; use pocketmine\Player;
use pocketmine\plugin\PluginBase;
use pocketmine\tile\Chest;
use pocketmine\tile\Tile; use pocketmine\tile\Tile;
use pocketmine\item\Item; use pocketmine\utils\Config;
use pocketmine\event\player\PlayerInteractEvent; use pocketmine\utils\Random;
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 PREFIX = "§l§o§b[§r§l§2Better§aGen§o§b]§r§f ";
const SAKURA_FOREST = 100; // Letting some place for future biomes. const SAKURA_FOREST = 100; // Letting some place for future biomes.
/* /*
* Called when the plugin enables * Called when the plugin enables
*/ */
public function onEnable() {
$this->getServer()->getPluginManager()->registerEvents($this, $this); public static function registerBiome(int $id, Biome $biome) {
Generator::addGenerator(BetterNormal::class, "betternormal"); BetterNormal::registerBiome($biome);
if($this->isOtherNS()) $this->getLogger()->warning("Tesseract detected. Note that some parts of the generator could not work properly");
@mkdir($this->getDataFolder());
if(! file_exists(LootTable::getPluginFolder(). "processingLoots.json"))
file_put_contents(LootTable::getPluginFolder(). "processingLoots.json", "{}");
} }
/* /*
* Called when the plugin disables * Called when the plugin disables
*/ */
public function onDisable() {
public function onEnable() {
$this->getServer()->getPluginManager()->registerEvents($this, $this);
Generator::addGenerator(BetterNormal::class, "betternormal");
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,85 +72,12 @@ class Main extends PluginBase implements \pocketmine\event\Listener {
* @param $args array * @param $args array
* return bool * return bool
*/ */
public function onCommand(\pocketmine\command\CommandSender $sender, \pocketmine\command\Command $cmd, $label, array $args): bool {
switch($cmd->getName()) { public static function isOtherNS() {
case "createworld" : // /createworld <name> [generator = betternormal] [seed = rand()] [options(json)] try {
switch(count($args)) { return @class_exists("pocketmine\\level\\generator\\normal\\object\\OakTree");
case 0 : } catch (\Exception $e) {
return false; return false;
break;
case 1 : // /createworld <name>
$name = $args [0];
$generator = Generator::getGenerator("betternormal");
$generatorName = "betternormal";
$seed = $this->generateRandomSeed();
$options = [ ];
break;
case 2 : // /createworld <name> [generator = betternormal]
$name = $args [0];
$generator = Generator::getGenerator($args [1]);
if(Generator::getGeneratorName($generator) !== strtolower($args [1])) {
$sender->sendMessage(self::PREFIX . "§4Could not find generator {$args[1]}. Are you sure it is registered?");
return true;
}
$generatorName = strtolower($args [1]);
$seed = $this->generateRandomSeed();
$options = [ ];
break;
case 3 : // /createworld <name> [generator = betternormal] [seed = rand()]
$name = $args [0];
$generator = Generator::getGenerator($args [1]);
if(Generator::getGeneratorName($generator) !== strtolower($args [1])) {
$sender->sendMessage(self::PREFIX . "§4Could not find generator {$args[1]}. Are you sure it is registered?");
return true;
}
$generatorName = strtolower($args [1]);
if(preg_match("[^\d]", $args [2]) !== false) {
$parts = str_split($args [2]);
foreach($parts as $key => $str) {
$parts [$key] = ord($str);
}
$seed = implode("", $parts);
} else {
$seed = $args [2];
}
$options = [ ];
break;
default : // /createworld <name> [generator = betternormal] [seed = rand()] [options(json)]
$name = $args [0];
$generator = Generator::getGenerator($args [1]);
if(Generator::getGeneratorName($generator) !== strtolower($args [1])) {
$sender->sendMessage(self::PREFIX . "§4Could not find generator {$args[1]}. Are you sure it is registered?");
return true;
}
$generatorName = strtolower($args [1]);
if($args[2] == "rand") $args[2] = $this->generateRandomSeed();
if(preg_match("[^\d]", $args [2]) !== false) {
$parts = str_split($args [2]);
foreach($parts as $key => $str) {
$parts [$key] = ord($str);
}
$seed = implode("", $parts);
} else {
$seed = $args [2];
}
unset($args [0], $args [1], $args [2]);
$options = json_decode($args [3], true);
if(! is_array($options)) {
$sender->sendMessage(Main::PREFIX . "§4Invalid JSON for options.");
return true;
}
break;
}
$options["preset"] = json_encode($options);
if((int) $seed == 0/*String*/){
$seed = $this->generateRandomSeed();
}
$this->getServer()->broadcastMessage(Main::PREFIX . "§aGenerating level $name with generator $generatorName and seed $seed..");
$this->getServer()->generateLevel($name, $seed, $generator, $options);
$this->getServer()->loadLevel($name);
return true;
break;
} }
} }
@ -154,14 +88,8 @@ class Main extends PluginBase implements \pocketmine\event\Listener {
* @params $infos Array(temperature, rainfall) * @params $infos Array(temperature, rainfall)
* @return bool * @return bool
*/ */
public function registerForest(string $name, string $treeClass, array $infos): bool {
if(! @class_exists($treeClass)) public function onDisable() {
return false;
if(! @is_subclass_of($treeClass, "pocketmine\\level\\generator\\normal\\object\\Tree"))
return false;
if(count($infos) < 2 or ! is_float($infos [0]) or ! is_float($infos [1]))
return false;
return BetterForest::registerForest($name, $treeClass, $infos);
} }
/* /*
@ -170,16 +98,104 @@ class Main extends PluginBase implements \pocketmine\event\Listener {
* @param $biome Biome * @param $biome Biome
* @return void * @return void
*/ */
public static function registerBiome(int $id, Biome $biome) {
BetterNormal::registerBiome($biome); public function onCommand(CommandSender $sender, Command $cmd, $label, array $args): bool {
switch ($cmd->getName()) {
case "createworld" : // /createworld <name> [generator = betternormal] [seed = rand()] [options(json)]
switch (count($args)) {
case 0 :
return false;
break;
case 1 : // /createworld <name>
$name = $args [0];
$generator = Generator::getGenerator("betternormal");
$generatorName = "betternormal";
$seed = $this->generateRandomSeed();
$options = [];
break;
case 2 : // /createworld <name> [generator = betternormal]
$name = $args [0];
$generator = Generator::getGenerator($args [1]);
if (Generator::getGeneratorName($generator) !== strtolower($args [1])) {
$sender->sendMessage(self::PREFIX . "§4Could not find generator {$args[1]}. Are you sure it is registered?");
return true;
}
$generatorName = strtolower($args [1]);
$seed = $this->generateRandomSeed();
$options = [];
break;
case 3 : // /createworld <name> [generator = betternormal] [seed = rand()]
$name = $args [0];
$generator = Generator::getGenerator($args [1]);
if (Generator::getGeneratorName($generator) !== strtolower($args [1])) {
$sender->sendMessage(self::PREFIX . "§4Could not find generator {$args[1]}. Are you sure it is registered?");
return true;
}
$generatorName = strtolower($args [1]);
if (preg_match("[^\d]", $args [2]) !== false) {
$parts = str_split($args [2]);
foreach ($parts as $key => $str) {
$parts [$key] = ord($str);
}
$seed = implode("", $parts);
} else {
$seed = $args [2];
}
$options = [];
break;
default : // /createworld <name> [generator = betternormal] [seed = rand()] [options(json)]
$name = $args [0];
$generator = Generator::getGenerator($args [1]);
if (Generator::getGeneratorName($generator) !== strtolower($args [1])) {
$sender->sendMessage(self::PREFIX . "§4Could not find generator {$args[1]}. Are you sure it is registered?");
return true;
}
$generatorName = strtolower($args [1]);
if ($args[2] == "rand") $args[2] = $this->generateRandomSeed();
if (preg_match("[^\d]", $args [2]) !== false) {
$parts = str_split($args [2]);
foreach ($parts as $key => $str) {
$parts [$key] = ord($str);
}
$seed = implode("", $parts);
} else {
$seed = $args [2];
}
unset($args [0], $args [1], $args [2]);
$options = json_decode($args [3], true);
if (!is_array($options)) {
$sender->sendMessage(Main::PREFIX . "§4Invalid JSON for options.");
return true;
}
break;
}
$options["preset"] = json_encode($options);
if ((int)$seed == 0/*String*/) {
$seed = $this->generateRandomSeed();
}
$this->getServer()->broadcastMessage(Main::PREFIX . "§aGenerating level $name with generator $generatorName and seed $seed..");
$this->getServer()->generateLevel($name, $seed, $generator, $options);
$this->getServer()->loadLevel($name);
return true;
break;
case 'temple':{
if($sender instanceof ConsoleCommandSender) return false;
/** @var Player $sender */
$temple = new Temple();
$temple->placeObject($sender->getLevel(), $sender->x, $sender->y, $sender->z, new Random(microtime()));
return true;
}
}
return false;
} }
/* /*
* Generates a(semi) random seed. * Generates a(semi) random seed.
* @return int * @return int
*/ */
public function generateRandomSeed(): int { public function generateRandomSeed(): int {
return (int) round(rand(0, round(time()) / memory_get_usage(true)) * (int) str_shuffle("127469453645108") / (int) str_shuffle("12746945364")); return (int)round(rand(0, round(time()) / memory_get_usage(true)) * (int)str_shuffle("127469453645108") / (int)str_shuffle("12746945364"));
} }
// Listener // Listener
@ -189,11 +205,27 @@ class Main extends PluginBase implements \pocketmine\event\Listener {
* @param $event pocketmine\event\level\ChunkPopulateEvent * @param $event pocketmine\event\level\ChunkPopulateEvent
* @return int * @return int
*/ */
public function registerForest(string $name, string $treeClass, array $infos): bool {
if (!@class_exists($treeClass))
return false;
if (!@is_subclass_of($treeClass, "pocketmine\\level\\generator\\normal\\object\\Tree"))
return false;
if (count($infos) < 2 or !is_float($infos [0]) or !is_float($infos [1]))
return false;
return BetterForest::registerForest($name, $treeClass, $infos);
}
/*
* Checks when a player interacts with a loot chest to create it.
*/
public function onChunkPopulate(ChunkPopulateEvent $event) { public function onChunkPopulate(ChunkPopulateEvent $event) {
$cfg = new Config(LootTable::getPluginFolder() . "processingLoots.json", Config::JSON); $cfg = new Config(LootTable::getPluginFolder() . "processingLoots.json", Config::JSON);
foreach($cfg->getAll() as $key => $value) { foreach ($cfg->getAll() as $key => $value) {
list($x, $y, $z) = explode(";", $key); list($x, $y, $z) = explode(";", $key);
if($value["saveAs"] == "chest" && $event->getLevel()->getBlockIdAt($x, $y, $z) == Block::AIR ){ if ($value["saveAs"] == "chest" && $event->getLevel()->getBlockIdAt($x, $y, $z) == Block::AIR) {
$event->getLevel()->setBlockIdAt($x, $y, $z, Block::CHEST); $event->getLevel()->setBlockIdAt($x, $y, $z, Block::CHEST);
} else { } else {
$cfg->remove($key); $cfg->remove($key);
@ -203,38 +235,14 @@ class Main extends PluginBase implements \pocketmine\event\Listener {
} }
/*
* Checks when a player interacts with a loot chest to create it.
*/
public function onInteract(PlayerInteractEvent $event) {
$cfg = new Config(LootTable::getPluginFolder() . "processingLoots.json", Config::JSON);
if($event->getBlock()->getId() !== Block::CHEST) return;
if(!$cfg->exists($event->getBlock()->getX() . ";" . $event->getBlock()->getY() . ";" . $event->getBlock()->getZ())) return;
$chest = new \pocketmine\block\Chest(0);
$nbt = new CompoundTag("", [
new ListTag("Items", []),
new StringTag("id", Tile::CHEST),
new IntTag("x", $event->getBlock()->x),
new IntTag("y", $event->getBlock()->y),
new IntTag("z", $event->getBlock()->z)
]);
$chest->setLevel($event->getBlock()->getLevel());
$cItem = Item::get(Item::CHEST, 0);
$cItem->setCustomName("§k(Fake)§r Minecart chest");
$chest->place($cItem, $event->getBlock()->getLevel()->getBlock($event->getBlock()), $chest, 0, 0, 0, 0);
$inv = $event->getBlock()->getLevel()->getTile($event->getBlock());
LootTable::fillChest($inv->getInventory(), $event->getBlock());
}
/* /*
* Checks when a player breaks a loot chest which is not created to create it * Checks when a player breaks a loot chest which is not created to create it
*/ */
public function onBlockBreak(BlockBreakEvent $event) {
public function onInteract(PlayerInteractEvent $event) {
$cfg = new Config(LootTable::getPluginFolder() . "processingLoots.json", Config::JSON); $cfg = new Config(LootTable::getPluginFolder() . "processingLoots.json", Config::JSON);
if($event->getBlock()->getId() !== Block::CHEST) return; if ($event->getBlock()->getId() !== Block::CHEST) return;
if(!$cfg->exists($event->getBlock()->getX() . ";" . $event->getBlock()->getY() . ";" . $event->getBlock()->getZ())) return; if (!$cfg->exists($event->getBlock()->getX() . ";" . $event->getBlock()->getY() . ";" . $event->getBlock()->getZ())) return;
$chest = new \pocketmine\block\Chest(0);
$nbt = new CompoundTag("", [ $nbt = new CompoundTag("", [
new ListTag("Items", []), new ListTag("Items", []),
new StringTag("id", Tile::CHEST), new StringTag("id", Tile::CHEST),
@ -242,24 +250,32 @@ class Main extends PluginBase implements \pocketmine\event\Listener {
new IntTag("y", $event->getBlock()->y), new IntTag("y", $event->getBlock()->y),
new IntTag("z", $event->getBlock()->z) new IntTag("z", $event->getBlock()->z)
]); ]);
$chest->setLevel($event->getBlock()->getLevel()); /** @var Chest $chest */
$cItem = Item::get(Item::CHEST, 0); $chest = Tile::createTile(Tile::CHEST, $event->getBlock()->getLevel(), $nbt);
$cItem->setCustomName("§k(Fake)§r Minecart chest"); $chest->setName("§k(Fake)§r Minecart chest");
$chest->place($cItem, $event->getBlock()->getLevel()->getBlock($event->getBlock()), $chest, 0, 0, 0, 0); LootTable::fillChest($chest->getInventory(), $event->getBlock());
$inv = $event->getBlock()->getLevel()->getTile($event->getBlock());
LootTable::fillChest($inv->getInventory(), $event->getBlock());
$event->setCancelled();
} }
/* /*
* Check if it's a Tesseract like namespace * Check if it's a Tesseract like namespace
* @return bool * @return bool
*/ */
public static function isOtherNS() {
try { public function onBlockBreak(BlockBreakEvent $event) {
return @class_exists("pocketmine\\level\\generator\\normal\\object\\OakTree"); $cfg = new Config(LootTable::getPluginFolder() . "processingLoots.json", Config::JSON);
} catch(\Exception $e) { if ($event->getBlock()->getId() !== Block::CHEST) return;
return false; if (!$cfg->exists($event->getBlock()->getX() . ";" . $event->getBlock()->getY() . ";" . $event->getBlock()->getZ())) return;
} $nbt = new CompoundTag("", [
new ListTag("Items", []),
new StringTag("id", Tile::CHEST),
new IntTag("x", $event->getBlock()->x),
new IntTag("y", $event->getBlock()->y),
new IntTag("z", $event->getBlock()->z)
]);
/** @var Chest $chest */
$chest = Tile::createTile(Tile::CHEST, $event->getBlock()->getLevel(), $nbt);
$chest->setName("§k(Fake)§r Minecart chest");
LootTable::fillChest($chest->getInventory(), $event->getBlock());
// $event->setCancelled(); //i think nope. You want to break it with items
} }
} }

View file

@ -7,23 +7,24 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @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\biome\Biome;
use pocketmine\block\Block;
use Ad5001\BetterGen\populator\TemplePopulator;
use Ad5001\BetterGen\populator\WellPopulator;
use Ad5001\BetterGen\populator\CactusPopulator; use Ad5001\BetterGen\populator\CactusPopulator;
use Ad5001\BetterGen\populator\DeadbushPopulator; use Ad5001\BetterGen\populator\DeadbushPopulator;
use Ad5001\BetterGen\populator\SugarCanePopulator; use Ad5001\BetterGen\populator\SugarCanePopulator;
use Ad5001\BetterGen\populator\TemplePopulator;
use Ad5001\BetterGen\populator\WellPopulator;
use pocketmine\block\Block;
use pocketmine\level\generator\biome\Biome;
use pocketmine\level\generator\normal\biome\SandyBiome;
class BetterDesert extends SandyBiome implements Mountainable { class BetterDesert extends SandyBiome implements Mountainable {
public function __construct() { public function __construct() {
parent::__construct();
$deadBush = new DeadbushPopulator (); $deadBush = new DeadbushPopulator ();
$deadBush->setBaseAmount(1); $deadBush->setBaseAmount(1);
$deadBush->setRandomAmount(2); $deadBush->setRandomAmount(2);

View file

@ -8,19 +8,19 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @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\biome\Biome;
use Ad5001\BetterGen\Main; use Ad5001\BetterGen\Main;
use Ad5001\BetterGen\populator\TreePopulator;
use Ad5001\BetterGen\populator\BushPopulator; use Ad5001\BetterGen\populator\BushPopulator;
use Ad5001\BetterGen\populator\FallenTreePopulator; use Ad5001\BetterGen\populator\FallenTreePopulator;
use Ad5001\BetterGen\populator\TreePopulator;
use pocketmine\level\generator\biome\Biome;
use pocketmine\level\generator\normal\biome\ForestBiome;
class BetterForest extends ForestBiome implements Mountainable { class BetterForest extends ForestBiome implements Mountainable {
@ -67,24 +67,24 @@ class BetterForest extends ForestBiome implements Mountainable {
return str_ireplace(" ", "", self::$types[$this->type]); return str_ireplace(" ", "", self::$types[$this->type]);
} }
/* /**
* Returns the ID relativly. * Returns the ID relatively.
* @return int
*/ */
public function getId() { public function getId() {
return self::$ids [$this->type]; return self::$ids [$this->type];
} }
/**
/* * @param string $name
* Registers a forest type. Don't use this method directly use the one from the main class. * @param string $treeClass
* @param $name string * @param array $infos
* @param $treeClass string
* @param
* @return bool * @return bool
*/ */
public static function registerForest(string $name, string $treeClass, array $infos): bool { public static function registerForest(string $name, string $treeClass, array $infos): bool {
self::$types [] = str_ireplace("tree", "", explode("\\", $treeClass ) [count(explode("\\", $treeClass ) )] ) . " Forest"; self::$types [] = str_ireplace("tree", "", explode("\\", $treeClass ) [count(explode("\\", $treeClass ) )] ) . " Forest";
TreePopulator::$types [] = $treeClass; TreePopulator::$types [] = $treeClass;
self::$ids [] = Main::SAKURA_FOREST + (count(self::$types ) - 2); 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;
} }
} }

View file

@ -7,18 +7,18 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\biome; namespace Ad5001\BetterGen\biome;
use pocketmine\level\generator\normal\biome\SnowyBiome;
use pocketmine\level\generator\biome\Biome;
use pocketmine\block\Block;
use Ad5001\BetterGen\populator\IglooPopulator;
use Ad5001\BetterGen\Main; use Ad5001\BetterGen\Main;
use Ad5001\BetterGen\populator\IglooPopulator;
use pocketmine\block\Block;
use pocketmine\level\generator\biome\Biome;
use pocketmine\level\generator\normal\biome\SnowyBiome;
class BetterIcePlains extends SnowyBiome implements Mountainable { class BetterIcePlains extends SnowyBiome implements Mountainable {
public function __construct() { public function __construct() {
@ -46,8 +46,9 @@ class BetterIcePlains extends SnowyBiome implements Mountainable {
return "BetterIcePlains"; return "BetterIcePlains";
} }
/* /**
* Returns biome's id. * Returns the biomes' id.
* @return int biome id
*/ */
public function getId() { public function getId() {
return Biome::ICE_PLAINS; return Biome::ICE_PLAINS;

View file

@ -7,27 +7,25 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @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\populator\Ore;
use pocketmine\level\generator\object\OreType;
use pocketmine\level\generator\biome\Biome;
use pocketmine\block\Block;
use pocketmine\block\GoldOre;
use Ad5001\BetterGen\Main; use Ad5001\BetterGen\Main;
use Ad5001\BetterGen\populator\TreePopulator;
use Ad5001\BetterGen\populator\CactusPopulator; use Ad5001\BetterGen\populator\CactusPopulator;
use Ad5001\BetterGen\populator\DeadbushPopulator; use Ad5001\BetterGen\populator\DeadbushPopulator;
use Ad5001\BetterGen\populator\SugarCanePopulator; use Ad5001\BetterGen\populator\SugarCanePopulator;
use Ad5001\BetterGen\populator\TreePopulator;
use pocketmine\block\Block;
use pocketmine\block\GoldOre;
use pocketmine\level\generator\normal\biome\SandyBiome;
class BetterMesa extends SandyBiome { class BetterMesa extends SandyBiome {
public function __construct() { public function __construct() {
parent::__construct();
$deadBush = new DeadbushPopulator (); $deadBush = new DeadbushPopulator ();
$deadBush->setBaseAmount(1); $deadBush->setBaseAmount(1);
$deadBush->setRandomAmount(2); $deadBush->setRandomAmount(2);

View file

@ -7,25 +7,24 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\biome; namespace Ad5001\BetterGen\biome;
use pocketmine\level\generator\normal\biome\SandyBiome; use Ad5001\BetterGen\Main;
use pocketmine\level\generator\object\OreType;
use pocketmine\level\generator\biome\Biome;
use pocketmine\block\Block;
use pocketmine\block\GoldOre;
use Ad5001\BetterGen\populator\CactusPopulator; use Ad5001\BetterGen\populator\CactusPopulator;
use Ad5001\BetterGen\populator\DeadbushPopulator; use Ad5001\BetterGen\populator\DeadbushPopulator;
use Ad5001\BetterGen\populator\SugarCanePopulator; use Ad5001\BetterGen\populator\SugarCanePopulator;
use Ad5001\BetterGen\Main; use pocketmine\block\Block;
use pocketmine\block\GoldOre;
use pocketmine\level\generator\normal\biome\SandyBiome;
class BetterMesaPlains extends SandyBiome { class BetterMesaPlains extends SandyBiome {
public function __construct() { public function __construct() {
parent::__construct();
$deadBush = new DeadbushPopulator (); $deadBush = new DeadbushPopulator ();
$deadBush->setBaseAmount(1); $deadBush->setBaseAmount(1);
$deadBush->setRandomAmount(2); $deadBush->setRandomAmount(2);

View file

@ -7,15 +7,15 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\biome; namespace Ad5001\BetterGen\biome;
use pocketmine\level\generator\biome\Biome;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\generator\biome\Biome;
class BetterRiver extends Biome { class BetterRiver extends Biome {
public function __construct() { public function __construct() {
@ -45,7 +45,7 @@ class BetterRiver extends Biome {
} }
/* /*
* Returns the ID relativly. * Returns the ID relatively.
*/ */
public function getId() { public function getId() {
return Biome::RIVER; return Biome::RIVER;

View file

@ -7,13 +7,13 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\biome; 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 { interface Mountainable {
} }

View file

@ -7,16 +7,16 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @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\Biome; use pocketmine\level\generator\biome\Biome;
use pocketmine\utils\Random; use pocketmine\level\generator\biome\BiomeSelector;
use pocketmine\level\generator\noise\Simplex; use pocketmine\level\generator\noise\Simplex;
use pocketmine\utils\Random;
class BetterBiomeSelector extends BiomeSelector { class BetterBiomeSelector extends BiomeSelector {
@ -30,9 +30,9 @@ class BetterBiomeSelector extends BiomeSelector {
/** @var Biome[] */ /** @var Biome[] */
private $biomes = [ ]; private $biomes = [ ];
private $map = [ ];
private $lookup; private $lookup;
public function __construct(Random $random, callable $lookup, Biome $fallback) { public function __construct(Random $random, callable $lookup, Biome $fallback) {
parent::__construct($random, $lookup, $fallback);
$this->fallback = $fallback; $this->fallback = $fallback;
$this->lookup = $lookup; $this->lookup = $lookup;
$this->temperature = new Simplex($random, 2, 1 / 16, 1 / 512); $this->temperature = new Simplex($random, 2, 1 / 16, 1 / 512);

View file

@ -7,21 +7,25 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\generator; namespace Ad5001\BetterGen\generator;
use pocketmine\level\ChunkManager; use Ad5001\BetterGen\biome\BetterDesert;
use pocketmine\utils\Random; use Ad5001\BetterGen\biome\BetterForest;
use pocketmine\level\generator\biome\Biome; use Ad5001\BetterGen\biome\BetterIcePlains;
use pocketmine\level\generator\Generator; use Ad5001\BetterGen\biome\BetterMesa;
use pocketmine\level\generator\noise\Simplex; use Ad5001\BetterGen\biome\BetterMesaPlains;
use pocketmine\level\generator\object\OreType; use Ad5001\BetterGen\biome\BetterRiver;
use pocketmine\level\generator\normal\object\OreType as OreType2; use Ad5001\BetterGen\biome\Mountainable;
use pocketmine\level\generator\populator\Ore; use Ad5001\BetterGen\Main;
use Ad5001\BetterGen\populator\CavePopulator;
use Ad5001\BetterGen\populator\FloatingIslandPopulator;
use Ad5001\BetterGen\populator\MineshaftPopulator;
use Ad5001\BetterGen\populator\RavinePopulator;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\block\CoalOre; use pocketmine\block\CoalOre;
use pocketmine\block\DiamondOre; use pocketmine\block\DiamondOre;
@ -31,20 +35,15 @@ use pocketmine\block\Gravel;
use pocketmine\block\IronOre; use pocketmine\block\IronOre;
use pocketmine\block\LapisOre; use pocketmine\block\LapisOre;
use pocketmine\block\RedstoneOre; use pocketmine\block\RedstoneOre;
use pocketmine\level\ChunkManager;
use pocketmine\level\generator\biome\Biome;
use pocketmine\level\generator\Generator;
use pocketmine\level\generator\noise\Simplex;
use pocketmine\level\generator\normal\object\OreType as OreType2;
use pocketmine\level\generator\object\OreType;
use pocketmine\level\Level; use pocketmine\level\Level;
use Ad5001\BetterGen\biome\BetterForest; use pocketmine\math\Vector3;
use Ad5001\BetterGen\biome\BetterDesert; use pocketmine\utils\Random;
use Ad5001\BetterGen\biome\BetterIcePlains;
use Ad5001\BetterGen\biome\BetterMesa;
use Ad5001\BetterGen\biome\BetterMesaPlains;
use Ad5001\BetterGen\biome\BetterRiver;
use Ad5001\BetterGen\biome\Mountainable;
use Ad5001\BetterGen\populator\CavePopulator;
use Ad5001\BetterGen\populator\RavinePopulator;
use Ad5001\BetterGen\populator\LakePopulator;
use Ad5001\BetterGen\populator\MineshaftPopulator;
use Ad5001\BetterGen\populator\FloatingIslandPopulator;
use Ad5001\BetterGen\Main;
class BetterNormal extends Generator { class BetterNormal extends Generator {
const NOT_OVERWRITABLE = [ const NOT_OVERWRITABLE = [
@ -60,12 +59,16 @@ class BetterNormal extends Generator {
Block::WATER, Block::WATER,
Block::STILL_WATER Block::STILL_WATER
]; ];
/** @var BetterBiomeSelector */
protected $selector; protected $selector;
/** @var Level */
protected $level; protected $level;
/** @var Random */
protected $random; protected $random;
protected $populators = [ ]; protected $populators = [ ];
protected $generationPopulators = [ ]; protected $generationPopulators = [ ];
public static $biomes = [ ]; public static $biomes = [ ];
/** @var Biome[] */
public static $biomeById = [ ]; public static $biomeById = [ ];
public static $levels = [ ]; public static $levels = [ ];
protected static $GAUSSIAN_KERNEL = null; // From main class protected static $GAUSSIAN_KERNEL = null; // From main class
@ -75,6 +78,7 @@ class BetterNormal extends Generator {
] ]
]; ];
protected $waterHeight = 63; protected $waterHeight = 63;
private $noiseBase;
/* /*
* Picks a biome by X and Z * Picks a biome by X and Z
@ -231,6 +235,7 @@ class BetterNormal extends Generator {
* @param $rainfall float * @param $rainfall float
*/ */
public static function getBiome($temperature, $rainfall) { public static function getBiome($temperature, $rainfall) {
$ret = null;
if (! isset(self::$biomes [( string ) round($rainfall, 1 )] )) { if (! isset(self::$biomes [( string ) round($rainfall, 1 )] )) {
while(! isset(self::$biomes [( string ) round($rainfall, 1 )] ) ) { while(! isset(self::$biomes [( string ) round($rainfall, 1 )] ) ) {
if (abs($rainfall - round($rainfall, 1 ) ) >= 0.05) if (abs($rainfall - round($rainfall, 1 ) ) >= 0.05)
@ -252,9 +257,8 @@ class BetterNormal extends Generator {
} }
if (is_string($ret )) { if (is_string($ret )) {
$ret = new $ret (); $ret = new $ret ();
} else {
return $ret;
} }
return $ret;
} }
/* /*
@ -263,7 +267,7 @@ class BetterNormal extends Generator {
* @return Biome * @return Biome
*/ */
public function getBiomeById(int $id): Biome { public function getBiomeById(int $id): Biome {
return self::$biomeById[$id] ?? self::$biomeById(Biome::OCEAN); return self::$biomeById[$id] ?? self::$biomeById[Biome::OCEAN];
} }
/* /*
@ -386,7 +390,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() { private static function generateKernel() {
self::$GAUSSIAN_KERNEL = [ ]; self::$GAUSSIAN_KERNEL = [ ];
@ -434,7 +438,7 @@ class BetterNormal extends Generator {
* @param $z int * @param $z int
*/ */
protected function getHighestWorkableBlock($x, $z) { protected function getHighestWorkableBlock($x, $z) {
for($y = 127; $y > 0; -- $y) { for($y = Level::Y_MAX - 1; $y > 0; -- $y) {
$b = $this->level->getBlockIdAt($x, $y, $z); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) { if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
break; break;
@ -443,6 +447,6 @@ class BetterNormal extends Generator {
} }
} }
return $y++; return ++$y;
} }
} }

View file

@ -7,23 +7,23 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\loot; namespace Ad5001\BetterGen\loot;
use pocketmine\inventory\BaseInventory;
use pocketmine\item\Item;
use pocketmine\math\Vector3;
use pocketmine\nbt\NBT;
use pocketmine\utils\Config; use pocketmine\utils\Config;
use pocketmine\utils\Random; use pocketmine\utils\Random;
use pocketmine\math\Vector3;
use pocketmine\item\Item;
use pocketmine\inventory\BaseInventory;
use pocketmine\nbt\NBT;
/* /*
* This class is used for loot setting. * 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: * Loot table format:
* { * {
* "max": Max number of loots (storable amount) * "max": Max number of loots (storable amount)
@ -33,9 +33,9 @@ use pocketmine\nbt\NBT;
* "maxCount": Maximal count * "maxCount": Maximal count
* "id": Id of the item * "id": Id of the item
* "data": Item damage * "data": Item damage
* "tags": {"display": {"Name": "Example NBT data"}}. This parameter is optionnal * "tags": {"display": {"Name": "Example NBT data"}}. This parameter is optional
* "minStacks": If choosen, the minimum amount of stacks that can be found * "minStacks": If chosen, the minimum amount of stacks that can be found
* "maxStacks": If choosen the maximum number of stacks that can be choosen * "maxStacks": If chosen the maximum number of stacks that can be chosen
* } * }
* } * }
*/ */
@ -55,7 +55,7 @@ class LootTable {
const LOOT_MINESHAFT = 2; const LOOT_MINESHAFT = 2;
/* /*
* Asyncronous loot table choosing * Asynchronous loot table choosing
* @param $place pocketmine\math\Vector3 * @param $place pocketmine\math\Vector3
* @param $type int * @param $type int
* @param $random pocketmine\utils\Random * @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 $inv pocketmine\inventory\BaseInventory
* @param $pos pocketmine\math\Vector3 * @param $pos pocketmine\math\Vector3
* @return void * @return void
@ -96,7 +96,7 @@ class LootTable {
for($i = 0; $i <= $randCount; $i++) { for($i = 0; $i <= $randCount; $i++) {
$rand = rand(0, count($loots)); $rand = rand(0, count($loots));
$items[$rand] = Item::get($loot["id"], $loot["data"], rand($loot["minCount"], $loot["maxCount"])); $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); $inv->setContents($items);

View file

@ -7,15 +7,15 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use pocketmine\utils\Random;
use pocketmine\level\generator\populator\Populator; use pocketmine\level\generator\populator\Populator;
use pocketmine\utils\Random;
abstract class AmountPopulator extends Populator { abstract class AmountPopulator extends Populator {
protected $baseAmount = 0; protected $baseAmount = 0;

View file

@ -7,21 +7,21 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use pocketmine\utils\Random; use Ad5001\BetterGen\structure\Bush;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use Ad5001\BetterGen\populator\TreePopulator; use pocketmine\level\Level;
use Ad5001\BetterGen\populator\AmountPopulator; use pocketmine\utils\Random;
use Ad5001\BetterGen\structure\Bush;
class BushPopulator extends AmountPopulator { class BushPopulator extends AmountPopulator {
/** @var ChunkManager */
protected $level; protected $level;
protected $type; protected $type;
@ -62,7 +62,7 @@ class BushPopulator extends AmountPopulator {
* @param $z int * @param $z int
*/ */
protected function getHighestWorkableBlock($x, $z) { protected function getHighestWorkableBlock($x, $z) {
for($y = 127; $y > 0; -- $y) { for($y = Level::Y_MAX - 1; $y > 0; -- $y) {
$b = $this->level->getBlockIdAt($x, $y, $z); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) { if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
break; break;
@ -71,6 +71,6 @@ class BushPopulator extends AmountPopulator {
} }
} }
return $y++; return ++$y;
} }
} }

View file

@ -7,7 +7,7 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @link https://github.com/Ad5001/BetterGen
*/ */
@ -15,13 +15,14 @@
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use Ad5001\BetterGen\structure\Cactus;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use pocketmine\level\Level;
use pocketmine\utils\Random; use pocketmine\utils\Random;
use Ad5001\BetterGen\structure\Cactus;
use Ad5001\BetterGen\populator\AmountPopulator;
class CactusPopulator extends AmountPopulator { class CactusPopulator extends AmountPopulator {
/** @var ChunkManager */
protected $level; protected $level;
/* /*
* Constructs the class * Constructs the class
@ -58,12 +59,12 @@ class CactusPopulator extends AmountPopulator {
* @param $z int * @param $z int
*/ */
protected function getHighestWorkableBlock($x, $z) { protected function getHighestWorkableBlock($x, $z) {
for($y = 127; $y >= 0; -- $y) { for($y = Level::Y_MAX - 1; $y >= 0; -- $y) {
$b = $this->level->getBlockIdAt($x, $y, $z); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) { if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) {
break; break;
} }
} }
return $y === 0 ? - 1 : $y++; return $y === 0 ? - 1 : ++$y;
} }
} }

View file

@ -7,21 +7,22 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use pocketmine\utils\Random; use Ad5001\BetterGen\utils\BuildingUtils;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use pocketmine\level\Level;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use Ad5001\BetterGen\utils\BuildingUtils; use pocketmine\utils\Random;
use Ad5001\BetterGen\populator\AmountPopulator;
class CavePopulator extends AmountPopulator { class CavePopulator extends AmountPopulator {
/** @var ChunkManager */
protected $level; protected $level;
const STOP = false; const STOP = false;
const CONTINUE = true; const CONTINUE = true;
@ -65,7 +66,7 @@ class CavePopulator extends AmountPopulator {
* @param $z int * @param $z int
*/ */
protected function getHighestWorkableBlock($x, $z) { protected function getHighestWorkableBlock($x, $z) {
for($y = 127; $y > 0; -- $y) { for($y = Level::Y_MAX - 1; $y > 0; -- $y) {
$b = $this->level->getBlockIdAt($x, $y, $z); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL or $b === Block::SAND or $b === Block::SNOW_BLOCK or $b === Block::SANDSTONE) { if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL or $b === Block::SAND or $b === Block::SNOW_BLOCK or $b === Block::SANDSTONE) {
break; break;
@ -74,7 +75,7 @@ class CavePopulator extends AmountPopulator {
} }
} }
return $y++; return ++$y;
} }
/* /*
@ -91,7 +92,7 @@ class CavePopulator extends AmountPopulator {
foreach($gen = $this->generateBranch($x, $y, $z, 5, 3, 5, $random ) as $v3 ) { foreach($gen = $this->generateBranch($x, $y, $z, 5, 3, 5, $random ) as $v3 ) {
$generatedBranches --; $generatedBranches --;
if ($generatedBranches <= 0) { if ($generatedBranches <= 0) {
$gen->send(self::STOP); $gen->send(self::STOP); // send not found.. @Ad5001 what is that
} else { } else {
$gen->send(self::CONTINUE); $gen->send(self::CONTINUE);
} }
@ -121,7 +122,7 @@ class CavePopulator extends AmountPopulator {
$y --; $y --;
} }
$z += round(($random->nextBoundedInt(round(30 * ($depth / 10) ) + 1 ) / 10 - 1)); $z += round(($random->nextBoundedInt(round(30 * ($depth / 10) ) + 1 ) / 10 - 1));
return [ ]; return;
} }
} }
$repeat = $random->nextBoundedInt(25 ) + 15; $repeat = $random->nextBoundedInt(25 ) + 15;

View file

@ -7,19 +7,22 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use Ad5001\BetterGen\generator\BetterBiomeSelector;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use pocketmine\level\generator\biome\Biome;
use pocketmine\level\Level;
use pocketmine\utils\Random; use pocketmine\utils\Random;
use Ad5001\BetterGen\populator\AmountPopulator;
class DeadbushPopulator extends AmountPopulator { class DeadbushPopulator extends AmountPopulator {
/** @var ChunkManager */
protected $level; protected $level;
/* /*
@ -35,26 +38,31 @@ class DeadbushPopulator extends AmountPopulator {
for($i = 0; $i < $amount; $i++) { for($i = 0; $i < $amount; $i++) {
$x = $random->nextRange($chunkX * 16, $chunkX * 16 + 15); $x = $random->nextRange($chunkX * 16, $chunkX * 16 + 15);
$z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15); $z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15);
if(!in_array($level->getChunk($chunkX, $chunkZ)->getBiomeId(abs($x % 16), ($z % 16)), [40, 39, Biome::DESERT])) continue;
$y = $this->getHighestWorkableBlock($x, $z); $y = $this->getHighestWorkableBlock($x, $z);
if ($y !== -1 && $level->getBlockIdAt($x, $y - 1, $z ) == Block::SAND) { if ($y !== -1) {
$level->setBlockIdAt($x, $y + 1, $z, Block::DEAD_BUSH); $level->setBlockIdAt($x, $y, $z, Block::DEAD_BUSH);
$level->setBlockDataAt($x, $y + 1, $z, 1); $level->setBlockDataAt($x, $y, $z, 1);
} }
} }
} }
/* /**
* Gets the top block (y) on an x and z axes * Gets the top block (y) on an x and z axes
* @param $x int * @param $x
* @param $z int * @param $z
* @return int
*/ */
protected function getHighestWorkableBlock($x, $z) { private function getHighestWorkableBlock($x, $z){
for($y = 127; $y >= 0; -- $y) { for($y = Level::Y_MAX - 1; $y > 0; --$y){
$b = $this->level->getBlockIdAt($x, $y, $z); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) { if($b === Block::DIRT or $b === Block::GRASS or $b === Block::SAND or $b === Block::SANDSTONE or $b === Block::HARDENED_CLAY or $b === Block::STAINED_HARDENED_CLAY){
break; break;
}elseif($b !== Block::AIR){
return -1;
} }
} }
return $y === 0 ? - 1 : $y++;
return ++$y;
} }
} }

View file

@ -7,21 +7,22 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use Ad5001\BetterGen\structure\FallenTree;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use pocketmine\level\Level;
use pocketmine\utils\Random; use pocketmine\utils\Random;
use Ad5001\BetterGen\structure\FallenTree;
use Ad5001\BetterGen\populator\AmountPopulator;
class FallenTreePopulator extends AmountPopulator { class FallenTreePopulator extends AmountPopulator {
/** @var ChunkManager */
protected $level; protected $level;
protected $type; protected $type;
/* /*
@ -45,29 +46,35 @@ class FallenTreePopulator extends AmountPopulator {
$this->level = $level; $this->level = $level;
$amount = $this->getAmount($random); $amount = $this->getAmount($random);
$tree = TreePopulator::$types[$this->type]; $tree = TreePopulator::$types[$this->type];
$fallenTree = new FallenTree(new $tree()); $fallenTree = new \Ad5001\BetterGen\structure\FallenTree(
new $tree()
);
for($i = 0; $i < $amount; $i++) { for($i = 0; $i < $amount; $i++) {
$x = $random->nextRange($chunkX * 16, $chunkX * 16 + 15); $x = $random->nextRange($chunkX * 16, $chunkX * 16 + 15);
$z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15); $z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15);
$y = $this->getHighestWorkableBlock($x, $z); $y = $this->getHighestWorkableBlock($x, $z);
if ($y !== -1 and $fallenTree->canPlaceObject($level, $x, $y + 1, $z, $random )) { if ($y !== -1 and $fallenTree->canPlaceObject($level, $x, $y + 1, $z, $random )) {
$fallenTree->placeObject($level, $x, $y + 1, $z, $random); $fallenTree->placeObject($level, $x, $y + 1, $z);
} }
} }
} }
/* /**
* Gets the top block (y) on an x and z axes * Gets the top block (y) on an x and z axes
* @param $x int * @param $x
* @param $z int * @param $z
* @return int
*/ */
protected function getHighestWorkableBlock($x, $z) { private function getHighestWorkableBlock($x, $z){
for($y = 127; $y >= 0; -- $y) { for($y = Level::Y_MAX - 1; $y > 0; --$y){
$b = $this->level->getBlockIdAt($x, $y, $z); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) { if($b === Block::DIRT or $b === Block::GRASS){
break; break;
}elseif($b !== Block::AIR and $b !== Block::SNOW_LAYER){
return -1;
} }
} }
return $y === 0 ? - 1 : $y++;
return ++$y;
} }
} }

View file

@ -7,27 +7,28 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use pocketmine\level\ChunkManager;
use pocketmine\utils\Random;
use Ad5001\BetterGen\generator\BetterNormal; use Ad5001\BetterGen\generator\BetterNormal;
use pocketmine\block\Block;
use pocketmine\level\generator\object\OreType;
use pocketmine\level\generator\normal\object\OreType as OreType2;
use pocketmine\math\Vector3;
use pocketmine\block\CoalOre;
use pocketmine\block\IronOre;
use pocketmine\block\RedstoneOre;
use pocketmine\block\LapisOre;
use pocketmine\block\GoldOre;
use pocketmine\block\DiamondOre;
use Ad5001\BetterGen\Main; use Ad5001\BetterGen\Main;
use pocketmine\block\Block;
use pocketmine\block\CoalOre;
use pocketmine\block\DiamondOre;
use pocketmine\block\GoldOre;
use pocketmine\block\IronOre;
use pocketmine\block\LapisOre;
use pocketmine\block\RedstoneOre;
use pocketmine\level\ChunkManager;
use pocketmine\level\generator\normal\object\OreType as OreType2;
use pocketmine\level\generator\object\OreType;
use pocketmine\level\Level;
use pocketmine\math\Vector3;
use pocketmine\utils\Random;
class FloatingIslandPopulator extends AmountPopulator { class FloatingIslandPopulator extends AmountPopulator {
@ -39,6 +40,9 @@ class FloatingIslandPopulator extends AmountPopulator {
* @param $chunkZ int * @param $chunkZ int
* @param $random pocketmine\utils\Random * @param $random pocketmine\utils\Random
*/ */
/** @var ChunkManager */
private $level;
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) { public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random) {
$this->level = $level; $this->level = $level;
if($this->getAmount($random) > 130) { if($this->getAmount($random) > 130) {
@ -49,7 +53,7 @@ class FloatingIslandPopulator extends AmountPopulator {
$height = $this->buildIslandBottomShape($level, new Vector3($x, $y, $z), $radius, $random); $height = $this->buildIslandBottomShape($level, new Vector3($x, $y, $z), $radius, $random);
$this->populateOres($level, new Vector3($x, $y - 1, $z), $radius * 2, $height, $random); $this->populateOres($level, new Vector3($x, $y - 1, $z), $radius * 2, $height, $random);
$chunk = $level->getChunk($chunkX, $chunkZ); $chunk = $level->getChunk($chunkX, $chunkZ);
$biome = BetterNormal::getBiomeById($chunk->getBiomeId($x % 16, $z % 16)); $biome = BetterNormal::$biomeById[$chunk->getBiomeId($x % 16, $z % 16)];
$populators = $biome->getPopulators(); $populators = $biome->getPopulators();
foreach($populators as $populator) { foreach($populators as $populator) {
$populator->populate($level, $chunkX, $chunkZ, $random); $populator->populate($level, $chunkX, $chunkZ, $random);
@ -65,7 +69,7 @@ class FloatingIslandPopulator extends AmountPopulator {
* @param $z int * @param $z int
*/ */
protected function getHighestWorkableBlock($x, $z) { protected function getHighestWorkableBlock($x, $z) {
for($y = 127; $y > 0; -- $y) { for($y = Level::Y_MAX - 1; $y > 0; -- $y) {
$b = $this->level->getBlockIdAt($x, $y, $z); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL or $b === Block::SAND) { if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL or $b === Block::SAND) {
break; break;
@ -74,7 +78,7 @@ class FloatingIslandPopulator extends AmountPopulator {
} }
} }
return $y++; return ++$y;
} }
@ -85,14 +89,11 @@ class FloatingIslandPopulator extends AmountPopulator {
* @param $pos pocketmine\math\Vector3 * @param $pos pocketmine\math\Vector3
* @param $radius int * @param $radius int
* @param $random pocketmine\utils\Random * @param $random pocketmine\utils\Random
* @return void * @return int lowest ore point
*/ */
public function buildIslandBottomShape(ChunkManager $level, Vector3 $pos, int $radius, Random $random) { public function buildIslandBottomShape(ChunkManager $level, Vector3 $pos, int $radius, Random $random) {
$pos = $pos->round(); $pos = $pos->round();
$xx = $pos->x;
$zz = $z;
$currentLen = 1; $currentLen = 1;
$isEdge = false;
$hBound = 0; $hBound = 0;
$current = 0; $current = 0;
for($y = $pos->y - 1; $radius > 0; $y--) { for($y = $pos->y - 1; $radius > 0; $y--) {
@ -105,7 +106,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(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)) { if($chunk = $level->getChunk($x >> 4, $z >> 4)) {
$biome = BetterNormal::getBiomeById($chunk->getBiomeId($x % 16, $z % 16)); $biome = BetterNormal::$biomeById[$chunk->getBiomeId($x % 16, $z % 16)];
$block = $biome->getGroundCover()[$pos->y - $y - 1] ?? Block::get(Block::STONE); $block = $biome->getGroundCover()[$pos->y - $y - 1] ?? Block::get(Block::STONE);
$block = $block->getId(); $block = $block->getId();
} elseif($random->nextBoundedInt(5) == 0 && $isEdge) { } elseif($random->nextBoundedInt(5) == 0 && $isEdge) {
@ -121,7 +122,7 @@ class FloatingIslandPopulator extends AmountPopulator {
$oldHB = $hBound; $oldHB = $hBound;
$hBound = $random->nextFloat(); $hBound = $random->nextFloat();
if($current >= $currentLen + $hBound) { if($current >= $currentLen + $hBound) {
if($radius == 0) return; if($radius == 0) return $pos->y;
$current = 0; $current = 0;
$currentLen += 0.3 * ($random->nextFloat() + 0.5); $currentLen += 0.3 * ($random->nextFloat() + 0.5);
$radius--; $radius--;
@ -160,6 +161,6 @@ class FloatingIslandPopulator extends AmountPopulator {
new OreType(new GoldOre (), 2, 8, $pos->y - $height, $pos->y - round($height / 2)), new OreType(new GoldOre (), 2, 8, $pos->y - $height, $pos->y - round($height / 2)),
new OreType(new DiamondOre (), 1, 7, $pos->y - $height, $pos->y - round($height / 4)) new OreType(new DiamondOre (), 1, 7, $pos->y - $height, $pos->y - round($height / 4))
]); ]);
$ores->populate($level, $x >> 4, $z >> 4, $random); $ores->populate($level, $pos->x >> 4, $pos->z >> 4, $random);//x z undefined
} }
} }

View file

@ -7,20 +7,21 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use pocketmine\utils\Random; use Ad5001\BetterGen\structure\Igloo;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use Ad5001\BetterGen\populator\AmountPopulator; use pocketmine\level\Level;
use Ad5001\BetterGen\structure\Igloo; use pocketmine\utils\Random;
class IglooPopulator extends AmountPopulator { class IglooPopulator extends AmountPopulator {
/** @var ChunkManager */
protected $level; protected $level;
/* /*
@ -48,7 +49,7 @@ class IglooPopulator extends AmountPopulator {
* @param $z int * @param $z int
*/ */
protected function getHighestWorkableBlock($x, $z) { protected function getHighestWorkableBlock($x, $z) {
for($y = 127; $y > 0; -- $y) { for($y = Level::Y_MAX - 1; $y > 0; -- $y) {
$b = $this->level->getBlockIdAt($x, $y, $z); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) { if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
break; break;
@ -57,6 +58,6 @@ class IglooPopulator extends AmountPopulator {
} }
} }
return $y++; return ++$y;
} }
} }

View file

@ -7,21 +7,22 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use pocketmine\utils\Random; use Ad5001\BetterGen\utils\BuildingUtils;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use pocketmine\level\Level;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use Ad5001\BetterGen\utils\BuildingUtils; use pocketmine\utils\Random;
use Ad5001\BetterGen\populator\AmountPopulator;
class LakePopulator extends AmountPopulator { class LakePopulator extends AmountPopulator {
/** @var ChunkManager */
protected $level; protected $level;
/* /*
@ -57,7 +58,7 @@ class LakePopulator extends AmountPopulator {
* @param $z int * @param $z int
*/ */
protected function getHighestWorkableBlock($x, $z) { protected function getHighestWorkableBlock($x, $z) {
for($y = 127; $y > 0; -- $y) { for($y = Level::Y_MAX - 1; $y > 0; -- $y) {
$b = $this->level->getBlockIdAt($x, $y, $z); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) { if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
break; break;
@ -66,6 +67,6 @@ class LakePopulator extends AmountPopulator {
} }
} }
return $y++; return ++$y;
} }
} }

View file

@ -7,22 +7,23 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use pocketmine\level\ChunkManager;
use pocketmine\utils\Random;
use Ad5001\BetterGen\utils\BuildingUtils;
use pocketmine\math\Vector3;
use pocketmine\block\Block;
use Ad5001\BetterGen\loot\LootTable; use Ad5001\BetterGen\loot\LootTable;
use Ad5001\BetterGen\utils\BuildingUtils;
use pocketmine\block\Block;
use pocketmine\level\ChunkManager;
use pocketmine\math\Vector3;
use pocketmine\utils\Random;
class MineshaftPopulator extends AmountPopulator { class MineshaftPopulator extends AmountPopulator {
protected $maxPath; protected $maxPath;
/** @var ChunkManager */
protected $level; protected $level;
const DIR_XPLUS = 0; const DIR_XPLUS = 0;
const DIR_XMIN = 1; const DIR_XMIN = 1;
@ -70,14 +71,13 @@ class MineshaftPopulator extends AmountPopulator {
} }
} }
/* /**
* Builds a mineshaft part and return applicable directions * Builds a mineshaft part and return applicable directions
* @param $x int * @param int $x
* @param $y int * @param int $y
* @param $z int * @param int $z
* @param $dir int * @param int $dir
* @param $random pocketmine\utils\Random * @param Random $random
* @param $deepneth int
*/ */
public function generateMineshaftPart(int $x, int $y, int $z, int $dir, Random $random) { public function generateMineshaftPart(int $x, int $y, int $z, int $dir, Random $random) {
if ($this->maxPath -- < 1) if ($this->maxPath -- < 1)
@ -91,18 +91,18 @@ class MineshaftPopulator extends AmountPopulator {
// First, filling everything blank. // 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 )); 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. // 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) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
}, $this->level); }, $this->level);
// Putting rails // 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) { if ($random->nextBoundedInt(3 ) !== 0) {
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL);
$level->setBlockDataAt($v3->x, $v3->y, $v3->z, 1); $level->setBlockDataAt($v3->x, $v3->y, $v3->z, 1);
} }
}, $this->level, $random); }, $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, $z + 1, Block::FENCE); $level->setBlockIdAt($x, $y, $z + 1, Block::FENCE);
$level->setBlockIdAt($x, $y + 1, $z - 1, Block::FENCE); $level->setBlockIdAt($x, $y + 1, $z - 1, Block::FENCE);
@ -131,19 +131,19 @@ class MineshaftPopulator extends AmountPopulator {
// First, filling everything blank. // First, filling everything blank.
BuildingUtils::fill($this->level, new Vector3($x, $y, $z - 1 ), new Vector3($x - 4, $y + 2, $z + 1 )); BuildingUtils::fill($this->level, new Vector3($x, $y, $z - 1 ), new Vector3($x - 4, $y + 2, $z + 1 ));
// Then, making sure the floor is solid. // 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) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
}, $this->level); }, $this->level);
// Putting rails // 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) { if ($random->nextBoundedInt(3 ) !== 0) {
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL);
$level->setBlockDataAt($v3->x, $v3->y, $v3->z, 1); $level->setBlockDataAt($v3->x, $v3->y, $v3->z, 1);
} }
}, $this->level, $random); }, $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, $z + 1, Block::FENCE); $level->setBlockIdAt($x, $y, $z + 1, Block::FENCE);
$level->setBlockIdAt($x, $y + 1, $z - 1, Block::FENCE); $level->setBlockIdAt($x, $y + 1, $z - 1, Block::FENCE);
@ -162,7 +162,7 @@ class MineshaftPopulator extends AmountPopulator {
if ($direction2 == 0) if ($direction2 == 0)
$direction2 = 2; $direction2 = 2;
if ($direction2 == 1) if ($direction2 == 1)
$direction2 = $direction2 = 4;
LootTable::buildLootTable(new Vector3($x - $direction2, $y, $z + $direction ), LootTable::LOOT_MINESHAFT, $random); LootTable::buildLootTable(new Vector3($x - $direction2, $y, $z + $direction ), LootTable::LOOT_MINESHAFT, $random);
} }
if ($random->nextBoundedInt(30 ) !== 0) if ($random->nextBoundedInt(30 ) !== 0)
@ -172,19 +172,19 @@ class MineshaftPopulator extends AmountPopulator {
// First, filling everything blank. // First, filling everything blank.
BuildingUtils::fill($this->level, new Vector3($x - 1, $y, $z ), new Vector3($x + 1, $y + 2, $z + 4 )); 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. // 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) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
}, $this->level); }, $this->level);
// Putting rails // 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) { if ($random->nextBoundedInt(3 ) !== 0) {
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL);
$level->setBlockDataAt($v3->x, $v3->y, $v3->z, 0); $level->setBlockDataAt($v3->x, $v3->y, $v3->z, 0);
} }
}, $this->level, $random); }, $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, $z, Block::FENCE); $level->setBlockIdAt($x + 1, $y, $z, Block::FENCE);
$level->setBlockIdAt($x - 1, $y + 1, $z, Block::FENCE); $level->setBlockIdAt($x - 1, $y + 1, $z, Block::FENCE);
@ -213,19 +213,19 @@ class MineshaftPopulator extends AmountPopulator {
// First, filling everything blank. // First, filling everything blank.
BuildingUtils::fill($this->level, new Vector3($x - 1, $y, $z ), new Vector3($x + 1, $y + 2, $z - 4 )); 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. // 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) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
}, $this->level); }, $this->level);
// Putting rails // 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) { if ($random->nextBoundedInt(3 ) !== 0) {
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::RAIL);
$level->setBlockDataAt($v3->x, $v3->y, $v3->z, 0); $level->setBlockDataAt($v3->x, $v3->y, $v3->z, 0);
} }
}, $this->level, $random); }, $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, $z, Block::FENCE); $level->setBlockIdAt($x + 1, $y, $z, Block::FENCE);
$level->setBlockIdAt($x - 1, $y + 1, $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. // 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) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
@ -310,12 +310,12 @@ class MineshaftPopulator extends AmountPopulator {
self::DIR_ZMIN self::DIR_ZMIN
] : [ ]) ] : [ ])
]; ];
for($i = 7; $i > $newfloor; $i --) { for($i = 7; $i > $newFloor; $i --) {
$chooseNew =(int ) $newFloor && $random->nextBoolean (); $chooseNew =(int ) $newFloor && $random->nextBoolean ();
$choose = $random->nextBoundedInt(4); $choose = $random->nextBoundedInt(4);
unset($possiblePathes [$chooseNew] [$choose]); unset($possiblePathes [$chooseNew] [$choose]);
} }
// Buidling pathes // Building pathes
foreach($possiblePathes [0] as $path ) { foreach($possiblePathes [0] as $path ) {
switch ($path) { switch ($path) {
case self::DIR_XPLUS : case self::DIR_XPLUS :
@ -366,17 +366,17 @@ class MineshaftPopulator extends AmountPopulator {
} }
// Building stairs // Building stairs
for($i = 0; $i < 4; $i ++) { for($i = 0; $i < 4; $i ++) {
switch ($path) { switch ($i) {
case self::DIR_XPLUS : case self::DIR_XPLUS :
BuildingUtils::fill($this->level, new Vector3($x + $i, $y - $i - 1, $z - 2 ), new Vector3($x + $i, $y - $i + 3, $z + 2 ), Block::get(Block::AIR )); BuildingUtils::fill($this->level, new Vector3($x + $i, $y - $i - 1, $z - 2 ), new Vector3($x + $i, $y - $i + 3, $z + 2 ), Block::get(Block::AIR ));
BuildingUtils::fillCallback(new Vector3($x + $i, $y - $i - 2, $z - 2 ), new Vector3($x + $i, $y - $i - 2, $z + 2 ), function ($v3, $level) { BuildingUtils::fillCallback(new Vector3($x + $i, $y - $i - 2, $z - 2 ), new Vector3($x + $i, $y - $i - 2, $z + 2 ), function ($v3, ChunkManager $level) {
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
}, $this->level); }, $this->level);
break; break;
case self::DIR_XMIN : case self::DIR_XMIN :
BuildingUtils::fill($this->level, new Vector3($x - $i, $y - $i - 1, $z - 2 ), new Vector3($x - $i, $y - $i + 3, $z + 2 ), Block::get(Block::AIR )); BuildingUtils::fill($this->level, new Vector3($x - $i, $y - $i - 1, $z - 2 ), new Vector3($x - $i, $y - $i + 3, $z + 2 ), Block::get(Block::AIR ));
BuildingUtils::fillCallback(new Vector3($x - $i, $y - $i - 2, $z - 2 ), new Vector3($x - $i, $y - $i - 2, $z + 2 ), function ($v3, $level) { BuildingUtils::fillCallback(new Vector3($x - $i, $y - $i - 2, $z - 2 ), new Vector3($x - $i, $y - $i - 2, $z + 2 ), function ($v3, ChunkManager $level) {
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
@ -384,7 +384,7 @@ class MineshaftPopulator extends AmountPopulator {
break; break;
case self::DIR_ZPLUS : case self::DIR_ZPLUS :
BuildingUtils::fill($this->level, new Vector3($x - 2, $y - $i - 1, $z + $i ), new Vector3($x + 2, $y - $i + 3, $z + $i ), Block::get(Block::AIR )); BuildingUtils::fill($this->level, new Vector3($x - 2, $y - $i - 1, $z + $i ), new Vector3($x + 2, $y - $i + 3, $z + $i ), Block::get(Block::AIR ));
BuildingUtils::fillCallback(new Vector3($x - 2, $y - $i - 2, $z + $i ), new Vector3($x + 2, $y - $i - 2, $z + $i ), function ($v3, $level) { BuildingUtils::fillCallback(new Vector3($x - 2, $y - $i - 2, $z + $i ), new Vector3($x + 2, $y - $i - 2, $z + $i ), function ($v3, ChunkManager $level) {
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
@ -392,7 +392,7 @@ class MineshaftPopulator extends AmountPopulator {
break; break;
case self::DIR_ZMIN : case self::DIR_ZMIN :
BuildingUtils::fill($this->level, new Vector3($x - 2, $y - $i - 1, $z - $i ), new Vector3($x + 2, $y - $i + 3, $z - $i ), Block::get(Block::AIR )); BuildingUtils::fill($this->level, new Vector3($x - 2, $y - $i - 1, $z - $i ), new Vector3($x + 2, $y - $i + 3, $z - $i ), Block::get(Block::AIR ));
BuildingUtils::fillCallback(new Vector3($x - 2, $y - $i - 2, $z - $i ), new Vector3($x + 2, $y - $i - 2, $z - $i ), function ($v3, $level) { BuildingUtils::fillCallback(new Vector3($x - 2, $y - $i - 2, $z - $i ), new Vector3($x + 2, $y - $i - 2, $z - $i ), function ($v3, ChunkManager $level) {
if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR) if ($level->getBlockIdAt($v3->x, $v3->y, $v3->z ) == Block::AIR)
$level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK); $level->setBlockIdAt($v3->x, $v3->y, $v3->z, Block::PLANK);
@ -402,7 +402,7 @@ class MineshaftPopulator extends AmountPopulator {
} }
// Next one // Next one
switch ($path) { switch ($i) {
case self::DIR_XPLUS : case self::DIR_XPLUS :
$this->generateMineshaftPart($x + 4, $y - 4, $z, self::DIR_XPLUS, $random); $this->generateMineshaftPart($x + 4, $y - 4, $z, self::DIR_XPLUS, $random);
break; break;

View file

@ -7,20 +7,21 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use pocketmine\utils\Random; use Ad5001\BetterGen\utils\BuildingUtils;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use Ad5001\BetterGen\populator\AmountPopulator; use pocketmine\level\Level;
use Ad5001\BetterGen\utils\BuildingUtils; use pocketmine\utils\Random;
class RavinePopulator extends AmountPopulator { class RavinePopulator extends AmountPopulator {
/** @var ChunkManager */
protected $level; protected $level;
const NOISE = 250; const NOISE = 250;
@ -74,7 +75,7 @@ class RavinePopulator extends AmountPopulator {
* @param $z int * @param $z int
*/ */
protected function getHighestWorkableBlock($x, $z) { protected function getHighestWorkableBlock($x, $z) {
for($y = 127; $y > 0; -- $y) { for($y = Level::Y_MAX - 1; $y > 0; -- $y) {
$b = $this->level->getBlockIdAt($x, $y, $z); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL or $b === Block::SAND or $b === Block::SNOW_BLOCK or $b === Block::SANDSTONE) { if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL or $b === Block::SAND or $b === Block::SNOW_BLOCK or $b === Block::SANDSTONE) {
break; break;
@ -83,7 +84,7 @@ class RavinePopulator extends AmountPopulator {
} }
} }
return $y++; return ++$y;
} }
/* /*

View file

@ -7,20 +7,21 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use Ad5001\BetterGen\structure\SugarCane;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use pocketmine\level\Level;
use pocketmine\utils\Random; use pocketmine\utils\Random;
use Ad5001\BetterGen\structure\SugarCane;
use Ad5001\BetterGen\populator\AmountPopulator;
class SugarCanePopulator extends AmountPopulator { class SugarCanePopulator extends AmountPopulator {
/** @var ChunkManager */
protected $level; protected $level;
/* /*
* Constructs the class * Constructs the class
@ -57,12 +58,12 @@ class SugarCanePopulator extends AmountPopulator {
* @param $z int * @param $z int
*/ */
protected function getHighestWorkableBlock($x, $z) { protected function getHighestWorkableBlock($x, $z) {
for($y = 127; $y >= 0; -- $y) { for($y = Level::Y_MAX - 1; $y >= 0; -- $y) {
$b = $this->level->getBlockIdAt($x, $y, $z); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) { if ($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2) {
break; break;
} }
} }
return $y === 0 ? - 1 : $y++; return $y === 0 ? - 1 : ++$y;
} }
} }

View file

@ -7,20 +7,21 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use pocketmine\utils\Random; use Ad5001\BetterGen\structure\Temple;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use Ad5001\BetterGen\structure\Temple; use pocketmine\level\Level;
use Ad5001\BetterGen\populator\AmountPopulator; use pocketmine\utils\Random;
class TemplePopulator extends AmountPopulator { class TemplePopulator extends AmountPopulator {
/** @var Level */
protected $level; protected $level;
/* /*
@ -48,13 +49,13 @@ class TemplePopulator extends AmountPopulator {
* @param $z int * @param $z int
*/ */
protected function getHighestWorkableBlock($x, $z) { protected function getHighestWorkableBlock($x, $z) {
for($y = 127; $y > 0; -- $y) { for($y = Level::Y_MAX - 1; $y > 0; -- $y) {
$b = $this->level->getBlockIdAt($x, $y, $z); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b === Block::SAND) { if ($b === Block::SAND) {
break; break;
} }
} }
return $y++; return ++$y;
} }
} }

View file

@ -7,27 +7,29 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use pocketmine\utils\Random; use Ad5001\BetterGen\Main;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use Ad5001\BetterGen\structure\SakuraTree; use pocketmine\level\generator\object\Tree;
use Ad5001\BetterGen\populator\AmountPopulator; use pocketmine\level\Level;
use Ad5001\BetterGen\Main; use pocketmine\utils\Random;
class TreePopulator extends AmountPopulator { class TreePopulator extends AmountPopulator {
/** @var Tree[] */
static $types = [ static $types = [
"pocketmine\\level\\generator\\object\\OakTree", "pocketmine\\level\\generator\\object\\OakTree",
"pocketmine\\level\\generator\\object\\BirchTree", "pocketmine\\level\\generator\\object\\BirchTree",
"Ad5001\\BetterGen\\structure\\SakuraTree" "Ad5001\\BetterGen\\structure\\SakuraTree"
]; ];
/** @var ChunkManager */
protected $level; protected $level;
protected $type; protected $type;
@ -63,6 +65,7 @@ class TreePopulator extends AmountPopulator {
continue; continue;
} }
$treeC = self::$types [$this->type]; $treeC = self::$types [$this->type];
/** @var Tree $tree */
$tree = new $treeC(); $tree = new $treeC();
$tree->placeObject($level, $x, $y, $z, $random); $tree->placeObject($level, $x, $y, $z, $random);
} }
@ -74,7 +77,7 @@ class TreePopulator extends AmountPopulator {
* @param $z int * @param $z int
*/ */
protected function getHighestWorkableBlock($x, $z) { protected function getHighestWorkableBlock($x, $z) {
for($y = 127; $y > 0; -- $y) { for($y = Level::Y_MAX - 1; $y > 0; -- $y) {
$b = $this->level->getBlockIdAt($x, $y, $z); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) { if ($b === Block::DIRT or $b === Block::GRASS or $b === Block::PODZOL) {
break; break;
@ -83,6 +86,6 @@ class TreePopulator extends AmountPopulator {
} }
} }
return $y++; return ++$y;
} }
} }

View file

@ -7,20 +7,21 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\populator; namespace Ad5001\BetterGen\populator;
use pocketmine\utils\Random; use Ad5001\BetterGen\structure\Well;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use Ad5001\BetterGen\structure\Well; use pocketmine\level\Level;
use Ad5001\BetterGen\populator\AmountPopulator; use pocketmine\utils\Random;
class WellPopulator extends AmountPopulator { class WellPopulator extends AmountPopulator {
/** @var ChunkManager */
protected $level; protected $level;
/* /*
@ -48,13 +49,13 @@ class WellPopulator extends AmountPopulator {
* @param $z int * @param $z int
*/ */
protected function getHighestWorkableBlock($x, $z) { protected function getHighestWorkableBlock($x, $z) {
for($y = 127; $y > 0; -- $y) { for($y = Level::Y_MAX - 1; $y > 0; -- $y) {
$b = $this->level->getBlockIdAt($x, $y, $z); $b = $this->level->getBlockIdAt($x, $y, $z);
if ($b === Block::SAND) { if ($b === Block::SAND) {
break; break;
} }
} }
return $y++; return ++$y;
} }
} }

View file

@ -7,19 +7,18 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\structure; namespace Ad5001\BetterGen\structure;
use pocketmine\block\Leaves;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use pocketmine\utils\Random;
use pocketmine\math\Vector3;
use pocketmine\level\generator\object\Object; use pocketmine\level\generator\object\Object;
use pocketmine\math\Vector3;
use pocketmine\utils\Random;
class Bush extends Object { class Bush extends Object {
public $overridable = [ public $overridable = [

View file

@ -7,7 +7,7 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @link https://github.com/Ad5001/BetterGen
*/ */
@ -15,9 +15,9 @@
namespace Ad5001\BetterGen\structure; namespace Ad5001\BetterGen\structure;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\utils\Random;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use pocketmine\level\generator\object\Object; use pocketmine\level\generator\object\Object;
use pocketmine\utils\Random;
class Cactus extends Object { class Cactus extends Object {
@ -29,10 +29,12 @@ class Cactus extends Object {
* @param $z int * @param $z int
* @param $random pocketmine\utils\Random * @param $random pocketmine\utils\Random
*/ */
private $totalHeight;
public function canPlaceObject(ChunkManager $level, int $x, int $y, int $z, Random $random): bool { public function canPlaceObject(ChunkManager $level, int $x, int $y, int $z, Random $random): bool {
$this->totalHeight = 1 + $random->nextBoundedInt(3); $this->totalHeight = 1 + $random->nextBoundedInt(3);
$below = $level->getBlockIdAt($x, $y - 1, $z); $below = $level->getBlockIdAt($x, $y - 1, $z);
for($yy = $y; $yy <= $y + $totalHeight; $yy ++) { for($yy = $y; $yy <= $y + $this->totalHeight; $yy ++) {
if ($level->getBlockIdAt($x, $yy, $z ) !== Block::AIR || ($below !== Block::SAND && $below !== Block::CACTUS) || ($level->getBlockIdAt($x - 1, $yy, $z ) !== Block::AIR || $level->getBlockIdAt($x + 1, $yy, $z ) !== Block::AIR || $level->getBlockIdAt($x, $yy, $z - 1 ) !== Block::AIR || $level->getBlockIdAt($x, $yy, $z + 1 ) !== Block::AIR)) { if ($level->getBlockIdAt($x, $yy, $z ) !== Block::AIR || ($below !== Block::SAND && $below !== Block::CACTUS) || ($level->getBlockIdAt($x - 1, $yy, $z ) !== Block::AIR || $level->getBlockIdAt($x + 1, $yy, $z ) !== Block::AIR || $level->getBlockIdAt($x, $yy, $z - 1 ) !== Block::AIR || $level->getBlockIdAt($x, $yy, $z + 1 ) !== Block::AIR)) {
return false; return false;
} }

View file

@ -7,20 +7,20 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\structure; namespace Ad5001\BetterGen\structure;
use pocketmine\block\Leaves; use Ad5001\BetterGen\utils\BuildingUtils;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use pocketmine\utils\Random;
use pocketmine\math\Vector3;
use pocketmine\level\generator\object\Object; use pocketmine\level\generator\object\Object;
use Ad5001\BetterGen\utils\BuildingUtils; use pocketmine\level\generator\object\Tree as ObjectTree;
use pocketmine\math\Vector3;
use pocketmine\utils\Random;
class FallenTree extends Object { class FallenTree extends Object {
@ -39,13 +39,14 @@ class FallenTree extends Object {
protected $tree; protected $tree;
protected $direction; protected $direction;
protected $random; protected $random;
private $length = 0;
/* /*
* Constructs the class * Constructs the class
* @param $tree Tree * @param $tree ObjectTree
* @throws Exeption * @throws Exeption
*/ */
public function __construct(Tree $tree) { public function __construct(ObjectTree $tree) {
$this->tree = $tree; $this->tree = $tree;
} }
@ -59,22 +60,24 @@ class FallenTree extends Object {
*/ */
public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) { public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) {
$randomHeight = round($random->nextBoundedInt(6) - 3); $randomHeight = round($random->nextBoundedInt(6) - 3);
$this->length = $this->tree->trunkHeight + $randomHeight; $this->length = ($this->tree->trunkHeight??5) + $randomHeight;
$this->direction = $random->nextBoundedInt(4); $this->direction = $random->nextBoundedInt(4);
$this->random = $random; $this->random = $random;
switch($this->direction) { switch ($this->direction) {
case 0: case 0:
case 1:// Z+ 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(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; if (!in_array($level->getBlockIdAt($v3->x, $v3->y, $v3->z), $this->overridable)) return false;
else return true;
}, $level))) { }, $level))) {
return false; return false;
} }
break; break;
case 2: case 2:
case 3: // X+ 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, ChunkManager $level) {
if(!in_array($level->getBlockIdAt($v3->x, $v3->y, $v3->z), $this->overridable)) return false; if (!in_array($level->getBlockIdAt($v3->x, $v3->y, $v3->z), $this->overridable)) return false;
else return true;
}, $level))) { }, $level))) {
return false; return false;
} }
@ -92,11 +95,12 @@ class FallenTree extends Object {
*/ */
public function placeObject(ChunkManager $level, $x, $y, $z) { public function placeObject(ChunkManager $level, $x, $y, $z) {
echo "Placing at $x $y $z FallenTree\n"; echo "Placing at $x $y $z FallenTree\n";
switch($this->direction) { switch ($this->direction) {
case 0: case 0:
$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);
$z += 2; $z += 2;
break;
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);
@ -106,6 +110,7 @@ class FallenTree extends Object {
$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;
break;
case 3: // X+ 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::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);
@ -113,7 +118,7 @@ class FallenTree extends Object {
break; break;
} }
// Second call to build the last wood block // Second call to build the last wood block
switch($this->direction) { switch ($this->direction) {
case 1: case 1:
$level->setBlockIdAt($x, $y, $z + $this->length + 2, $this->tree->trunkBlock); $level->setBlockIdAt($x, $y, $z + $this->length + 2, $this->tree->trunkBlock);
break; break;
@ -131,9 +136,9 @@ class FallenTree extends Object {
* @param $level pocketmine\level\ChunkManager * @param $level pocketmine\level\ChunkManager
*/ */
public function placeBlock($x, $y, $z, ChunkManager $level) { 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 )] )) { 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->setBlockIdAt($x, $y, $z, $this->tree->leafBlock);
$level->setBlockDataAt($x, $y, $z, $this->trunk [1]); $level->setBlockDataAt($x, $y, $z, $this->tree->type);
} }
} }
} }

View file

@ -7,7 +7,7 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @link https://github.com/Ad5001/BetterGen
*/ */
@ -16,8 +16,8 @@ namespace Ad5001\BetterGen\structure;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use pocketmine\utils\Random;
use pocketmine\level\generator\object\Object; use pocketmine\level\generator\object\Object;
use pocketmine\utils\Random;
class Igloo extends Object { class Igloo extends Object {
public $overridable = [ public $overridable = [
@ -59,7 +59,7 @@ class Igloo extends Object {
if (! isset($this->overridable [$level->getBlockIdAt($xx, $yy, $zz )] )) if (! isset($this->overridable [$level->getBlockIdAt($xx, $yy, $zz )] ))
return false; return false;
break; break;
case 2 : // Entrence is z+ case 2 : // Entrance is z+
for($xx = $x - 3; $xx <= $x + 3; $xx ++) for($xx = $x - 3; $xx <= $x + 3; $xx ++)
for($yy = $y + 1; $yy <= $y + 4; $yy ++) for($yy = $y + 1; $yy <= $y + 4; $yy ++)
for($zz = $z - 3; $zz <= $z + 4; $zz ++) for($zz = $z - 3; $zz <= $z + 4; $zz ++)
@ -84,6 +84,7 @@ class Igloo extends Object {
* @param $y int * @param $y int
* @param $z int * @param $z int
* @param $random pocketmine\utils\Random * @param $random pocketmine\utils\Random
* @return bool placed
*/ */
public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) { public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) {
if (! isset($this->direction ) && ! $this->canPlaceObject($level, $x, $y, $z, $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); $level->setBlockIdAt($xx, $y + 1, $zz, Block::CARPET);
} }
// Other furnitures // Other furniture
// Bed // Bed
$level->setBlockIdAt($x - 1, $y + 1, $z + 2, Block::BED_BLOCK); $level->setBlockIdAt($x - 1, $y + 1, $z + 2, Block::BED_BLOCK);
$level->setBlockIdAt($x, $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); $level->setBlockIdAt($xx, $y + 1, $zz, Block::CARPET);
} }
// Other furnitures // Other furniture
// Bed // Bed
$level->setBlockIdAt($x + 1, $y + 1, $z + 2, Block::BED_BLOCK); $level->setBlockIdAt($x + 1, $y + 1, $z + 2, Block::BED_BLOCK);
$level->setBlockIdAt($x, $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; break;
// Third direction // Third direction
case 2 : // Entrence is z+ case 2 : // Entrance is z+
// Ground // Ground
for($xx = $x - 3; $xx <= $x + 3; $xx ++) for($xx = $x - 3; $xx <= $x + 3; $xx ++)
for($zz = $z - 3; $zz <= $z + 4; $zz ++) for($zz = $z - 3; $zz <= $z + 4; $zz ++)
@ -299,7 +300,7 @@ class Igloo extends Object {
$level->setBlockIdAt($xx, $y + 1, $zz, Block::CARPET); $level->setBlockIdAt($xx, $y + 1, $zz, Block::CARPET);
} }
// Other furnitures // Other furniture
// Bed // Bed
$level->setBlockIdAt($x + 2, $y + 1, $z - 1, Block::BED_BLOCK); $level->setBlockIdAt($x + 2, $y + 1, $z - 1, Block::BED_BLOCK);
$level->setBlockIdAt($x + 2, $y + 1, $z, 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); $level->setBlockIdAt($xx, $y + 1, $zz, Block::CARPET);
} }
// Other furnitures // Other furniture
// Bed // Bed
$level->setBlockIdAt($x + 2, $y + 1, $z + 1, Block::BED_BLOCK); $level->setBlockIdAt($x + 2, $y + 1, $z + 1, Block::BED_BLOCK);
$level->setBlockIdAt($x + 2, $y + 1, $z, 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); $level->setBlockIdAt($x - 2, $y + 1, $z + 1, Block::FURNACE);
break; break;
} }
return true;
} }
} }

View file

@ -7,26 +7,28 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\structure; namespace Ad5001\BetterGen\structure;
use Ad5001\BetterGen\Main;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\block\Wood; use pocketmine\block\Wood;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use pocketmine\level\generator\object\Tree;
use pocketmine\utils\Random; use pocketmine\utils\Random;
use Ad5001\BetterGen\Main;
if(Main::isOtherNS()) { if (Main::isOtherNS()) {
class_alias("pocketmine\\level\\generator\\normal\\object\\Tree", "Ad5001\\BetterGen\\structure\\Tree"); class_alias("pocketmine\\level\\generator\\normal\\object\\Tree", "Ad5001\\BetterGen\\structure\\Tree");
} else { } else {
class_alias("pocketmine\\level\\generator\\object\\Tree", "Ad5001\\BetterGen\\structure\\Tree"); class_alias("pocketmine\\level\\generator\\object\\Tree", "Ad5001\\BetterGen\\structure\\Tree");
} }
class SakuraTree extends Tree { 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 => [ 7 => [
0, 0,
1 1
@ -63,16 +65,16 @@ class SakuraTree extends Tree {
4 4
], ],
[ [
- 4, -4,
4 4
], ],
[ [
4, 4,
- 4 -4
], ],
[ [
- 4, -4,
- 4 -4
] ]
], ],
8 => [ 8 => [
@ -81,16 +83,16 @@ class SakuraTree extends Tree {
6 6
], ],
[ [
- 6, -6,
6 6
], ],
[ [
6, 6,
- 6 -6
], ],
[ [
- 6, -6,
- 6 -6
] ]
], ],
9 => [ 9 => [
@ -99,16 +101,16 @@ class SakuraTree extends Tree {
6 6
], ],
[ [
- 6, -6,
6 6
], ],
[ [
6, 6,
- 6 -6
], ],
[ [
- 6, -6,
- 6 -6
] ]
], ],
10 => [ 10 => [
@ -117,16 +119,16 @@ class SakuraTree extends Tree {
6 6
], ],
[ [
- 6, -6,
6 6
], ],
[ [
6, 6,
- 6 -6
], ],
[ [
- 6, -6,
- 6 -6
] ]
], ],
11 => [ 11 => [
@ -143,40 +145,40 @@ class SakuraTree extends Tree {
6 6
], ],
[ [
- 7, -7,
7 7
], ],
[ [
- 6, -6,
8 8
], ],
[ [
- 8, -8,
6 6
], ],
[ [
7, 7,
- 7 -7
], ],
[ [
6, 6,
- 8 -8
], ],
[ [
8, 8,
- 6 -6
], ],
[ [
- 7, -7,
- 7 -7
], ],
[ [
- 6, -6,
- 8 -8
], ],
[ [
- 8, -8,
- 6 -6
] ]
], ],
12 => [ 12 => [
@ -193,40 +195,40 @@ class SakuraTree extends Tree {
6 6
], ],
[ [
- 7, -7,
7 7
], ],
[ [
- 6, -6,
8 8
], ],
[ [
- 8, -8,
6 6
], ],
[ [
7, 7,
- 7 -7
], ],
[ [
6, 6,
- 8 -8
], ],
[ [
8, 8,
- 6 -6
], ],
[ [
- 7, -7,
- 7 -7
], ],
[ [
- 6, -6,
- 8 -8
], ],
[ [
- 8, -8,
- 6 -6
] ]
], ],
13 => [ 13 => [
@ -243,48 +245,48 @@ class SakuraTree extends Tree {
6 6
], ],
[ [
- 7, -7,
7 7
], ],
[ [
- 6, -6,
8 8
], ],
[ [
- 8, -8,
6 6
], ],
[ [
7, 7,
- 7 -7
], ],
[ [
6, 6,
- 8 -8
], ],
[ [
8, 8,
- 6 -6
], ],
[ [
- 7, -7,
- 7 -7
], ],
[ [
- 6, -6,
- 8 -8
], ],
[ [
- 8, -8,
- 6 -6
] ]
] ]
]; ];
const ADDITIONAL_BLOCKS = [ // Blocks who aren't set to fully fill the tree. X relative to $lastX and Z from $lastZ const ADDITIONAL_BLOCKS = [ // Blocks who aren't set to fully fill the tree. X relative to $lastX and Z from $lastZ
7 => [ ], 7 => [],
8 => [ ], 8 => [],
9 => [ ], 9 => [],
10 => [ ], 10 => [],
11 => [ 11 => [
[ [
6, 6,
@ -299,40 +301,40 @@ class SakuraTree extends Tree {
7 7
], ],
[ [
- 6, -6,
6 6
], ],
[ [
- 7, -7,
6 6
], ],
[ [
- 6, -6,
7 7
], ],
[ [
6, 6,
- 6 -6
], ],
[ [
7, 7,
- 6 -6
], ],
[ [
6, 6,
- 7 -7
], ],
[ [
- 6, -6,
- 6 -6
], ],
[ [
- 7, -7,
- 6 -6
], ],
[ [
- 6, -6,
- 7 -7
] ]
], ],
12 => [ 12 => [
@ -349,40 +351,40 @@ class SakuraTree extends Tree {
7 7
], ],
[ [
- 6, -6,
6 6
], ],
[ [
- 7, -7,
6 6
], ],
[ [
- 6, -6,
7 7
], ],
[ [
6, 6,
- 6 -6
], ],
[ [
7, 7,
- 6 -6
], ],
[ [
6, 6,
- 7 -7
], ],
[ [
- 6, -6,
- 6 -6
], ],
[ [
- 7, -7,
- 6 -6
], ],
[ [
- 6, -6,
- 7 -7
] ]
], ],
13 => [ 13 => [
@ -399,40 +401,40 @@ class SakuraTree extends Tree {
7 7
], ],
[ [
- 6, -6,
6 6
], ],
[ [
- 7, -7,
6 6
], ],
[ [
- 6, -6,
7 7
], ],
[ [
6, 6,
- 6 -6
], ],
[ [
7, 7,
- 6 -6
], ],
[ [
6, 6,
- 7 -7
], ],
[ [
- 6, -6,
- 6 -6
], ],
[ [
- 7, -7,
- 6 -6
], ],
[ [
- 6, -6,
- 7 -7
] ]
] ]
]; ];
@ -440,6 +442,8 @@ class SakuraTree extends Tree {
public $trunkHeight = 11; public $trunkHeight = 11;
public $leafType;
public $leaf2Type;
/* /*
* Constructs the class * Constructs the class
@ -468,6 +472,8 @@ class SakuraTree extends Tree {
} }
$trunkHeight = 7 + $random->nextBoundedInt(7); $trunkHeight = 7 + $random->nextBoundedInt(7);
$xDiff = $zDiff = 0;
$direction = $random->nextBoundedInt(3); // Choosing building north east west south $direction = $random->nextBoundedInt(3); // Choosing building north east west south
switch ($direction) { switch ($direction) {
case 0 : case 0 :
@ -487,20 +493,20 @@ class SakuraTree extends Tree {
$zDiff = 0; $zDiff = 0;
break; break;
} }
list($vParts, $hParts ) = self::TRUNK_POS [$trunkHeight]; list($vParts, $hParts) = self::TRUNK_POS [$trunkHeight];
$this->setLog($level, $x, $y, $z); $this->setLog($level, $x, $y, $z);
list($lastX, $lastY, $lastZ ) = [ list($lastX, $lastY, $lastZ) = [
$x, $x,
$y, $y,
$z $z
]; ];
// Filling horisontally // Filling horizontally
if ($hParts > 0) { if ($hParts > 0) {
for($i = 0; $i < $hParts; $i ++) { for ($i = 0; $i < $hParts; $i++) {
$lastX += $xDiff * 2; $lastX += $xDiff * 2;
$lastY ++; $lastY++;
$lastZ += $zDiff * 2; $lastZ += $zDiff * 2;
$this->setLog($level, $lastX - $xDiff, $lastY, $lastZ - $zDiff); $this->setLog($level, $lastX - $xDiff, $lastY, $lastZ - $zDiff);
$this->setLog($level, $lastX, $lastY, $lastZ); $this->setLog($level, $lastX, $lastY, $lastZ);
@ -509,13 +515,13 @@ class SakuraTree extends Tree {
// The middle block // The middle block
$lastX += $xDiff; $lastX += $xDiff;
$lastY ++; $lastY++;
$lastZ += $zDiff; $lastZ += $zDiff;
$this->setLog($level, $lastX, $lastY, $lastZ); $this->setLog($level, $lastX, $lastY, $lastZ);
// Filling verticaly // Filling vertically
if ($vParts > 0) { if ($vParts > 0) {
for($i = 0; $i < $vParts; $i ++) { for ($i = 0; $i < $vParts; $i++) {
$lastX += $xDiff; $lastX += $xDiff;
$lastY += 2; $lastY += 2;
$lastZ += $zDiff; $lastZ += $zDiff;
@ -525,18 +531,20 @@ class SakuraTree extends Tree {
} }
// Filling the top trunk. // Filling the top trunk.
$lastX += $xDiff; $lastX += $xDiff;
$lastY ++; $lastY++;
$lastZ += $zDiff; $lastZ += $zDiff;
for($i = 0; $i < 4; $i ++) { for ($i = 0; $i < 4; $i++) {
$this->setLog($level, $lastX, $lastY + $i, $lastZ); $this->setLog($level, $lastX, $lastY + $i, $lastZ);
} }
$lastY ++; $lastY++;
// FIlling the branches. // Filling the branches.
$branchLen2 = function ($base) { $branchLen2 = function ($base) {
return ceil($base / 2); return ceil($base / 2);
}; };
for($dir = 0; $dir < 4; $dir ++) { $xd = $zd = 0;
for ($dir = 0; $dir < 4; $dir++) {
switch ($dir) { switch ($dir) {
case 0 : case 0 :
$xd = 0; $xd = 0;
@ -561,32 +569,36 @@ class SakuraTree extends Tree {
$totalLength = $stickLen + $stickLen2; // Length of the stick $totalLength = $stickLen + $stickLen2; // Length of the stick
$sideLen = $totalLength ** 2; // Side length $sideLen = $totalLength ** 2; // Side length
//TODO CHECK WHAT THIS IS SUPPOSED TO BE
$numForward = ($totalLength % 2 == 0) ? $totalLength - 1 : $totalLength;
//TODO END
$lX1 = $lZ1 = $lX = $lZ = 0;
// First branch part + first leave part // First branch part + first leave part
for($i = 1; $i < $stickLen + 1; $i ++) { for ($i = 1; $i < $stickLen + 1; $i++) {
$lX1 = $lastX + ($xd * $i); $lX1 = $lastX + ($xd * $i);
$lZ1 = $lastZ + ($zd * $i); $lZ1 = $lastZ + ($zd * $i);
if ($zd !== 0) if ($zd !== 0)
for($x = $lX1 - $numForward; $x !== $lX1 + $numForward + 1; $x ++) { for ($x = $lX1 - $numForward; $x !== $lX1 + $numForward + 1; $x++) {
$this->setLeave($level, $x, $lastY + 3, $lZ1, $random); $this->setLeave($level, $x, $lastY + 3, $lZ1, $random);
} }
if ($xd !== 0) if ($xd !== 0)
for($z = $lZ1 - $numForward; $z !== $lZ1 + $numForward + 1; $z ++) { for ($z = $lZ1 - $numForward; $z !== $lZ1 + $numForward + 1; $z++) {
$this->setLeave($level, $lX1, $lastY + 3, $z, $random); $this->setLeave($level, $lX1, $lastY + 3, $z, $random);
} }
$this->setLog($level, $lX1, $lastY, $lZ1); $this->setLog($level, $lX1, $lastY, $lZ1);
} }
// Second branch part. + second leave part // Second branch part. + second leave part
$numForward = ($totalLength % 2 == 0) ? $totalLength - 1 : $totalLength; for ($i = 1; $i < $stickLen + 1; $i++) {
for($i = 1; $i < $stickLen + 1; $i ++) {
$lX = $lX1 + ($xd * $i); $lX = $lX1 + ($xd * $i);
$lZ = $lZ1 + ($zd * $i); $lZ = $lZ1 + ($zd * $i);
if ($zd !== 0) if ($zd !== 0)
for($x = $lX - $numForward; $x !== $lX + $numForward + 1; $x ++) { for ($x = $lX - $numForward; $x !== $lX + $numForward + 1; $x++) {
$this->setLeave($level, $x, $lastY + 2, $lZ, $random); $this->setLeave($level, $x, $lastY + 2, $lZ, $random);
} }
if ($xd !== 0) if ($xd !== 0)
for($z = $lZ - $numForward; $z !== $lZ + $numForward + 1; $z ++) { for ($z = $lZ - $numForward; $z !== $lZ + $numForward + 1; $z++) {
$this->setLeave($level, $lX, $lastY + 2, $z, $random); $this->setLeave($level, $lX, $lastY + 2, $z, $random);
} }
$this->setLog($level, $lX, $lastY + 1, $lZ); $this->setLog($level, $lX, $lastY + 1, $lZ);
@ -596,15 +608,15 @@ class SakuraTree extends Tree {
$lZ += $zd; $lZ += $zd;
// Leaves falling from the tree forward // Leaves falling from the tree forward
if ($lastZ !== $lZ) { // Z has changed, using X for setting if ($lastZ !== $lZ) { // Z has changed, using X for setting
for($x = $lX - $numForward; $x <= $lX + $numForward; $x ++) { for ($x = $lX - $numForward; $x <= $lX + $numForward; $x++) {
$numDown = $random->nextBoundedInt(3 ) + 1; $numDown = $random->nextBoundedInt(3) + 1;
for($y = $lastY + 1; $y > $lastY - $numDown; $y --) for ($y = $lastY + 1; $y > $lastY - $numDown; $y--)
$this->setLeave($level, $x, $y, $lZ, $random); $this->setLeave($level, $x, $y, $lZ, $random);
} }
} else { // Z have stayed, X has changed } else { // Z have stayed, X has changed
for($z = $lZ - $numForward; $z <= $lZ + $numForward; $z ++) { for ($z = $lZ - $numForward; $z <= $lZ + $numForward; $z++) {
$numDown = $random->nextBoundedInt(3 ) + 1; $numDown = $random->nextBoundedInt(3) + 1;
for($y = $lastY + 1; $y > $lastY + 1 - $numDown; $y --) for ($y = $lastY + 1; $y > $lastY + 1 - $numDown; $y--)
$this->setLeave($level, $lX, $y, $z, $random); $this->setLeave($level, $lX, $y, $z, $random);
} }
} }
@ -630,15 +642,15 @@ class SakuraTree extends Tree {
break; break;
} }
// Leaves falling from the tree diagonaly // Leaves falling from the tree diagonally
foreach(self::DIAG_LEAVES [$trunkHeight] as $pos ) { foreach (self::DIAG_LEAVES [$trunkHeight] as $pos) {
$numDown = $random->nextBoundedInt(3 ) + 1; $numDown = $random->nextBoundedInt(3) + 1;
for($y = $lastY + 1; $y > $lastY - $numDown; $y --) for ($y = $lastY + 1; $y > $lastY - $numDown; $y--)
$this->setLeave($level, $lastX + $pos [0], $y, $lastZ + $pos [1], $random); $this->setLeave($level, $lastX + $pos [0], $y, $lastZ + $pos [1], $random);
} }
// Additional leaves // Additional leaves
foreach(self::ADDITIONAL_BLOCKS [$trunkHeight] as $pos ) { foreach (self::ADDITIONAL_BLOCKS [$trunkHeight] as $pos) {
$this->setLeave($level, $lastX + $pos [0], $lastY + 2, $lastZ + $pos [1], $random); $this->setLeave($level, $lastX + $pos [0], $lastY + 2, $lastZ + $pos [1], $random);
} }
} }
@ -668,7 +680,7 @@ class SakuraTree extends Tree {
$data = [ $data = [
$this->leafType, $this->leafType,
$this->leaf2Type $this->leaf2Type
] [( int ) $random->nextBoolean ()]; ] [( int )$random->nextBoolean()];
$level->setBlockIdAt($x, $y, $z, $this->realLeafBlock); $level->setBlockIdAt($x, $y, $z, $this->realLeafBlock);
$level->setBlockDataAt($x, $y, $z, $data); $level->setBlockDataAt($x, $y, $z, $data);
} }

View file

@ -7,7 +7,7 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @link https://github.com/Ad5001/BetterGen
*/ */
@ -16,9 +16,9 @@
namespace Ad5001\BetterGen\structure; namespace Ad5001\BetterGen\structure;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\utils\Random;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use pocketmine\level\generator\object\Object; use pocketmine\level\generator\object\Object;
use pocketmine\utils\Random;
class SugarCane extends Object { class SugarCane extends Object {
@ -30,6 +30,8 @@ class SugarCane extends Object {
* @param $z int * @param $z int
* @param $random pocketmine\utils\Random * @param $random pocketmine\utils\Random
*/ */
private $totalHeight;
public function canPlaceObject(ChunkManager $level, int $x, int $y, int $z, Random $random): bool { public function canPlaceObject(ChunkManager $level, int $x, int $y, int $z, Random $random): bool {
$this->totalHeight = 1 + $random->nextBoundedInt(3); $this->totalHeight = 1 + $random->nextBoundedInt(3);
$below = $level->getBlockIdAt($x, $y - 1, $z); $below = $level->getBlockIdAt($x, $y - 1, $z);

View file

@ -7,20 +7,19 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\structure; namespace Ad5001\BetterGen\structure;
use Ad5001\BetterGen\utils\BuildingUtils;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use pocketmine\utils\Random;
use pocketmine\math\Vector3;
use pocketmine\level\generator\object\Object; use pocketmine\level\generator\object\Object;
use Ad5001\BetterGen\loot\LootTable; use pocketmine\math\Vector3;
use Ad5001\BetterGen\utils\BuildingUtils; use pocketmine\utils\Random;
class Temple extends Object { class Temple extends Object {
const DIRECTION_PLUSX = 0; const DIRECTION_PLUSX = 0;
@ -45,43 +44,44 @@ class Temple extends Object {
2 2
], ],
[ [
- 3, -3,
0 0
], ],
[ [
- 2, -2,
1 1
], ],
[ [
- 1, -1,
2 2
], ],
[ [
0, 0,
- 3 -3
], ],
[ [
2, 2,
- 1 -1
], ],
[ [
1, 1,
- 2 -2
], ],
[ [
- 2, -2,
- 1 -1
], ],
[ [
- 1, -1,
- 2 -2
] ]
]; ];
public $overridable = [ public $overridable = [
Block::AIR => true, Block::AIR => true,
6 => true, Block::SAPLING => true,
17 => true, Block::LOG => true,
18 => true, Block::LEAVES => true,
Block::STONE => true,
Block::DANDELION => true, Block::DANDELION => true,
Block::POPPY => true, Block::POPPY => true,
Block::SNOW_LAYER => true, Block::SNOW_LAYER => true,
@ -96,17 +96,20 @@ class Temple extends Object {
], ],
[ [
1, 1,
- 1 -1
], ],
[ [
- 1, -1,
- 1 -1
], ],
[ [
- 1, -1,
1 1
] ]
]; ];
/** @var ChunkManager */
private $level;
private $direction = 0;
/* /*
* Checks if a temple is placeable * Checks if a temple is placeable
@ -117,12 +120,14 @@ class Temple extends Object {
* @param $random pocketmine\utils\Random * @param $random pocketmine\utils\Random
* @return bool * @return bool
*/ */
public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) { public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) {
$this->level = $level;
$this->direction = $random->nextBoundedInt(4); $this->direction = $random->nextBoundedInt(4);
for($xx = $x - 10; $xx <= $x + 10; $xx ++) for ($xx = $x - 10; $xx <= $x + 10; $xx++)
for($yy = $y + 1; $yy <= $y + 11; $yy ++) for ($yy = $y + 1; $yy <= $y + 11; $yy++)
for($zz = $z - 10; $zz <= $z + 10; $zz ++) for ($zz = $z - 10; $zz <= $z + 10; $zz++)
if (! isset($this->overridable [$level->getBlockIdAt($xx, $yy, $zz )] )) if (!isset($this->overridable [$level->getBlockIdAt($xx, $yy, $zz)]))
return false; return false;
return true; return true;
} }
@ -137,87 +142,94 @@ class Temple extends Object {
*/ */
public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) { public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) {
// Clearing space... // Clearing space...
BuildingUtils::fill($level, new Vector3($x + 10, $y + 1, $z + 10 ), new Vector3($x - 10, $y + 2, $z - 10 ), Block::get(Block::AIR )); BuildingUtils::fill($level, new Vector3($x + 10, $y + 1, $z + 10), new Vector3($x - 10, $y + 2, $z - 10), Block::get(Block::AIR));
// First, build a pyramid. // First, build a pyramid.
$this->level = $level; $this->level = $level;
$firstPos = new Vector3($x + 10, $y, $z + 10); $firstPos = new Vector3($x + 10, $y, $z + 10);
$sndPos = new Vector3($x - 10, $y, $z - 10); $sndPos = new Vector3($x - 10, $y, $z - 10);
for($i = 0; $i <= 9; $i ++) { for ($i = 0; $i <= 9; $i++) {
// Building sides // Building diagonal sides
BuildingUtils::walls($level, $firstPos, $sndPos, Block::get(Block::SANDSTONE )); BuildingUtils::walls($level, $firstPos->add(-$i, $i, -$i), $sndPos->add($i, $i, $i), Block::get(Block::SANDSTONE));
// Next floor
$firstPos->x --;
$firstPos->z --;
$firstPos->y = $y + $i;
$sndPos->x ++;
$sndPos->z ++;
$sndPos->y = $y + $i;
} }
// Floors
for($xx = $x + 9; $xx >= $x - 9; $xx --) // Floor top
for($zz = $z + 9; $zz >= $z - 9; $zz --) BuildingUtils::fill($level, new Vector3($x - 5, $y + 4, $z - 5), new Vector3($x + 5, $y + 4, $z + 5), Block::get(Block::SANDSTONE));
$this->placeBlock($xx, $y, $zz); #for ($xx = $x + 5; $xx >= $x - 5; $xx--)
for($xx = $x + 5; $xx >= $x - 5; $xx --) # for ($zz = $z + 5; $zz >= $z - 5; $zz--)
for($zz = $z + 5; $zz >= $z - 5; $zz --) # $this->placeBlock($xx, $y + 4, $zz);
$this->placeBlock($xx, $y + 4, $zz);
// Creating hole // Creating hole
for($xx = $x - 1; $xx <= $x + 1; $xx ++) BuildingUtils::fill($level, new Vector3($x - 1, $y - 11, $z - 1), new Vector3($x + 1, $y + 4, $z + 1), Block::get(Block::AIR));
for($yy = $y - 11; $yy <= $y + 4; $yy ++) #for ($xx = $x - 1; $xx <= $x + 1; $xx++)
for($zz = $z - 1; $zz <= $z + 1; $zz ++) # for ($yy = $y - 11; $yy <= $y + 4; $yy++)
$this->placeBlock($xx, $yy, $zz, 0); # for ($zz = $z - 1; $zz <= $z + 1; $zz++)
# $this->placeBlock($xx, $yy, $zz, Block::AIR);
// Floor patern // Hole walls
foreach($this->directions as $dir ) { BuildingUtils::walls($level, new Vector3($x - 2, $y - 1, $z - 2), new Vector3($x + 2, $y - 8, $z + 2), Block::get(Block::SANDSTONE));
// Building pillar
for($yy = $y + 1; $yy <= $y + 3; $yy ++) //Floor bottom
$this->placeBlock($x + ($dir [0] * 2), $yy, $z + ($dir [1] * 2), Block::SANDSTONE, 2); BuildingUtils::fill($level, new Vector3($x - 9, $y, $z - 9), new Vector3($x + 9, $y, $z + 9), Block::get(Block::SANDSTONE));
#for ($xx = $x + 9; $xx >= $x - 9; $xx--)
# for ($zz = $z + 9; $zz >= $z - 9; $zz--)
# $this->placeBlock($xx, $y, $zz);
// Floor pattern
for ($i = -2; $i <= 1; $i++) {//straight
$xextra = ($i + 1) % 2;
$zextra = ($i) % 2;
// Orange hardened clay // Orange hardened clay
$this->placeBlock($x + $dir [0], $y, $z + $dir [1], Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + ($xextra * 3), $y, $z + ($zextra * 3), Block::STAINED_HARDENED_CLAY, 1);//OUTER out
$this->placeBlock($x + ($dir [0] * 2), $y, $z, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + ($xextra * 2), $y, $z + ($zextra * 2), Block::STAINED_HARDENED_CLAY, 1);//OUTER in
$this->placeBlock($x + ($dir [0] * 3), $y, $z, Block::STAINED_HARDENED_CLAY, 1); }
$this->placeBlock($x, $y, $z + ($dir [1] * 2), Block::STAINED_HARDENED_CLAY, 1); foreach ($this->directions as $direction) {//Diagonals
$this->placeBlock($x, $y, $z + ($dir [1] * 3), Block::STAINED_HARDENED_CLAY, 1); // Building pillar
for ($yy = $y + 1; $yy <= $y + 3; $yy++)
// Sandstone $this->placeBlock($x + ($direction[0] * 2), $yy, $z + ($direction[1] * 2), Block::SANDSTONE, 2);
$this->placeBlock($x + $dir [0], $y, $z); $this->placeBlock($x + $direction[0], $y, $z + $direction[1], Block::STAINED_HARDENED_CLAY, 1);//Diagonal
$this->placeBlock($x, $y, $z + $dir [1]);
} }
// Blue hardened clay (center) // Blue hardened clay (center)
$this->placeBlock($x, $y, $z, Block::STAINED_HARDENED_CLAY, 11); $this->placeBlock($x, $y, $z, Block::STAINED_HARDENED_CLAY, 11);
// Hole walls // Floor pattern end
BuildingUtils::walls($level, new Vector3($x - 2, $y, $z - 2 ), new Vector3($x + 2, $y - 8, $z + 2 ), Block::get(Block::SANDSTONE ));
// Last step like this // Last step like this
for($xx = $x - 2; $xx <= $x + 2; $xx ++) { for ($xx = $x - 2; $xx <= $x + 2; $xx++) {
$this->placeBlock($xx, $y - 9, $z - 2, Block::SANDSTONE, 2); $this->placeBlock($xx, $y - 9, $z - 2, Block::SANDSTONE, 2);
$this->placeBlock($xx, $y - 9, $z + 2, Block::SANDSTONE, 2); $this->placeBlock($xx, $y - 9, $z + 2, Block::SANDSTONE, 2);
} }
for($zz = $z - 2; $zz <= $z + 2; $zz ++) { for ($zz = $z - 2; $zz <= $z + 2; $zz++) {
$this->placeBlock($x - 2, $y - 9, $zz, Block::SANDSTONE, 2); $this->placeBlock($x - 2, $y - 9, $zz, Block::SANDSTONE, 2);
$this->placeBlock($x + 2, $y - 9, $zz, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y - 9, $zz, Block::SANDSTONE, 2);
} }
foreach(self::THREE_DIAGS as $diagPos ) { foreach (self::THREE_DIAGS as $diagPos) {
$this->placeBlock($x + $diagPos [0], $y - 10, $z + $diagPos [1], Block::SANDSTONE, 1); $this->placeBlock($x + $diagPos [0], $y - 10, $z + $diagPos [1], Block::SANDSTONE, 1);
$this->placeBlock($x + $diagPos [0], $y - 11, $z + $diagPos [1], Block::SANDSTONE, 2); $this->placeBlock($x + $diagPos [0], $y - 11, $z + $diagPos [1], Block::SANDSTONE, 2);
} }
// Floor + TNT // Floor + TNT
for($xx = $x - 2; $xx <= $x + 2; $xx ++) for ($xx = $x - 2; $xx <= $x + 2; $xx++)
for($zz = $z - 2; $zz <= $z + 2; $zz ++) for ($zz = $z - 2; $zz <= $z + 2; $zz++)
$this->placeBlock($xx, $y - 12, $zz, Block::SANDSTONE, 2); $this->placeBlock($xx, $y - 12, $zz, Block::SANDSTONE, 2);
for($xx = $x - 1; $xx <= $x + 1; $xx ++) for ($xx = $x - 1; $xx <= $x + 1; $xx++)
for($zz = $z - 1; $zz <= $z + 1; $zz ++) for ($zz = $z - 1; $zz <= $z + 1; $zz++)
$this->placeBlock($xx, $y - 13, $zz, Block::TNT); $this->placeBlock($xx, $y - 13, $zz, Block::TNT);
$this->placeBlock($x, $y - 11, $z, Block::STONE_PRESSURE_PLATE); $this->placeBlock($x, $y - 11, $z, Block::STONE_PRESSURE_PLATE);
//TODO TILES
$this->placeBlock($x, $y - 11, $z + 2, Block::CHEST, 4);
$this->placeBlock($x, $y - 11, $z - 2, Block::CHEST, 2);
$this->placeBlock($x + 2, $y - 11, $z, Block::CHEST, 5);
$this->placeBlock($x - 2, $y - 11, $z, Block::CHEST, 3);
$this->placeBlock($x, $y - 10, $z + 2, Block::AIR);
$this->placeBlock($x, $y - 10, $z - 2, Block::AIR);
$this->placeBlock($x + 2, $y - 10, $z, Block::AIR);
$this->placeBlock($x - 2, $y - 10, $z, Block::AIR);
// Chests // Chests
LootTable::buildLootTable(new Vector3($x, $y - 11, $z + 2 ), LootTable::LOOT_DESERT_TEMPLE, $random); /*LootTable::buildLootTable(new Vector3($x, $y - 11, $z + 2), LootTable::LOOT_DESERT_TEMPLE, $random);//TODO: Improve using addon
LootTable::buildLootTable(new Vector3($x, $y - 11, $z - 2 ), LootTable::LOOT_DESERT_TEMPLE, $random); LootTable::buildLootTable(new Vector3($x, $y - 11, $z - 2), LootTable::LOOT_DESERT_TEMPLE, $random);
LootTable::buildLootTable(new Vector3($x + 2, $y - 11, $z ), LootTable::LOOT_DESERT_TEMPLE, $random); LootTable::buildLootTable(new Vector3($x + 2, $y - 11, $z), LootTable::LOOT_DESERT_TEMPLE, $random);
LootTable::buildLootTable(new Vector3($x - 2, $y - 11, $z ), LootTable::LOOT_DESERT_TEMPLE, $random); LootTable::buildLootTable(new Vector3($x - 2, $y - 11, $z), LootTable::LOOT_DESERT_TEMPLE, $random);*/
// Entrance is a rectangular parallelepiped // Entrance is a rectangular parallelepiped
switch ($this->direction) { switch ($this->direction) {
@ -226,15 +238,15 @@ class Temple extends Object {
$this->placeTower($x + 8, $y, $z + 8, self::DIRECTION_PLUSX, self::DIRECTION_PLUSZ); $this->placeTower($x + 8, $y, $z + 8, self::DIRECTION_PLUSX, self::DIRECTION_PLUSZ);
$this->placeTower($x + 8, $y, $z - 8, self::DIRECTION_PLUSX, self::DIRECTION_MINZ); $this->placeTower($x + 8, $y, $z - 8, self::DIRECTION_PLUSX, self::DIRECTION_MINZ);
// Creating rectangular parallelepiped of sandstone. // Creating rectangular parallelepiped of sandstone.
BuildingUtils::fill($level, new Vector3($x + 6, $y + 1, $z - 6 ), new Vector3($x + 9, $y + 4, $z + 6 ), Block::get(Block::SANDSTONE )); BuildingUtils::fill($level, new Vector3($x + 6, $y + 1, $z - 6), new Vector3($x + 9, $y + 4, $z + 6), Block::get(Block::SANDSTONE));
// Creating a path to the entrance // Creating a path to the entrance
BuildingUtils::fill($level, new Vector3($x + 6, $y + 1, $z - 1 ), new Vector3($x + 9, $y + 4, $z + 1 ), Block::get(Block::AIR )); BuildingUtils::fill($level, new Vector3($x + 6, $y + 1, $z - 1), new Vector3($x + 9, $y + 4, $z + 1), Block::get(Block::AIR));//this clears the entrance
// Creating path to towers. // Creating path to towers.
for($yy = $y + 1; $yy <= $y + 2; $yy ++) for ($yy = $y + 1; $yy <= $y + 2; $yy++)
for($zz = $z - 6; $zz <= $z + 6; $zz ++) for ($zz = $z - 6; $zz <= $z + 6; $zz++)
$this->placeBlock($x + 8, $yy, $zz, 0); $this->placeBlock($x + 8, $yy, $zz, 0);
// Door additional blocks // Door additional blocks
for($yy = $y + 1; $yy <= $y + 4; $yy ++) { for ($yy = $y + 1; $yy <= $y + 4; $yy++) {
$this->placeBlock($x + 6, $yy, $z - 2); $this->placeBlock($x + 6, $yy, $z - 2);
$this->placeBlock($x + 6, $yy, $z + 2); $this->placeBlock($x + 6, $yy, $z + 2);
// Polished entrance // Polished entrance
@ -246,17 +258,17 @@ class Temple extends Object {
} }
// Finishing entrance structure // Finishing entrance structure
$this->placeBlock($x + 9, $y + 3, $z, Block::SANDSTONE, 2); $this->placeBlock($x + 9, $y + 3, $z, Block::SANDSTONE, 2);
for($zz = $z - 2; $zz <= $z + 2; $zz ++) for ($zz = $z - 2; $zz <= $z + 2; $zz++)
$this->placeBlock($x + 10, $y + 4, $zz, Block::SANDSTONE, 2); $this->placeBlock($x + 10, $y + 4, $zz, Block::SANDSTONE, 2);
$this->placeBlock($x + 10, $y + 5, $z, Block::SANDSTONE, 1); $this->placeBlock($x + 10, $y + 5, $z, Block::SANDSTONE, 1);
$this->placeBlock($x + 10, $y + 5, $z - 1, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + 10, $y + 5, $z - 1, Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x + 10, $y + 5, $z + 1, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + 10, $y + 5, $z + 1, Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x + 10, $y + 5, $z - 2, Block::SANDSTONE, 2); $this->placeBlock($x + 10, $y + 5, $z - 2, Block::SANDSTONE, 2);
$this->placeBlock($x + 10, $y + 5, $z + 2, Block::SANDSTONE, 2); $this->placeBlock($x + 10, $y + 5, $z + 2, Block::SANDSTONE, 2);
for($zz = $z - 1; $zz <= $z + 1; $zz ++) for ($zz = $z - 1; $zz <= $z + 1; $zz++)
$this->placeBlock($x + 10, $y + 6, $zz, Block::SANDSTONE, 2); $this->placeBlock($x + 10, $y + 6, $zz, Block::SANDSTONE, 2);
for($xx = $x + 6; $xx <= $x + 9; $xx ++) for ($xx = $x + 6; $xx <= $x + 9; $xx++)
for($zz = $z - 2; $zz <= $z + 2; $zz ++) for ($zz = $z - 2; $zz <= $z + 2; $zz++)
$this->placeBlock($xx, $y + 4, $zz); $this->placeBlock($xx, $y + 4, $zz);
break; break;
@ -265,21 +277,21 @@ class Temple extends Object {
$this->placeTower($x - 8, $y, $z + 8, self::DIRECTION_MINX, self::DIRECTION_PLUSZ); $this->placeTower($x - 8, $y, $z + 8, self::DIRECTION_MINX, self::DIRECTION_PLUSZ);
$this->placeTower($x - 8, $y, $z - 8, self::DIRECTION_MINX, self::DIRECTION_MINZ); $this->placeTower($x - 8, $y, $z - 8, self::DIRECTION_MINX, self::DIRECTION_MINZ);
// Creating rectangular parallelepiped of sandstone. // Creating rectangular parallelepiped of sandstone.
for($xx = $x - 6; $xx >= $x - 9; $xx --) for ($xx = $x - 6; $xx >= $x - 9; $xx--)
for($yy = $y + 1; $yy <= $y + 4; $yy ++) for ($yy = $y + 1; $yy <= $y + 4; $yy++)
for($zz = $z - 6; $zz <= $z + 6; $zz ++) for ($zz = $z - 6; $zz <= $z + 6; $zz++)
$this->placeBlock($xx, $yy, $zz); $this->placeBlock($xx, $yy, $zz);
// Creating a path to the entrance // Creating a path to the entrance
for($xx = $x - 6; $xx >= $x - 9; $xx --) for ($xx = $x - 6; $xx >= $x - 9; $xx--)
for($yy = $y + 1; $yy <= $y + 4; $yy ++) for ($yy = $y + 1; $yy <= $y + 4; $yy++)
for($zz = $z - 1; $zz <= $z + 1; $zz ++) for ($zz = $z - 1; $zz <= $z + 1; $zz++)
$this->placeBlock($xx, $yy, $zz, 0); $this->placeBlock($xx, $yy, $zz, 0);
// Creating path to towers. // Creating path to towers.
for($yy = $y + 1; $yy <= $y + 2; $yy ++) for ($yy = $y + 1; $yy <= $y + 2; $yy++)
for($zz = $z - 6; $zz <= $z + 6; $zz ++) for ($zz = $z - 6; $zz <= $z + 6; $zz++)
$this->placeBlock($x - 8, $yy, $zz, 0); $this->placeBlock($x - 8, $yy, $zz, 0);
// Door additional blocks // Door additional blocks
for($yy = $y + 1; $yy <= $y + 4; $yy ++) { for ($yy = $y + 1; $yy <= $y + 4; $yy++) {
$this->placeBlock($x - 6, $yy, $z - 2); $this->placeBlock($x - 6, $yy, $z - 2);
$this->placeBlock($x - 6, $yy, $z + 2); $this->placeBlock($x - 6, $yy, $z + 2);
// Polished entrance // Polished entrance
@ -291,35 +303,36 @@ class Temple extends Object {
} }
// Finishing entrance structure // Finishing entrance structure
$this->placeBlock($x - 9, $y + 3, $z, Block::SANDSTONE, 2); $this->placeBlock($x - 9, $y + 3, $z, Block::SANDSTONE, 2);
for($zz = $z - 2; $zz <= $z + 2; $zz ++) for ($zz = $z - 2; $zz <= $z + 2; $zz++)
$this->placeBlock($x - 10, $y + 4, $zz, Block::SANDSTONE, 2); $this->placeBlock($x - 10, $y + 4, $zz, Block::SANDSTONE, 2);
$this->placeBlock($x - 10, $y + 5, $z, Block::SANDSTONE, 1); $this->placeBlock($x - 10, $y + 5, $z, Block::SANDSTONE, 1);
$this->placeBlock($x - 10, $y + 5, $z - 1, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 10, $y + 5, $z - 1, Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x - 10, $y + 5, $z + 1, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 10, $y + 5, $z + 1, Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x - 10, $y + 5, $z - 2, Block::SANDSTONE, 2); $this->placeBlock($x - 10, $y + 5, $z - 2, Block::SANDSTONE, 2);
$this->placeBlock($x - 10, $y + 5, $z + 2, Block::SANDSTONE, 2); $this->placeBlock($x - 10, $y + 5, $z + 2, Block::SANDSTONE, 2);
for($zz = $z - 1; $zz <= $z + 1; $zz ++) for ($zz = $z - 1; $zz <= $z + 1; $zz++)
$this->placeBlock($x - 10, $y + 6, $zz, Block::SANDSTONE, 2); $this->placeBlock($x - 10, $y + 6, $zz, Block::SANDSTONE, 2);
for($xx = $x - 6; $xx >= $x - 9; $xx --) for ($xx = $x - 6; $xx >= $x - 9; $xx--)
for($zz = $z - 2; $zz <= $z + 2; $zz ++) for ($zz = $z - 2; $zz <= $z + 2; $zz++)
$this->placeBlock($xx, $y + 4, $zz); $this->placeBlock($xx, $y + 4, $zz);
break; break;
case self::DIRECTION_PLUSZ : // z+ (2) case self::DIRECTION_PLUSZ : // z+ (2)
//TODO: Build pillars inside
// Building towers. // Building towers.
$this->placeTower($x + 8, $y, $z + 8, self::DIRECTION_PLUSZ, self::DIRECTION_PLUSX); $this->placeTower($x + 8, $y, $z + 8, self::DIRECTION_PLUSZ, self::DIRECTION_PLUSX);
$this->placeTower($x - 8, $y, $z + 8, self::DIRECTION_PLUSZ, self::DIRECTION_MINX); $this->placeTower($x - 8, $y, $z + 8, self::DIRECTION_PLUSZ, self::DIRECTION_MINX);
// Creating rectangular parallelepiped of sandstone. // Creating rectangular parallelepiped of sandstone.
BuildingUtils::fill($level, new Vector3($x - 6, $y + 1, $z + 6 ), new Vector3($x + 6, $y + 4, $z + 9 ), Block::get(Block::SANDSTONE )); BuildingUtils::fill($level, new Vector3($x - 6, $y + 1, $z + 6), new Vector3($x + 6, $y + 4, $z + 9), Block::get(Block::SANDSTONE));
// Creating a path to the entrance // Creating a path to the entrance
for($xx = $x - 1; $xx <= $x + 1; $xx ++) for ($xx = $x - 1; $xx <= $x + 1; $xx++)
for($yy = $y + 1; $yy <= $y + 4; $yy ++) for ($yy = $y + 1; $yy <= $y + 4; $yy++)
for($zz = $z + 6; $zz <= $z + 9; $zz ++) for ($zz = $z + 6; $zz <= $z + 9; $zz++)
$this->placeBlock($xx, $yy, $zz, 0); $this->placeBlock($xx, $yy, $zz, 0);
// Creating path to towers. // Creating path to towers.
BuildingUtils::fill($level, new Vector3($x - 1, $y + 1, $z + 6 ), new Vector3($x + 1, $y + 4, $z + 9 ), Block::get(Block::AIR )); BuildingUtils::fill($level, new Vector3($x - 1, $y + 1, $z + 6), new Vector3($x + 1, $y + 4, $z + 9), Block::get(Block::AIR));
// Door additional blocks // Door additional blocks
for($yy = $y + 1; $yy <= $y + 4; $yy ++) { for ($yy = $y + 1; $yy <= $y + 4; $yy++) {
$this->placeBlock($x - 2, $yy, $z + 6); $this->placeBlock($x - 2, $yy, $z + 6);
$this->placeBlock($x + 2, $yy, $z + 6); $this->placeBlock($x + 2, $yy, $z + 6);
// Polished entrance // Polished entrance
@ -331,17 +344,17 @@ class Temple extends Object {
} }
// Finishing entrance structure // Finishing entrance structure
$this->placeBlock($x, $y + 3, $z + 9, Block::SANDSTONE, 2); $this->placeBlock($x, $y + 3, $z + 9, Block::SANDSTONE, 2);
for($xx = $x - 2; $xx <= $x + 2; $xx ++) for ($xx = $x - 2; $xx <= $x + 2; $xx++)
$this->placeBlock($xx, $y + 4, $z + 10, Block::SANDSTONE, 2); $this->placeBlock($xx, $y + 4, $z + 10, Block::SANDSTONE, 2);
$this->placeBlock($x, $y + 5, $z + 10, Block::SANDSTONE, 1); $this->placeBlock($x, $y + 5, $z + 10, Block::SANDSTONE, 1);
$this->placeBlock($x - 1, $y + 5, $z + 10, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 1, $y + 5, $z + 10, Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x + 1, $y + 5, $z + 10, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + 1, $y + 5, $z + 10, Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x - 2, $y + 5, $z + 10, Block::SANDSTONE, 2); $this->placeBlock($x - 2, $y + 5, $z + 10, Block::SANDSTONE, 2);
$this->placeBlock($x + 2, $y + 5, $z + 10, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y + 5, $z + 10, Block::SANDSTONE, 2);
for($xx = $x - 1; $xx <= $x + 1; $xx ++) for ($xx = $x - 1; $xx <= $x + 1; $xx++)
$this->placeBlock($xx, $y + 6, $z + 10, Block::SANDSTONE, 2); $this->placeBlock($xx, $y + 6, $z + 10, Block::SANDSTONE, 2);
for($zz = $z + 6; $zz <= $z + 9; $zz ++) for ($zz = $z + 6; $zz <= $z + 9; $zz++)
for($xx = $x - 2; $xx <= $x + 2; $xx ++) for ($xx = $x - 2; $xx <= $x + 2; $xx++)
$this->placeBlock($xx, $y + 4, $zz); $this->placeBlock($xx, $y + 4, $zz);
break; break;
@ -350,15 +363,15 @@ class Temple extends Object {
$this->placeTower($x + 8, $y, $z - 8, self::DIRECTION_MINZ, self::DIRECTION_PLUSX); $this->placeTower($x + 8, $y, $z - 8, self::DIRECTION_MINZ, self::DIRECTION_PLUSX);
$this->placeTower($x - 8, $y, $z - 8, self::DIRECTION_MINZ, self::DIRECTION_MINX); $this->placeTower($x - 8, $y, $z - 8, self::DIRECTION_MINZ, self::DIRECTION_MINX);
// Creating rectangular parallelepiped of sandstone. // Creating rectangular parallelepiped of sandstone.
BuildingUtils::fill($level, new Vector3($x - 6, $y + 1, $z - 6 ), new Vector3($x + 6, $y + 4, $z - 9 ), Block::get(Block::SANDSTONE )); BuildingUtils::fill($level, new Vector3($x - 6, $y + 1, $z - 6), new Vector3($x + 6, $y + 4, $z - 9), Block::get(Block::SANDSTONE));
// Creating a path to the entrance // Creating a path to the entrance
BuildingUtils::fill($level, new Vector3($x - 1, $y + 1, $z - 6 ), new Vector3($x + 1, $y + 4, $z - 9 ), Block::get(Block::AIR )); BuildingUtils::fill($level, new Vector3($x - 1, $y + 1, $z - 6), new Vector3($x + 1, $y + 4, $z - 9), Block::get(Block::AIR));
// Creating path to towers. // Creating path to towers.
for($yy = $y + 1; $yy <= $y + 2; $yy ++) for ($yy = $y + 1; $yy <= $y + 2; $yy++)
for($xx = $x - 6; $xx <= $x + 6; $xx ++) for ($xx = $x - 6; $xx <= $x + 6; $xx++)
$this->placeBlock($xx, $yy, $z - 8, 0); $this->placeBlock($xx, $yy, $z - 8, 0);
// Door additional blocks // Door additional blocks
for($yy = $y + 1; $yy <= $y + 4; $yy ++) { for ($yy = $y + 1; $yy <= $y + 4; $yy++) {
$this->placeBlock($x - 2, $yy, $z - 6); $this->placeBlock($x - 2, $yy, $z - 6);
$this->placeBlock($x + 2, $yy, $z - 6); $this->placeBlock($x + 2, $yy, $z - 6);
// Polished entrance // Polished entrance
@ -370,49 +383,37 @@ class Temple extends Object {
} }
// Finishing entrance structure // Finishing entrance structure
$this->placeBlock($x, $y + 3, $z - 9, Block::SANDSTONE, 2); $this->placeBlock($x, $y + 3, $z - 9, Block::SANDSTONE, 2);
for($xx = $x - 2; $xx <= $x + 2; $xx ++) for ($xx = $x - 2; $xx <= $x + 2; $xx++)
$this->placeBlock($xx, $y + 4, $z - 10, Block::SANDSTONE, 2); $this->placeBlock($xx, $y + 4, $z - 10, Block::SANDSTONE, 2);
$this->placeBlock($x, $y + 5, $z - 10, Block::SANDSTONE, 1); $this->placeBlock($x, $y + 5, $z - 10, Block::SANDSTONE, 1);
$this->placeBlock($x - 1, $y + 5, $z - 10, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 1, $y + 5, $z - 10, Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x + 1, $y + 5, $z - 10, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + 1, $y + 5, $z - 10, Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x - 2, $y + 5, $z - 10, Block::SANDSTONE, 2); $this->placeBlock($x - 2, $y + 5, $z - 10, Block::SANDSTONE, 2);
$this->placeBlock($x + 2, $y + 5, $z - 10, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y + 5, $z - 10, Block::SANDSTONE, 2);
for($xx = $x - 1; $xx <= $x + 1; $xx ++) for ($xx = $x - 1; $xx <= $x + 1; $xx++)
$this->placeBlock($xx, $y + 6, $z - 10, Block::SANDSTONE, 2); $this->placeBlock($xx, $y + 6, $z - 10, Block::SANDSTONE, 2);
for($zz = $z - 6; $zz >= $z - 9; $zz --) for ($zz = $z - 6; $zz >= $z - 9; $zz--)
for($xx = $x - 2; $xx <= $x + 2; $xx ++) for ($xx = $x - 2; $xx <= $x + 2; $xx++)
$this->placeBlock($xx, $y + 4, $zz); $this->placeBlock($xx, $y + 4, $zz);
break; break;
} }
} }
/* /**
* Places a slab * Places a block
* @param $x int * @param $x int
* @param $y int * @param $y int
* @param $z int * @param $z int
* @return void * @param int $id
*/ * @param int $meta
protected function placeSlab($x, $y, $z) {
$this->level->setBlockIdAt($x, $y, $z, 44);
$this->level->setBlockDataAt($x, $y, $z, 1);
}
/*
* Places a slab
* @param $x int
* @param $y int
* @param $z int
* @param $id int
* @param $meta int
* @return void
*/ */
protected function placeBlock($x, $y, $z, $id = Block::SANDSTONE, $meta = 0) { protected function placeBlock($x, $y, $z, $id = Block::SANDSTONE, $meta = 0) {
$this->level->setBlockIdAt($x, $y, $z, $id); $this->level->setBlockIdAt($x, $y, $z, $id);
$this->level->setBlockDataAt($x, $y, $z, $meta); $this->level->setBlockDataAt($x, $y, $z, $meta);
} }
/*
/**
* 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 inversed $direction1, stairs come from inversed $direction2 to $direction2, patterns are on $direction1 and $direction2
* @param $x int * @param $x int
* @param $y int * @param $y int
@ -422,13 +423,15 @@ class Temple extends Object {
* @return void * @return void
*/ */
public function placeTower($x, $y, $z, $direction1 = self::DIRECTION_PLUSX, $direction2 = self::DIRECTION_PLUSZ) { public function placeTower($x, $y, $z, $direction1 = self::DIRECTION_PLUSX, $direction2 = self::DIRECTION_PLUSZ) {
BuildingUtils::walls($this->level, new Vector3($x + 2, $y, $z + 2 ), new Vector3($x - 2, $y + 8, $z - 2 ), Block::get(Block::SANDSTONE )); BuildingUtils::walls($this->level, new Vector3($x + 2, $y, $z + 2), new Vector3($x - 2, $y + 8, $z - 2), Block::get(Block::SANDSTONE));
//Clear insides
BuildingUtils::fill($this->level, new Vector3($x + 1, $y + 1, $z + 1), new Vector3($x - 1, $y + 7, $z - 1), Block::get(Block::AIR));
switch ($direction1) { switch ($direction1) {
case self::DIRECTION_PLUSX : // x+ (0) case self::DIRECTION_PLUSX : // x+ (0)
// Stairs // Stairs
switch ($direction2) { switch ($direction2) {
case self::DIRECTION_PLUSZ : case self::DIRECTION_PLUSZ :
for($zz = $z + 1; $zz >= $z; $zz --) { for ($zz = $z + 1; $zz >= $z; $zz--) {
$this->placeBlock($x - 1, $y + 1, $zz); $this->placeBlock($x - 1, $y + 1, $zz);
$this->placeBlock($x - 1, $y + 2, $zz); $this->placeBlock($x - 1, $y + 2, $zz);
} }
@ -436,19 +439,19 @@ class Temple extends Object {
$this->placeBlock($x, $y + 1, $z + 1); $this->placeBlock($x, $y + 1, $z + 1);
$this->placeSlab($x, $y + 2, $z + 1); $this->placeSlab($x, $y + 2, $z + 1);
// Pattern // Pattern
foreach([ foreach ([
1, 1,
2, 2,
4 4
] as $h ) { ] as $h) {
$this->placeBlock($x - 1, $y + $h, $z + 2, Block::SANDSTONE, 2); $this->placeBlock($x - 1, $y + $h, $z + 2, Block::SANDSTONE, 2);
$this->placeBlock($x + 1, $y + $h, $z + 2, Block::SANDSTONE, 2); $this->placeBlock($x + 1, $y + $h, $z + 2, Block::SANDSTONE, 2);
$this->placeBlock($x, $y + $h, $z + 2, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x, $y + $h, $z + 2, Block::STAINED_HARDENED_CLAY, 1);
} }
foreach([ foreach ([
3, 3,
5 5
] as $h ) { ] as $h) {
$this->placeBlock($x - 1, $y + $h, $z + 2, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 1, $y + $h, $z + 2, Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x + 1, $y + $h, $z + 2, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + 1, $y + $h, $z + 2, Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x, $y + $h, $z + 2, Block::SANDSTONE, 1); $this->placeBlock($x, $y + $h, $z + 2, Block::SANDSTONE, 1);
@ -460,12 +463,12 @@ class Temple extends Object {
$this->placeBlock($x, $y + 7, $z + 2, Block::SANDSTONE, 2); $this->placeBlock($x, $y + 7, $z + 2, Block::SANDSTONE, 2);
$this->placeBlock($x + 1, $y + 7, $z + 2, Block::SANDSTONE, 2); $this->placeBlock($x + 1, $y + 7, $z + 2, Block::SANDSTONE, 2);
// Building entrance to second floor. // Building entrance to second floor. //TODO
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 - 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 )); BuildingUtils::fill($this->level, new Vector3($x - 8, $y + 5, $z - 4), new Vector3($x - 8, $y + 6, $z - 5), Block::get(Block::AIR));
break; break;
case self::DIRECTION_MINZ : case self::DIRECTION_MINZ :
for($zz = $z - 1; $zz <= $z; $zz ++) { for ($zz = $z - 1; $zz <= $z; $zz++) {
$this->placeBlock($x - 1, $y + 1, $zz); $this->placeBlock($x - 1, $y + 1, $zz);
$this->placeBlock($x - 1, $y + 2, $zz); $this->placeBlock($x - 1, $y + 2, $zz);
} }
@ -473,19 +476,19 @@ class Temple extends Object {
$this->placeBlock($x, $y + 1, $z - 1); $this->placeBlock($x, $y + 1, $z - 1);
$this->placeSlab($x, $y + 2, $z - 1); $this->placeSlab($x, $y + 2, $z - 1);
// Pattern // Pattern
foreach([ foreach ([
1, 1,
2, 2,
4 4
] as $h ) { ] as $h) {
$this->placeBlock($x - 1, $y + $h, $z - 2, Block::SANDSTONE, 2); $this->placeBlock($x - 1, $y + $h, $z - 2, Block::SANDSTONE, 2);
$this->placeBlock($x + 1, $y + $h, $z - 2, Block::SANDSTONE, 2); $this->placeBlock($x + 1, $y + $h, $z - 2, Block::SANDSTONE, 2);
$this->placeBlock($x, $y + $h, $z - 2, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x, $y + $h, $z - 2, Block::STAINED_HARDENED_CLAY, 1);
} }
foreach([ foreach ([
3, 3,
5 5
] as $h ) { ] as $h) {
$this->placeBlock($x - 1, $y + $h, $z - 2, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 1, $y + $h, $z - 2, Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x + 1, $y + $h, $z - 2, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + 1, $y + $h, $z - 2, Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x, $y + $h, $z - 2, Block::SANDSTONE, 1); $this->placeBlock($x, $y + $h, $z - 2, Block::SANDSTONE, 1);
@ -497,12 +500,12 @@ class Temple extends Object {
$this->placeBlock($x, $y + 7, $z - 2, Block::SANDSTONE, 2); $this->placeBlock($x, $y + 7, $z - 2, Block::SANDSTONE, 2);
$this->placeBlock($x + 1, $y + 7, $z - 2, Block::SANDSTONE, 2); $this->placeBlock($x + 1, $y + 7, $z - 2, Block::SANDSTONE, 2);
break; 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. //TODO
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 // Finishing stairs system
$this->placeBlock($x - 2, $y + 3, $z, Block::SANDSTONE_STAIRS, 1); $this->placeBlock($x - 2, $y + 3, $z, Block::SANDSTONE_STAIRS, 1);
$this->placeBlock($x - 3, $y + 4, $z, Block::SANDSTONE_STAIRS, 1); $this->placeBlock($x - 3, $y + 4, $z, Block::SANDSTONE_STAIRS, 1);
@ -510,22 +513,22 @@ class Temple extends Object {
$this->placeBlock($x - 2, $y + 5, $z, Block::AIR); $this->placeBlock($x - 2, $y + 5, $z, Block::AIR);
$this->placeBlock($x - 2, $y + 6, $z, Block::AIR); $this->placeBlock($x - 2, $y + 6, $z, Block::AIR);
// Making path from stairs to first floor. // Making path from stairs to first floor.
BuildingUtils::fill($this->level, new Vector3($x - 4, $y, $z + 2 ), new Vector3($x - 9, $y + 4, $z - 2 ), Block::get(Block::SANDSTONE )); BuildingUtils::fill($this->level, new Vector3($x - 3, $y, $z + 1 + ($direction2 === self::DIRECTION_PLUSZ ? 2 : 0)), new Vector3($x - 8, $y + 4, $z - 1 + ($direction2 === self::DIRECTION_MINZ ? -2 : 0)), Block::get(Block::SANDSTONE));
// Other side pattern // Other side pattern
foreach([ foreach ([
1, 1,
2, 2,
4 4
] as $h ) { ] as $h) {
$this->placeBlock($x + 2, $y + $h, $z + 1, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y + $h, $z + 1, Block::SANDSTONE, 2);
$this->placeBlock($x + 2, $y + $h, $z - 1, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y + $h, $z - 1, Block::SANDSTONE, 2);
$this->placeBlock($x + 2, $y + $h, $z, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + 2, $y + $h, $z, Block::STAINED_HARDENED_CLAY, 1);
} }
foreach([ foreach ([
3, 3,
5 5
] as $h ) { ] as $h) {
$this->placeBlock($x + 2, $y + $h, $z - 1, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + 2, $y + $h, $z - 1, Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x + 2, $y + $h, $z + 1, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + 2, $y + $h, $z + 1, Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x + 2, $y + $h, $z, Block::SANDSTONE, 1); $this->placeBlock($x + 2, $y + $h, $z, Block::SANDSTONE, 1);
@ -542,7 +545,7 @@ class Temple extends Object {
// Stairs // Stairs
switch ($direction2) { switch ($direction2) {
case self::DIRECTION_PLUSZ : case self::DIRECTION_PLUSZ :
for($zz = $z + 1; $zz >= $z; $zz --) { for ($zz = $z + 1; $zz >= $z; $zz--) {
$this->placeBlock($x + 1, $y + 1, $zz); $this->placeBlock($x + 1, $y + 1, $zz);
$this->placeBlock($x + 1, $y + 2, $zz); $this->placeBlock($x + 1, $y + 2, $zz);
} }
@ -550,19 +553,19 @@ class Temple extends Object {
$this->placeBlock($x, $y + 1, $z + 1); $this->placeBlock($x, $y + 1, $z + 1);
$this->placeSlab($x, $y + 2, $z + 1); $this->placeSlab($x, $y + 2, $z + 1);
// Pattern // Pattern
foreach([ foreach ([
1, 1,
2, 2,
4 4
] as $h ) { ] as $h) {
$this->placeBlock($x + 1, $y + $h, $z + 2, Block::SANDSTONE, 2); $this->placeBlock($x + 1, $y + $h, $z + 2, Block::SANDSTONE, 2);
$this->placeBlock($x - 1, $y + $h, $z + 2, Block::SANDSTONE, 2); $this->placeBlock($x - 1, $y + $h, $z + 2, Block::SANDSTONE, 2);
$this->placeBlock($x, $y + $h, $z + 2, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x, $y + $h, $z + 2, Block::STAINED_HARDENED_CLAY, 1);
} }
foreach([ foreach ([
3, 3,
5 5
] as $h ) { ] as $h) {
$this->placeBlock($x + 1, $y + $h, $z + 2, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + 1, $y + $h, $z + 2, Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x - 1, $y + $h, $z + 2, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 1, $y + $h, $z + 2, Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x, $y + $h, $z + 2, Block::SANDSTONE, 1); $this->placeBlock($x, $y + $h, $z + 2, Block::SANDSTONE, 1);
@ -574,12 +577,12 @@ class Temple extends Object {
$this->placeBlock($x, $y + 7, $z + 2, Block::SANDSTONE, 2); $this->placeBlock($x, $y + 7, $z + 2, Block::SANDSTONE, 2);
$this->placeBlock($x + 1, $y + 7, $z + 2, Block::SANDSTONE, 2); $this->placeBlock($x + 1, $y + 7, $z + 2, Block::SANDSTONE, 2);
// Building entrance to second floor. // Building entrance to second floor. //TODO
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 + 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 )); BuildingUtils::fill($this->level, new Vector3($x + 8, $y + 5, $z - 4), new Vector3($x + 8, $y + 6, $z - 5), Block::get(Block::AIR));
break; break;
case self::DIRECTION_MINZ : case self::DIRECTION_MINZ :
for($zz = $z - 1; $zz <= $z; $zz ++) { for ($zz = $z - 1; $zz <= $z; $zz++) {
$this->placeBlock($x + 1, $y + 1, $zz); $this->placeBlock($x + 1, $y + 1, $zz);
$this->placeBlock($x + 1, $y + 2, $zz); $this->placeBlock($x + 1, $y + 2, $zz);
} }
@ -587,19 +590,19 @@ class Temple extends Object {
$this->placeBlock($x, $y + 1, $z - 1); $this->placeBlock($x, $y + 1, $z - 1);
$this->placeSlab($x, $y + 2, $z - 1); $this->placeSlab($x, $y + 2, $z - 1);
// Pattern // Pattern
foreach([ foreach ([
1, 1,
2, 2,
4 4
] as $h ) { ] as $h) {
$this->placeBlock($x + 1, $y + $h, $z - 2, Block::SANDSTONE, 2); $this->placeBlock($x + 1, $y + $h, $z - 2, Block::SANDSTONE, 2);
$this->placeBlock($x - 1, $y + $h, $z - 2, Block::SANDSTONE, 2); $this->placeBlock($x - 1, $y + $h, $z - 2, Block::SANDSTONE, 2);
$this->placeBlock($x, $y + $h, $z - 2, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x, $y + $h, $z - 2, Block::STAINED_HARDENED_CLAY, 1);
} }
foreach([ foreach ([
3, 3,
5 5
] as $h ) { ] as $h) {
$this->placeBlock($x + 1, $y + $h, $z - 2, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + 1, $y + $h, $z - 2, Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x - 1, $y + $h, $z - 2, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 1, $y + $h, $z - 2, Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x, $y + $h, $z - 2, Block::SANDSTONE, 1); $this->placeBlock($x, $y + $h, $z - 2, Block::SANDSTONE, 1);
@ -611,9 +614,9 @@ class Temple extends Object {
$this->placeBlock($x, $y + 6, $z - 2, Block::SANDSTONE, 2); $this->placeBlock($x, $y + 6, $z - 2, Block::SANDSTONE, 2);
$this->placeBlock($x + 1, $y + 6, $z - 2, Block::SANDSTONE, 2); $this->placeBlock($x + 1, $y + 6, $z - 2, Block::SANDSTONE, 2);
// Building entrance to second floor. // Building entrance to second floor. //TODO
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 + 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 )); BuildingUtils::fill($this->level, new Vector3($x + 8, $y + 5, $z + 4), new Vector3($x + 8, $y + 6, $z + 5), Block::get(Block::AIR));
break; break;
} }
@ -624,22 +627,22 @@ class Temple extends Object {
$this->placeBlock($x + 2, $y + 5, $z, Block::AIR); $this->placeBlock($x + 2, $y + 5, $z, Block::AIR);
$this->placeBlock($x + 2, $y + 6, $z, Block::AIR); $this->placeBlock($x + 2, $y + 6, $z, Block::AIR);
// Making path from stairs to first floor. // Making path from stairs to first floor.
BuildingUtils::fill($this->level, new Vector3($x + 4, $y, $z + 2 ), new Vector3($x + 9, $y + 4, $z - 2 ), Block::get(Block::SANDSTONE )); BuildingUtils::fill($this->level, new Vector3($x + 3, $y, $z + 1 + ($direction2 === self::DIRECTION_PLUSZ ? 2 : 0)), new Vector3($x + 8, $y + 4, $z - 1 + ($direction2 === self::DIRECTION_MINZ ? -2 : 0)), Block::get(Block::SANDSTONE));
// Other side pattern // Other side pattern
foreach([ foreach ([
1, 1,
2, 2,
4 4
] as $h ) { ] as $h) {
$this->placeBlock($x - 2, $y + $h, $z + 1, Block::SANDSTONE, 2); $this->placeBlock($x - 2, $y + $h, $z + 1, Block::SANDSTONE, 2);
$this->placeBlock($x - 2, $y + $h, $z - 1, Block::SANDSTONE, 2); $this->placeBlock($x - 2, $y + $h, $z - 1, Block::SANDSTONE, 2);
$this->placeBlock($x - 2, $y + $h, $z, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 2, $y + $h, $z, Block::STAINED_HARDENED_CLAY, 1);
} }
foreach([ foreach ([
3, 3,
5 5
] as $h ) { ] as $h) {
$this->placeBlock($x - 2, $y + $h, $z - 1, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 2, $y + $h, $z - 1, Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x - 2, $y + $h, $z + 1, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 2, $y + $h, $z + 1, Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x - 2, $y + $h, $z, Block::SANDSTONE, 1); $this->placeBlock($x - 2, $y + $h, $z, Block::SANDSTONE, 1);
@ -656,7 +659,7 @@ class Temple extends Object {
// Stairs // Stairs
switch ($direction2) { switch ($direction2) {
case self::DIRECTION_PLUSX : case self::DIRECTION_PLUSX :
for($xx = $x + 1; $xx >= $x; $xx --) { for ($xx = $x + 1; $xx >= $x; $xx--) {
$this->placeBlock($xx, $y + 1, $z - 1); $this->placeBlock($xx, $y + 1, $z - 1);
$this->placeBlock($xx, $y + 2, $z - 1); $this->placeBlock($xx, $y + 2, $z - 1);
} }
@ -664,19 +667,19 @@ class Temple extends Object {
$this->placeBlock($x + 1, $y + 1, $z); $this->placeBlock($x + 1, $y + 1, $z);
$this->placeSlab($x + 1, $y + 2, $z); $this->placeSlab($x + 1, $y + 2, $z);
// Pattern // Pattern
foreach([ foreach ([
1, 1,
2, 2,
4 4
] as $h ) { ] as $h) {
$this->placeBlock($x + 2, $y + $h, $z + 1, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y + $h, $z + 1, Block::SANDSTONE, 2);
$this->placeBlock($x + 2, $y + $h, $z - 1, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y + $h, $z - 1, Block::SANDSTONE, 2);
$this->placeBlock($x + 2, $y + $h, $z, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + 2, $y + $h, $z, Block::STAINED_HARDENED_CLAY, 1);
} }
foreach([ foreach ([
3, 3,
5 5
] as $h ) { ] as $h) {
$this->placeBlock($x + 2, $y + $h, $z + 1, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + 2, $y + $h, $z + 1, Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x + 2, $y + $h, $z - 1, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + 2, $y + $h, $z - 1, Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x + 2, $y + $h, $z, Block::SANDSTONE, 1); $this->placeBlock($x + 2, $y + $h, $z, Block::SANDSTONE, 1);
@ -687,12 +690,12 @@ class Temple extends Object {
$this->placeBlock($x + 2, $y + 7, $z - 1, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y + 7, $z - 1, Block::SANDSTONE, 2);
$this->placeBlock($x + 2, $y + 7, $z, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y + 7, $z, Block::SANDSTONE, 2);
$this->placeBlock($x + 2, $y + 7, $z + 1, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y + 7, $z + 1, Block::SANDSTONE, 2);
// Building entrance to second floor. // Building entrance to second floor. //TODO
BuildingUtils::fill($this->level, new Vector3($x - 4, $y + 5, $z - 9 ), new Vector3($x - 5, $y + 7, $z - 7 ), Block::get(Block::SANDSTONE, 2 )); BuildingUtils::fill($this->level, new Vector3($x - 4, $y + 5, $z - 9), new Vector3($x - 5, $y + 7, $z - 7), Block::get(Block::SANDSTONE, 2));
BuildingUtils::fill($this->level, new Vector3($x - 4, $y + 5, $z - 8 ), new Vector3($x - 5, $y + 6, $z - 8 ), Block::get(Block::AIR )); BuildingUtils::fill($this->level, new Vector3($x - 4, $y + 5, $z - 8), new Vector3($x - 5, $y + 6, $z - 8), Block::get(Block::AIR));
break; break;
case self::DIRECTION_MINX : case self::DIRECTION_MINX :
for($xx = $x - 1; $xx <= $x; $xx ++) { for ($xx = $x - 1; $xx <= $x; $xx++) {
$this->placeBlock($xx, $y + 1, $z - 1); $this->placeBlock($xx, $y + 1, $z - 1);
$this->placeBlock($xx, $y + 2, $z - 1); $this->placeBlock($xx, $y + 2, $z - 1);
} }
@ -700,19 +703,19 @@ class Temple extends Object {
$this->placeBlock($x - 1, $y + 1, $z); $this->placeBlock($x - 1, $y + 1, $z);
$this->placeSlab($x - 1, $y + 2, $z); $this->placeSlab($x - 1, $y + 2, $z);
// Pattern // Pattern
foreach([ foreach ([
1, 1,
2, 2,
4 4
] as $h ) { ] as $h) {
$this->placeBlock($x - 2, $y + $h, $z - 1, Block::SANDSTONE, 2); $this->placeBlock($x - 2, $y + $h, $z - 1, Block::SANDSTONE, 2);
$this->placeBlock($x - 2, $y + $h, $z + 1, Block::SANDSTONE, 2); $this->placeBlock($x - 2, $y + $h, $z + 1, Block::SANDSTONE, 2);
$this->placeBlock($x - 2, $y + $h, $z, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 2, $y + $h, $z, Block::STAINED_HARDENED_CLAY, 1);
} }
foreach([ foreach ([
3, 3,
5 5
] as $h ) { ] as $h) {
$this->placeBlock($x - 2, $y + $h, $z - 1, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 2, $y + $h, $z - 1, Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x - 2, $y + $h, $z + 1, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 2, $y + $h, $z + 1, Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x - 2, $y + $h, $z, Block::SANDSTONE, 1); $this->placeBlock($x - 2, $y + $h, $z, Block::SANDSTONE, 1);
@ -723,9 +726,9 @@ class Temple extends Object {
$this->placeBlock($x - 2, $y + 7, $z - 1, Block::SANDSTONE, 2); $this->placeBlock($x - 2, $y + 7, $z - 1, Block::SANDSTONE, 2);
$this->placeBlock($x - 2, $y + 7, $z, Block::SANDSTONE, 2); $this->placeBlock($x - 2, $y + 7, $z, Block::SANDSTONE, 2);
$this->placeBlock($x - 2, $y + 7, $z + 1, Block::SANDSTONE, 2); $this->placeBlock($x - 2, $y + 7, $z + 1, Block::SANDSTONE, 2);
// Building entrance to second floor. // Building entrance to second floor. //TODO
BuildingUtils::fill($this->level, new Vector3($x + 4, $y + 5, $z - 9 ), new Vector3($x + 5, $y + 7, $z - 7 ), Block::get(Block::SANDSTONE, 2 )); BuildingUtils::fill($this->level, new Vector3($x + 4, $y + 5, $z - 9), new Vector3($x + 5, $y + 7, $z - 7), Block::get(Block::SANDSTONE, 2));
BuildingUtils::fill($this->level, new Vector3($x + 4, $y + 5, $z - 8 ), new Vector3($x + 5, $y + 6, $z - 8 ), Block::get(Block::AIR )); BuildingUtils::fill($this->level, new Vector3($x + 4, $y + 5, $z - 8), new Vector3($x + 5, $y + 6, $z - 8), Block::get(Block::AIR));
break; break;
} }
@ -736,22 +739,22 @@ class Temple extends Object {
$this->placeBlock($x, $y + 5, $z - 2, Block::AIR); $this->placeBlock($x, $y + 5, $z - 2, Block::AIR);
$this->placeBlock($x, $y + 6, $z - 2, Block::AIR); $this->placeBlock($x, $y + 6, $z - 2, Block::AIR);
// Making path from stairs to first floor. // Making path from stairs to first floor.
BuildingUtils::fill($this->level, new Vector3($x + 2, $y, $z - 4 ), new Vector3($x - 2, $y + 4, $z - 9 ), Block::get(Block::SANDSTONE )); BuildingUtils::fill($this->level, new Vector3($x + 1 + ($direction2 === self::DIRECTION_PLUSX ? 2 : 0), $y, $z - 3), new Vector3($x - 1 + ($direction2 === self::DIRECTION_MINX ? -2 : 0), $y + 4, $z - 8), Block::get(Block::SANDSTONE));
// Other side pattern // Other side pattern
foreach([ foreach ([
1, 1,
2, 2,
4 4
] as $h ) { ] as $h) {
$this->placeBlock($x + 1, $y + $h, $z + 2, Block::SANDSTONE, 2); $this->placeBlock($x + 1, $y + $h, $z + 2, Block::SANDSTONE, 2);
$this->placeBlock($x - 1, $y + $h, $z + 2, Block::SANDSTONE, 2); $this->placeBlock($x - 1, $y + $h, $z + 2, Block::SANDSTONE, 2);
$this->placeBlock($x, $y + $h, $z + 2, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x, $y + $h, $z + 2, Block::STAINED_HARDENED_CLAY, 1);
} }
foreach([ foreach ([
3, 3,
5 5
] as $h ) { ] as $h) {
$this->placeBlock($x + 1, $y + $h, $z + 2, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + 1, $y + $h, $z + 2, Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x - 1, $y + $h, $z + 2, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 1, $y + $h, $z + 2, Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x, $y + $h, $z + 2, Block::SANDSTONE, 1); $this->placeBlock($x, $y + $h, $z + 2, Block::SANDSTONE, 1);
@ -768,7 +771,7 @@ class Temple extends Object {
// Stairs // Stairs
switch ($direction2) { switch ($direction2) {
case self::DIRECTION_PLUSX : case self::DIRECTION_PLUSX :
for($xx = $x + 1; $xx >= $x; $xx --) { for ($xx = $x + 1; $xx >= $x; $xx--) {
$this->placeBlock($xx, $y + 1, $z + 1); $this->placeBlock($xx, $y + 1, $z + 1);
$this->placeBlock($xx, $y + 2, $z + 1); $this->placeBlock($xx, $y + 2, $z + 1);
} }
@ -776,19 +779,19 @@ class Temple extends Object {
$this->placeBlock($x + 1, $y + 1, $z); $this->placeBlock($x + 1, $y + 1, $z);
$this->placeSlab($x + 1, $y + 2, $z); $this->placeSlab($x + 1, $y + 2, $z);
// Pattern // Pattern
foreach([ foreach ([
1, 1,
2, 2,
4 4
] as $h ) { ] as $h) {
$this->placeBlock($x + 2, $y + $h, $z + 1, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y + $h, $z + 1, Block::SANDSTONE, 2);
$this->placeBlock($x + 2, $y + $h, $z - 1, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y + $h, $z - 1, Block::SANDSTONE, 2);
$this->placeBlock($x + 2, $y + $h, $z, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + 2, $y + $h, $z, Block::STAINED_HARDENED_CLAY, 1);
} }
foreach([ foreach ([
3, 3,
5 5
] as $h ) { ] as $h) {
$this->placeBlock($x + 2, $y + $h, $z + 1, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + 2, $y + $h, $z + 1, Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x + 2, $y + $h, $z - 1, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + 2, $y + $h, $z - 1, Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x + 2, $y + $h, $z, Block::SANDSTONE, 1); $this->placeBlock($x + 2, $y + $h, $z, Block::SANDSTONE, 1);
@ -799,12 +802,12 @@ class Temple extends Object {
$this->placeBlock($x + 2, $y + 7, $z - 1, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y + 7, $z - 1, Block::SANDSTONE, 2);
$this->placeBlock($x + 2, $y + 7, $z, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y + 7, $z, Block::SANDSTONE, 2);
$this->placeBlock($x + 2, $y + 7, $z + 1, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y + 7, $z + 1, Block::SANDSTONE, 2);
// Building entrance to second floor. // Building entrance to second floor. //TODO
BuildingUtils::fill($this->level, new Vector3($x - 4, $y + 5, $z + 9 ), new Vector3($x - 5, $y + 7, $z + 7 ), Block::get(Block::SANDSTONE, 2 )); BuildingUtils::fill($this->level, new Vector3($x - 4, $y + 5, $z + 9), new Vector3($x - 5, $y + 7, $z + 7), Block::get(Block::SANDSTONE, 2));
BuildingUtils::fill($this->level, new Vector3($x - 4, $y + 5, $z + 8 ), new Vector3($x - 5, $y + 6, $z + 8 ), Block::get(Block::AIR )); BuildingUtils::fill($this->level, new Vector3($x - 4, $y + 5, $z + 8), new Vector3($x - 5, $y + 6, $z + 8), Block::get(Block::AIR));
break; break;
case self::DIRECTION_MINX : case self::DIRECTION_MINX :
for($xx = $x - 1; $xx <= $x; $xx ++) { for ($xx = $x - 1; $xx <= $x; $xx++) {
$this->placeBlock($xx, $y + 1, $z + 1); $this->placeBlock($xx, $y + 1, $z + 1);
$this->placeBlock($xx, $y + 2, $z + 1); $this->placeBlock($xx, $y + 2, $z + 1);
} }
@ -812,19 +815,19 @@ class Temple extends Object {
$this->placeBlock($x - 1, $y + 1, $z); $this->placeBlock($x - 1, $y + 1, $z);
$this->placeSlab($x - 1, $y + 2, $z); $this->placeSlab($x - 1, $y + 2, $z);
// Pattern // Pattern
foreach([ foreach ([
1, 1,
2, 2,
4 4
] as $h ) { ] as $h) {
$this->placeBlock($x - 2, $y + $h, $z - 1, Block::SANDSTONE, 2); $this->placeBlock($x - 2, $y + $h, $z - 1, Block::SANDSTONE, 2);
$this->placeBlock($x - 2, $y + $h, $z + 1, Block::SANDSTONE, 2); $this->placeBlock($x - 2, $y + $h, $z + 1, Block::SANDSTONE, 2);
$this->placeBlock($x - 2, $y + $h, $z, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 2, $y + $h, $z, Block::STAINED_HARDENED_CLAY, 1);
} }
foreach([ foreach ([
3, 3,
5 5
] as $h ) { ] as $h) {
$this->placeBlock($x - 2, $y + $h, $z - 1, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 2, $y + $h, $z - 1, Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x - 2, $y + $h, $z + 1, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 2, $y + $h, $z + 1, Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x - 2, $y + $h, $z, Block::SANDSTONE, 1); $this->placeBlock($x - 2, $y + $h, $z, Block::SANDSTONE, 1);
@ -835,9 +838,9 @@ class Temple extends Object {
$this->placeBlock($x - 2, $y + 7, $z - 1, Block::SANDSTONE, 2); $this->placeBlock($x - 2, $y + 7, $z - 1, Block::SANDSTONE, 2);
$this->placeBlock($x - 2, $y + 7, $z, Block::SANDSTONE, 2); $this->placeBlock($x - 2, $y + 7, $z, Block::SANDSTONE, 2);
$this->placeBlock($x - 2, $y + 7, $z + 1, Block::SANDSTONE, 2); $this->placeBlock($x - 2, $y + 7, $z + 1, Block::SANDSTONE, 2);
// Building entrance to second floor. // Building entrance to second floor. //TODO
BuildingUtils::fill($this->level, new Vector3($x + 4, $y + 5, $z + 9 ), new Vector3($x + 5, $y + 7, $z + 7 ), Block::get(Block::SANDSTONE, 2 )); BuildingUtils::fill($this->level, new Vector3($x + 4, $y + 5, $z + 9), new Vector3($x + 5, $y + 7, $z + 7), Block::get(Block::SANDSTONE, 2));
BuildingUtils::fill($this->level, new Vector3($x + 4, $y + 5, $z + 8 ), new Vector3($x + 5, $y + 6, $z + 8 ), Block::get(Block::AIR )); BuildingUtils::fill($this->level, new Vector3($x + 4, $y + 5, $z + 8), new Vector3($x + 5, $y + 6, $z + 8), Block::get(Block::AIR));
break; break;
} }
@ -848,22 +851,22 @@ class Temple extends Object {
$this->placeBlock($x, $y + 5, $z + 2, Block::AIR); $this->placeBlock($x, $y + 5, $z + 2, Block::AIR);
$this->placeBlock($x, $y + 6, $z + 2, Block::AIR); $this->placeBlock($x, $y + 6, $z + 2, Block::AIR);
// Making path from stairs to first floor. // Making path from stairs to first floor.
BuildingUtils::fill($this->level, new Vector3($x + 2, $y, $z + 4 ), new Vector3($x - 2, $y + 4, $z + 9 ), Block::get(Block::SANDSTONE )); BuildingUtils::fill($this->level, new Vector3($x + 1 + ($direction2 === self::DIRECTION_PLUSX ? 2 : 0), $y, $z + 3), new Vector3($x - 1 + ($direction2 === self::DIRECTION_MINX ? -2 : 0), $y + 4, $z + 8), Block::get(Block::SANDSTONE));
// Other side pattern // Other side pattern
foreach([ foreach ([
1, 1,
2, 2,
4 4
] as $h ) { ] as $h) {
$this->placeBlock($x + 1, $y + $h, $z - 2, Block::SANDSTONE, 2); $this->placeBlock($x + 1, $y + $h, $z - 2, Block::SANDSTONE, 2);
$this->placeBlock($x - 1, $y + $h, $z - 2, Block::SANDSTONE, 2); $this->placeBlock($x - 1, $y + $h, $z - 2, Block::SANDSTONE, 2);
$this->placeBlock($x, $y + $h, $z - 2, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x, $y + $h, $z - 2, Block::STAINED_HARDENED_CLAY, 1);
} }
foreach([ foreach ([
3, 3,
5 5
] as $h ) { ] as $h) {
$this->placeBlock($x + 1, $y + $h, $z - 2, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + 1, $y + $h, $z - 2, Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x - 1, $y + $h, $z - 2, Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x - 1, $y + $h, $z - 2, Block::STAINED_HARDENED_CLAY, 1);
$this->placeBlock($x, $y + $h, $z - 2, Block::SANDSTONE, 1); $this->placeBlock($x, $y + $h, $z - 2, Block::SANDSTONE, 1);
@ -878,19 +881,34 @@ class Temple extends Object {
} }
// Making top // Making top
BuildingUtils::top($this->level, new Vector3($x - 1, $y + 9, $z - 1 ), new Vector3($x + 1, $y, $z + 1 ), Block::get(Block::SANDSTONE )); BuildingUtils::top($this->level, new Vector3($x - 1, $y + 9, $z - 1), new Vector3($x + 1, $y, $z + 1), Block::get(Block::SANDSTONE));
$this->placeBlock($x - 2, $y + 9, $z, Block::SANDSTONE_STAIRS, 0); $this->placeBlock($x - 2, $y + 9, $z, Block::SANDSTONE_STAIRS, 0);
$this->placeBlock($x + 2, $y + 9, $z, Block::SANDSTONE_STAIRS, 1); $this->placeBlock($x + 2, $y + 9, $z, Block::SANDSTONE_STAIRS, 1);
$this->placeBlock($x, $y + 9, $z - 2, Block::SANDSTONE_STAIRS, 2); $this->placeBlock($x, $y + 9, $z - 2, Block::SANDSTONE_STAIRS, 2);
$this->placeBlock($x, $y + 9, $z + 2, Block::SANDSTONE_STAIRS, 3); $this->placeBlock($x, $y + 9, $z + 2, Block::SANDSTONE_STAIRS, 3);
} }
/*
* Inverses a direction /**
* Places a slab
* @param $x int
* @param $y int
* @param $z int
* @param $id int
* @param $meta int
* @return void
*/
protected function placeSlab($x, $y, $z, $id = 44, $meta = 1, $top = false) {
if ($top) $meta &= 0x08;
$this->placeBlock($x, $y, $z, $id, $meta);
}
/**
* Inverts a direction
* @param $direction int * @param $direction int
* @return int * @return int
*/ */
protected function getInversedDirection(int $direction): int { protected function getInvertedDirection(int $direction): int {
switch ($direction) { switch ($direction) {
case self::DIRECTION_PLUSX : // x+ (0) case self::DIRECTION_PLUSX : // x+ (0)
return self::DIRECTION_MINX; return self::DIRECTION_MINX;
@ -905,7 +923,7 @@ class Temple extends Object {
return self::DIRECTION_PLUSZ; return self::DIRECTION_PLUSZ;
break; break;
default : default :
return - 1; return -1;
break; break;
} }
} }

View file

@ -7,7 +7,7 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @link https://github.com/Ad5001/BetterGen
*/ */
@ -17,11 +17,13 @@ namespace Ad5001\BetterGen\structure;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use pocketmine\utils\Random;
use pocketmine\level\generator\object\Object; use pocketmine\level\generator\object\Object;
use pocketmine\utils\Random;
class Well extends Object { class Well extends Object {
/** @var ChunkManager */
private $level;
public $overridable = [ public $overridable = [
Block::AIR => true, Block::AIR => true,
6 => true, 6 => true,
@ -55,14 +57,15 @@ class Well extends Object {
/* /*
* Checks if a well is placeable * Checks if a well is placeable
* @param $level pocketmine\level\ChunkManager * @param $level ChunkManager
* @param $x int * @param $x int
* @param $y int * @param $y int
* @param $z int * @param $z int
* @param $random pocketmine\utils\Random * @param $random Random
* @return bool * @return bool
*/ */
public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) { public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) {
$this->level = $level;
for($xx = $x - 2; $xx <= $x + 2; $xx ++) for($xx = $x - 2; $xx <= $x + 2; $xx ++)
for($yy = $y; $yy <= $y + 3; $yy ++) for($yy = $y; $yy <= $y + 3; $yy ++)
for($zz = $z - 2; $zz <= $z + 2; $zz ++) for($zz = $z - 2; $zz <= $z + 2; $zz ++)
@ -73,16 +76,16 @@ class Well extends Object {
/* /*
* Places a well * Places a well
* @param $level pocketmine\level\ChunkManager * @param $level ChunkManager
* @param $x int * @param $x int
* @param $y int * @param $y int
* @param $z int * @param $z int
* @param $random pocketmine\utils\Random * @param $random Random
*/ */
public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) { public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) {
$this->level = $level; $this->level = $level;
foreach($this->directions as $direction ) { foreach($this->directions as $direction ) {
// Building pillard // Building pillars
for($yy = $y; $yy < $y + 3; $yy ++) for($yy = $y; $yy < $y + 3; $yy ++)
$this->placeBlock($x + $direction [0], $yy, $z + $direction [1], Block::SANDSTONE); $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); $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. // Building slabs on the sides. Places two times due to all directions.
$this->placeSlab($x + ($direction [0] * 2), $y, $z); $this->placeBlock($x + ($direction [0] * 2), $y, $z, Block::SANDSTONE, 1);
$this->placeSlab($x, $y, $z + ($direction [1] * 2)); $this->placeBlock($x, $y, $z + ($direction [1] * 2), Block::SANDSTONE, 1);
// Placing water.Places two times due to all directions. // Placing water.Places two times due to all directions.
$this->placeBlock($x + $direction [0], $y, $z, Block::WATER); $this->placeBlock($x + $direction [0], $y, $z, Block::WATER);
$this->placeBlock($x, $y, $z + $direction [1], Block::WATER); $this->placeBlock($x, $y, $z + $direction [1], Block::WATER);
} }
// Finitions // Final things
for($xx = $x - 1; $xx <= $x + 1; $xx ++) for($xx = $x - 1; $xx <= $x + 1; $xx ++)
for($zz = $z - 1; $zz <= $z + 1; $zz ++) for($zz = $z - 1; $zz <= $z + 1; $zz ++)
$this->placeSlab($xx, $y + 3, $zz); $this->placeBlock($xx, $y + 3, $zz);
$this->placeSlab($x, $y + 3, $z, Block::SANDSTONE); $this->placeBlock($x, $y + 3, $z, Block::SANDSTONE, 1);
$this->placeSlab($x, $y, $z, Block::WATER); $this->placeBlock($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);
} }
/* /*
@ -128,7 +119,8 @@ class Well extends Object {
* @param $id int * @param $id int
* @return void * @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->setBlockIdAt($x, $y, $z, $id);
$this->level->setBlockDataAt($x, $y, $z, $meta);
} }
} }

View file

@ -7,16 +7,16 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\utils; namespace Ad5001\BetterGen\utils;
use pocketmine\math\Vector3;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\level\ChunkManager; use pocketmine\level\ChunkManager;
use pocketmine\math\Vector3;
use pocketmine\utils\Random; use pocketmine\utils\Random;
class BuildingUtils { class BuildingUtils {

View file

@ -7,17 +7,17 @@
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \ * \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\ * \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/ * \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator. * Tomorrow's pocketmine generator.
* @author Ad5001 * @author Ad5001
* @link https://github.com/Ad5001/BetterGen * @link https://github.com/Ad5001/BetterGen
*/ */
namespace Ad5001\BetterGen\utils; 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 { 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 * src: http://php.net/manual/en/function.in-array.php#89256
* @param mixed $needle * @param mixed $needle
* @param array $haystack * @param array $haystack