From 7ce51d546a1bbd3cf6391c066405976f55ebbed2 Mon Sep 17 00:00:00 2001 From: thebigsmileXD Date: Fri, 12 May 2017 09:01:46 +0200 Subject: [PATCH] Reformatting, Fix #2, temple debug command --- plugin.yml | 6 + src/Ad5001/BetterGen/Main.php | 205 ++--- src/Ad5001/BetterGen/structure/SakuraTree.php | 4 +- src/Ad5001/BetterGen/structure/Temple.php | 719 +++++++++--------- 4 files changed, 484 insertions(+), 450 deletions(-) diff --git a/plugin.yml b/plugin.yml index 8c90a65..5c857ff 100644 --- a/plugin.yml +++ b/plugin.yml @@ -23,9 +23,15 @@ commands: description: Teleports you to an another world usage: "/worldtp " permission: bettergen.cmd.worldtp + temple: + description: Spawns a temple for debugging + usage: "/temple" + permission: bettergen.cmd.debug permissions: bettergen.cmd.createworld: default: op bettergen.cmd.worldtp: default: op + bettergen.cmd.debug: + default: op ... \ No newline at end of file diff --git a/src/Ad5001/BetterGen/Main.php b/src/Ad5001/BetterGen/Main.php index ed72ce9..2dce547 100644 --- a/src/Ad5001/BetterGen/Main.php +++ b/src/Ad5001/BetterGen/Main.php @@ -1,10 +1,10 @@ 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", "{}"); + + public static function registerBiome(int $id, Biome $biome) { + BetterNormal::registerBiome($biome); } - + /* * 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", "{}"); } - + /* * Called when one of the defined commands of the plugin has been called * @param $sender \pocketmine\command\CommandSender @@ -65,10 +72,37 @@ class Main extends PluginBase implements Listener { * @param $args array * return bool */ + + public static function isOtherNS() { + try { + return @class_exists("pocketmine\\level\\generator\\normal\\object\\OakTree"); + } catch (\Exception $e) { + return false; + } + } + + /* + * Registers a forest type. + * @param $name string + * @param $treeClass string + * @params $infos Array(temperature, rainfall) + * @return bool + */ + + public function onDisable() { + } + + /* + * Registers a biome for the normal generator. Normal means(Biome::register) doesn't allow biome to be generated + * @param $id int + * @param $biome Biome + * @return void + */ + public function onCommand(CommandSender $sender, Command $cmd, $label, array $args): bool { - switch($cmd->getName()) { + switch ($cmd->getName()) { case "createworld" : // /createworld [generator = betternormal] [seed = rand()] [options(json)] - switch(count($args)) { + switch (count($args)) { case 0 : return false; break; @@ -77,50 +111,50 @@ class Main extends PluginBase implements Listener { $generator = Generator::getGenerator("betternormal"); $generatorName = "betternormal"; $seed = $this->generateRandomSeed(); - $options = [ ]; + $options = []; break; case 2 : // /createworld [generator = betternormal] $name = $args [0]; $generator = Generator::getGenerator($args [1]); - if(Generator::getGeneratorName($generator) !== strtolower($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 = [ ]; + $options = []; break; case 3 : // /createworld [generator = betternormal] [seed = rand()] $name = $args [0]; $generator = Generator::getGenerator($args [1]); - if(Generator::getGeneratorName($generator) !== strtolower($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) { + if (preg_match("[^\d]", $args [2]) !== false) { $parts = str_split($args [2]); - foreach($parts as $key => $str) { + foreach ($parts as $key => $str) { $parts [$key] = ord($str); } $seed = implode("", $parts); } else { $seed = $args [2]; } - $options = [ ]; + $options = []; break; default : // /createworld [generator = betternormal] [seed = rand()] [options(json)] $name = $args [0]; $generator = Generator::getGenerator($args [1]); - if(Generator::getGeneratorName($generator) !== strtolower($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) { + 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) { + foreach ($parts as $key => $str) { $parts [$key] = ord($str); } $seed = implode("", $parts); @@ -129,14 +163,14 @@ class Main extends PluginBase implements Listener { } unset($args [0], $args [1], $args [2]); $options = json_decode($args [3], true); - if(! is_array($options)) { + 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*/){ + if ((int)$seed == 0/*String*/) { $seed = $this->generateRandomSeed(); } $this->getServer()->broadcastMessage(Main::PREFIX . "§aGenerating level $name with generator $generatorName and seed $seed.."); @@ -144,57 +178,54 @@ class Main extends PluginBase implements Listener { $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()); + return true; + } } return false; } - - /* - * Registers a forest type. - * @param $name string - * @param $treeClass string - * @params $infos Array(temperature, rainfall) - * @return bool - */ - 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); - } - - /* - * Registers a biome for the normal generator. Normal means(Biome::register) doesn't allow biome to be generated - * @param $id int - * @param $biome Biome - * @return void - */ - public static function registerBiome(int $id, Biome $biome) { - BetterNormal::registerBiome($biome); - } - + /* * Generates a(semi) random seed. * @return 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 - + /* * Checks after a chunk populates so we an add tiles and loot tables * @param $event pocketmine\event\level\ChunkPopulateEvent * @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) { $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); - 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); } else { $cfg->remove($key); @@ -202,36 +233,38 @@ class Main extends PluginBase implements Listener { } } } - - + + /* - * Checks when a player interacts with a loot chest to create it. + * Checks when a player breaks a loot chest which is not created 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; + if ($event->getBlock()->getId() !== Block::CHEST) return; + 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) + 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()); } - - + /* - * Checks when a player breaks a loot chest which is not created to create it - */ + * Check if it's a Tesseract like namespace + * @return bool + */ + public function onBlockBreak(BlockBreakEvent $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; + if ($event->getBlock()->getId() !== Block::CHEST) return; + if (!$cfg->exists($event->getBlock()->getX() . ";" . $event->getBlock()->getY() . ";" . $event->getBlock()->getZ())) return; $nbt = new CompoundTag("", [ new ListTag("Items", []), new StringTag("id", Tile::CHEST), @@ -245,16 +278,4 @@ class Main extends PluginBase implements Listener { LootTable::fillChest($chest->getInventory(), $event->getBlock()); // $event->setCancelled(); //i think nope. You want to break it with items } - - /* - * Check if it's a Tesseract like namespace - * @return bool - */ - public static function isOtherNS() { - try { - return @class_exists("pocketmine\\level\\generator\\normal\\object\\OakTree"); - } catch(\Exception $e) { - return false; - } - } } diff --git a/src/Ad5001/BetterGen/structure/SakuraTree.php b/src/Ad5001/BetterGen/structure/SakuraTree.php index e855c3c..0e41259 100644 --- a/src/Ad5001/BetterGen/structure/SakuraTree.php +++ b/src/Ad5001/BetterGen/structure/SakuraTree.php @@ -442,8 +442,8 @@ class SakuraTree extends Tree { public $trunkHeight = 11; - private $leafType; - private $leaf2Type; + public $leafType; + public $leaf2Type; /* * Constructs the class diff --git a/src/Ad5001/BetterGen/structure/Temple.php b/src/Ad5001/BetterGen/structure/Temple.php index d719aef..4ad1e18 100644 --- a/src/Ad5001/BetterGen/structure/Temple.php +++ b/src/Ad5001/BetterGen/structure/Temple.php @@ -1,10 +1,10 @@ true, + Block::SAPLING => true, + Block::LOG => true, + Block::LEAVES => true, + Block::STONE => true, + Block::DANDELION => true, + Block::POPPY => true, + Block::SNOW_LAYER => true, + Block::LOG2 => true, + Block::LEAVES2 => true, + Block::CACTUS => true + ]; + protected $directions = [ + [ + 1, + 1 + ], + [ + 1, + -1 + ], + [ + -1, + -1 + ], + [ + -1, + 1 + ] ]; /** @var ChunkManager */ private $level; - public $overridable = [ - Block::AIR => true, - 6 => true, - 17 => true, - 18 => true, - Block::DANDELION => true, - Block::POPPY => true, - Block::SNOW_LAYER => true, - Block::LOG2 => true, - Block::LEAVES2 => true, - Block::CACTUS => true - ]; - protected $directions = [ - [ - 1, - 1 - ], - [ - 1, - - 1 - ], - [ - - 1, - - 1 - ], - [ - - 1, - 1 - ] - ]; + private $direction = 0; /* * Checks if a temple is placeable @@ -119,17 +121,18 @@ class Temple extends Object { * @param $random pocketmine\utils\Random * @return bool */ + public function canPlaceObject(ChunkManager $level, $x, $y, $z, Random $random) { $this->level = $level; $this->direction = $random->nextBoundedInt(4); - for($xx = $x - 10; $xx <= $x + 10; $xx ++) - for($yy = $y + 1; $yy <= $y + 11; $yy ++) - for($zz = $z - 10; $zz <= $z + 10; $zz ++) - if (! isset($this->overridable [$level->getBlockIdAt($xx, $yy, $zz )] )) + for ($xx = $x - 10; $xx <= $x + 10; $xx++) + for ($yy = $y + 1; $yy <= $y + 11; $yy++) + for ($zz = $z - 10; $zz <= $z + 10; $zz++) + if (!isset($this->overridable [$level->getBlockIdAt($xx, $yy, $zz)])) return false; return true; } - + /* * Places a temple * @param $level pocketmine\level\ChunkManager @@ -140,41 +143,41 @@ class Temple extends Object { */ public function placeObject(ChunkManager $level, $x, $y, $z, Random $random) { // 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. $this->level = $level; $firstPos = 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 - BuildingUtils::walls($level, $firstPos, $sndPos, Block::get(Block::SANDSTONE )); - + BuildingUtils::walls($level, $firstPos, $sndPos, Block::get(Block::SANDSTONE)); + // Next floor - $firstPos->x --; - $firstPos->z --; + $firstPos->x--; + $firstPos->z--; $firstPos->y = $y + $i; - $sndPos->x ++; - $sndPos->z ++; + $sndPos->x++; + $sndPos->z++; $sndPos->y = $y + $i; } // Floors - for($xx = $x + 9; $xx >= $x - 9; $xx --) - for($zz = $z + 9; $zz >= $z - 9; $zz --) + for ($xx = $x + 9; $xx >= $x - 9; $xx--) + for ($zz = $z + 9; $zz >= $z - 9; $zz--) $this->placeBlock($xx, $y, $zz); - for($xx = $x + 5; $xx >= $x - 5; $xx --) - for($zz = $z + 5; $zz >= $z - 5; $zz --) + for ($xx = $x + 5; $xx >= $x - 5; $xx--) + for ($zz = $z + 5; $zz >= $z - 5; $zz--) $this->placeBlock($xx, $y + 4, $zz); - + // Creating hole - for($xx = $x - 1; $xx <= $x + 1; $xx ++) - for($yy = $y - 11; $yy <= $y + 4; $yy ++) - for($zz = $z - 1; $zz <= $z + 1; $zz ++) + for ($xx = $x - 1; $xx <= $x + 1; $xx++) + for ($yy = $y - 11; $yy <= $y + 4; $yy++) + for ($zz = $z - 1; $zz <= $z + 1; $zz++) $this->placeBlock($xx, $yy, $zz, 0); - + // Floor patern - foreach($this->directions as $dir ) { + foreach ($this->directions as $dir) { // Building pillar - for($yy = $y + 1; $yy <= $y + 3; $yy ++) + for ($yy = $y + 1; $yy <= $y + 3; $yy++) $this->placeBlock($x + ($dir [0] * 2), $yy, $z + ($dir [1] * 2), Block::SANDSTONE, 2); // Orange hardened clay $this->placeBlock($x + $dir [0], $y, $z + $dir [1], Block::STAINED_HARDENED_CLAY, 1); @@ -184,7 +187,7 @@ class Temple extends Object { $this->placeBlock($x, $y, $z + ($dir [1] * 3), Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + ($dir [0] * 2), $yy, $z + ($dir [1]), Block::STAINED_HARDENED_CLAY, 1); $this->placeBlock($x + ($dir [0]), $yy, $z + ($dir [1] * 2), Block::STAINED_HARDENED_CLAY, 1); - + // Sandstone $this->placeBlock($x + $dir [0], $y, $z); $this->placeBlock($x, $y, $z + $dir [1]); @@ -192,54 +195,54 @@ class Temple extends Object { // Blue hardened clay (center) $this->placeBlock($x, $y, $z, Block::STAINED_HARDENED_CLAY, 11); // Hole walls - BuildingUtils::walls($level, new Vector3($x - 2, $y, $z - 2 ), new Vector3($x + 2, $y - 8, $z + 2 ), Block::get(Block::SANDSTONE )); - + 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 - 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); } - 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); } - - 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 - 11, $z + $diagPos [1], Block::SANDSTONE, 2); } - + // Floor + TNT - for($xx = $x - 2; $xx <= $x + 2; $xx ++) - for($zz = $z - 2; $zz <= $z + 2; $zz ++) + for ($xx = $x - 2; $xx <= $x + 2; $xx++) + for ($zz = $z - 2; $zz <= $z + 2; $zz++) $this->placeBlock($xx, $y - 12, $zz, Block::SANDSTONE, 2); - for($xx = $x - 1; $xx <= $x + 1; $xx ++) - for($zz = $z - 1; $zz <= $z + 1; $zz ++) + for ($xx = $x - 1; $xx <= $x + 1; $xx++) + for ($zz = $z - 1; $zz <= $z + 1; $zz++) $this->placeBlock($xx, $y - 13, $zz, Block::TNT); $this->placeBlock($x, $y - 11, $z, Block::STONE_PRESSURE_PLATE); - + // 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); - 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, $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); + // Entrance is a rectangular parallelepiped switch ($this->direction) { case self::DIRECTION_PLUSX : // x+ (0) - // Building towers. + // Building towers. $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); // 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 - 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)); // Creating path to towers. - for($yy = $y + 1; $yy <= $y + 2; $yy ++) - for($zz = $z - 6; $zz <= $z + 6; $zz ++) + for ($yy = $y + 1; $yy <= $y + 2; $yy++) + for ($zz = $z - 6; $zz <= $z + 6; $zz++) $this->placeBlock($x + 8, $yy, $zz, 0); // 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); // Polished entrance @@ -251,40 +254,40 @@ class Temple extends Object { } // Finishing entrance structure $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 + 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 - 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); - for($xx = $x + 6; $xx <= $x + 9; $xx ++) - for($zz = $z - 2; $zz <= $z + 2; $zz ++) + for ($xx = $x + 6; $xx <= $x + 9; $xx++) + for ($zz = $z - 2; $zz <= $z + 2; $zz++) $this->placeBlock($xx, $y + 4, $zz); break; - + case self::DIRECTION_MINX : // x- (1) - // Building towers. + // Building towers. $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); // Creating rectangular parallelepiped of sandstone. - for($xx = $x - 6; $xx >= $x - 9; $xx --) - for($yy = $y + 1; $yy <= $y + 4; $yy ++) - for($zz = $z - 6; $zz <= $z + 6; $zz ++) + for ($xx = $x - 6; $xx >= $x - 9; $xx--) + for ($yy = $y + 1; $yy <= $y + 4; $yy++) + for ($zz = $z - 6; $zz <= $z + 6; $zz++) $this->placeBlock($xx, $yy, $zz); // Creating a path to the entrance - for($xx = $x - 6; $xx >= $x - 9; $xx --) - for($yy = $y + 1; $yy <= $y + 4; $yy ++) - for($zz = $z - 1; $zz <= $z + 1; $zz ++) + for ($xx = $x - 6; $xx >= $x - 9; $xx--) + for ($yy = $y + 1; $yy <= $y + 4; $yy++) + for ($zz = $z - 1; $zz <= $z + 1; $zz++) $this->placeBlock($xx, $yy, $zz, 0); // Creating path to towers. - for($yy = $y + 1; $yy <= $y + 2; $yy ++) - for($zz = $z - 6; $zz <= $z + 6; $zz ++) + for ($yy = $y + 1; $yy <= $y + 2; $yy++) + for ($zz = $z - 6; $zz <= $z + 6; $zz++) $this->placeBlock($x - 8, $yy, $zz, 0); // 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); // Polished entrance @@ -296,35 +299,35 @@ class Temple extends Object { } // Finishing entrance structure $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 + 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 - 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); - for($xx = $x - 6; $xx >= $x - 9; $xx --) - for($zz = $z - 2; $zz <= $z + 2; $zz ++) + for ($xx = $x - 6; $xx >= $x - 9; $xx--) + for ($zz = $z - 2; $zz <= $z + 2; $zz++) $this->placeBlock($xx, $y + 4, $zz); break; - + case self::DIRECTION_PLUSZ : // z+ (2) - // 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_MINX); // 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 - for($xx = $x - 1; $xx <= $x + 1; $xx ++) - for($yy = $y + 1; $yy <= $y + 4; $yy ++) - for($zz = $z + 6; $zz <= $z + 9; $zz ++) + for ($xx = $x - 1; $xx <= $x + 1; $xx++) + for ($yy = $y + 1; $yy <= $y + 4; $yy++) + for ($zz = $z + 6; $zz <= $z + 9; $zz++) $this->placeBlock($xx, $yy, $zz, 0); // 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 - 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); // Polished entrance @@ -336,34 +339,34 @@ class Temple extends Object { } // Finishing entrance structure $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($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 - 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); - for($zz = $z + 6; $zz <= $z + 9; $zz ++) - for($xx = $x - 2; $xx <= $x + 2; $xx ++) + for ($zz = $z + 6; $zz <= $z + 9; $zz++) + for ($xx = $x - 2; $xx <= $x + 2; $xx++) $this->placeBlock($xx, $y + 4, $zz); break; - + case self::DIRECTION_MINZ : // z- (3) - // Building towers. + // Building towers. $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); // 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 - 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. - for($yy = $y + 1; $yy <= $y + 2; $yy ++) - for($xx = $x - 6; $xx <= $x + 6; $xx ++) + for ($yy = $y + 1; $yy <= $y + 2; $yy++) + for ($xx = $x - 6; $xx <= $x + 6; $xx++) $this->placeBlock($xx, $yy, $z - 8, 0); // 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); // Polished entrance @@ -375,22 +378,22 @@ class Temple extends Object { } // Finishing entrance structure $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($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 - 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); - for($zz = $z - 6; $zz >= $z - 9; $zz --) - for($xx = $x - 2; $xx <= $x + 2; $xx ++) + for ($zz = $z - 6; $zz >= $z - 9; $zz--) + for ($xx = $x - 2; $xx <= $x + 2; $xx++) $this->placeBlock($xx, $y + 4, $zz); break; } } - + /* * Places a slab * @param $x int @@ -398,11 +401,12 @@ class Temple extends Object { * @param $z int * @return void */ - protected function placeSlab($x, $y, $z) { - $this->level->setBlockIdAt($x, $y, $z, 44); - $this->level->setBlockDataAt($x, $y, $z, 1); + + protected function placeBlock($x, $y, $z, $id = Block::SANDSTONE, $meta = 0) { + $this->level->setBlockIdAt($x, $y, $z, $id); + $this->level->setBlockDataAt($x, $y, $z, $meta); } - + /* * Places a slab * @param $x int @@ -412,28 +416,15 @@ class Temple extends Object { * @param $meta int * @return void */ - protected function placeBlock($x, $y, $z, $id = Block::SANDSTONE, $meta = 0) { - $this->level->setBlockIdAt($x, $y, $z, $id); - $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 - * @param $x int - * @param $y int - * @param $z int - * @param $direction1 int - * @param $direction2 int - * @return void - */ + 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)); switch ($direction1) { case self::DIRECTION_PLUSX : // x+ (0) - // Stairs + // Stairs switch ($direction2) { 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 + 2, $zz); } @@ -441,19 +432,19 @@ class Temple extends Object { $this->placeBlock($x, $y + 1, $z + 1); $this->placeSlab($x, $y + 2, $z + 1); // Pattern - foreach([ - 1, - 2, - 4 - ] as $h ) { + foreach ([ + 1, + 2, + 4 + ] 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, $y + $h, $z + 2, Block::STAINED_HARDENED_CLAY, 1); } - foreach([ - 3, - 5 - ] as $h ) { + foreach ([ + 3, + 5 + ] 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, $y + $h, $z + 2, Block::SANDSTONE, 1); @@ -464,13 +455,13 @@ class Temple extends Object { $this->placeBlock($x - 1, $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); - + // 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 )); + 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)); break; 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 + 2, $zz); } @@ -478,19 +469,19 @@ class Temple extends Object { $this->placeBlock($x, $y + 1, $z - 1); $this->placeSlab($x, $y + 2, $z - 1); // Pattern - foreach([ - 1, - 2, - 4 - ] as $h ) { + foreach ([ + 1, + 2, + 4 + ] 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, $y + $h, $z - 2, Block::STAINED_HARDENED_CLAY, 1); } - foreach([ - 3, - 5 - ] as $h ) { + foreach ([ + 3, + 5 + ] 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, $y + $h, $z - 2, Block::SANDSTONE, 1); @@ -505,8 +496,8 @@ class Temple extends Object { } // 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 )); + BuildingUtils::fill($this->level, new Vector3($x - 9, $y + 5, $z + 4), new Vector3($x - 7, $y + 7, $z + 5), Block::get(Block::SANDSTONE, 2)); + BuildingUtils::fill($this->level, new Vector3($x - 8, $y + 5, $z + 4), new Vector3($x - 8, $y + 6, $z + 5), Block::get(Block::AIR)); // Finishing stairs system $this->placeBlock($x - 2, $y + 3, $z, Block::SANDSTONE_STAIRS, 1); @@ -515,22 +506,22 @@ class Temple extends Object { $this->placeBlock($x - 2, $y + 5, $z, Block::AIR); $this->placeBlock($x - 2, $y + 6, $z, Block::AIR); // 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 - 4, $y, $z + 2), new Vector3($x - 9, $y + 4, $z - 2), Block::get(Block::SANDSTONE)); + // Other side pattern - foreach([ - 1, - 2, - 4 - ] as $h ) { + foreach ([ + 1, + 2, + 4 + ] 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, Block::STAINED_HARDENED_CLAY, 1); } - foreach([ - 3, - 5 - ] as $h ) { + foreach ([ + 3, + 5 + ] 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, Block::SANDSTONE, 1); @@ -542,12 +533,12 @@ class Temple extends Object { $this->placeBlock($x + 2, $y + 7, $z, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y + 7, $z + 1, Block::SANDSTONE, 2); break; - + case self::DIRECTION_MINX : // x- (1) - // Stairs + // Stairs switch ($direction2) { 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 + 2, $zz); } @@ -555,19 +546,19 @@ class Temple extends Object { $this->placeBlock($x, $y + 1, $z + 1); $this->placeSlab($x, $y + 2, $z + 1); // Pattern - foreach([ - 1, - 2, - 4 - ] as $h ) { + foreach ([ + 1, + 2, + 4 + ] 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, $y + $h, $z + 2, Block::STAINED_HARDENED_CLAY, 1); } - foreach([ - 3, - 5 - ] as $h ) { + foreach ([ + 3, + 5 + ] 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, $y + $h, $z + 2, Block::SANDSTONE, 1); @@ -578,13 +569,13 @@ class Temple extends Object { $this->placeBlock($x - 1, $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); - + // 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 )); + 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)); break; 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 + 2, $zz); } @@ -592,19 +583,19 @@ class Temple extends Object { $this->placeBlock($x, $y + 1, $z - 1); $this->placeSlab($x, $y + 2, $z - 1); // Pattern - foreach([ - 1, - 2, - 4 - ] as $h ) { + foreach ([ + 1, + 2, + 4 + ] 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, $y + $h, $z - 2, Block::STAINED_HARDENED_CLAY, 1); } - foreach([ - 3, - 5 - ] as $h ) { + foreach ([ + 3, + 5 + ] 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, $y + $h, $z - 2, Block::SANDSTONE, 1); @@ -615,13 +606,13 @@ class Temple extends Object { $this->placeBlock($x - 1, $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); - + // 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 )); + 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)); break; } - + // Finishing stairs system $this->placeBlock($x + 2, $y + 3, $z, Block::SANDSTONE_STAIRS, 0); $this->placeBlock($x + 3, $y + 4, $z, Block::SANDSTONE_STAIRS, 0); @@ -629,22 +620,22 @@ class Temple extends Object { $this->placeBlock($x + 2, $y + 5, $z, Block::AIR); $this->placeBlock($x + 2, $y + 6, $z, Block::AIR); // 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 + 4, $y, $z + 2), new Vector3($x + 9, $y + 4, $z - 2), Block::get(Block::SANDSTONE)); + // Other side pattern - foreach([ - 1, - 2, - 4 - ] as $h ) { + foreach ([ + 1, + 2, + 4 + ] 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, Block::STAINED_HARDENED_CLAY, 1); } - foreach([ - 3, - 5 - ] as $h ) { + foreach ([ + 3, + 5 + ] 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, Block::SANDSTONE, 1); @@ -656,12 +647,12 @@ class Temple extends Object { $this->placeBlock($x - 2, $y + 7, $z, Block::SANDSTONE, 2); $this->placeBlock($x - 2, $y + 7, $z + 1, Block::SANDSTONE, 2); break; - + case self::DIRECTION_PLUSZ : // z+ (2) - // Stairs + // Stairs switch ($direction2) { 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 + 2, $z - 1); } @@ -669,19 +660,19 @@ class Temple extends Object { $this->placeBlock($x + 1, $y + 1, $z); $this->placeSlab($x + 1, $y + 2, $z); // Pattern - foreach([ - 1, - 2, - 4 - ] as $h ) { + foreach ([ + 1, + 2, + 4 + ] 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, Block::STAINED_HARDENED_CLAY, 1); } - foreach([ - 3, - 5 - ] as $h ) { + foreach ([ + 3, + 5 + ] 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, Block::SANDSTONE, 1); @@ -693,11 +684,11 @@ class Temple extends Object { $this->placeBlock($x + 2, $y + 7, $z, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y + 7, $z + 1, Block::SANDSTONE, 2); // Building entrance to second floor. - 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 - 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)); break; 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 + 2, $z - 1); } @@ -705,19 +696,19 @@ class Temple extends Object { $this->placeBlock($x - 1, $y + 1, $z); $this->placeSlab($x - 1, $y + 2, $z); // Pattern - foreach([ - 1, - 2, - 4 - ] as $h ) { + foreach ([ + 1, + 2, + 4 + ] 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, Block::STAINED_HARDENED_CLAY, 1); } - foreach([ - 3, - 5 - ] as $h ) { + foreach ([ + 3, + 5 + ] 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, Block::SANDSTONE, 1); @@ -729,11 +720,11 @@ class Temple extends Object { $this->placeBlock($x - 2, $y + 7, $z, Block::SANDSTONE, 2); $this->placeBlock($x - 2, $y + 7, $z + 1, Block::SANDSTONE, 2); // Building entrance to second floor. - 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 - 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)); break; } - + // Finishing stairs system $this->placeBlock($x, $y + 3, $z - 2, Block::SANDSTONE_STAIRS, 3); $this->placeBlock($x, $y + 4, $z - 3, Block::SANDSTONE_STAIRS, 3); @@ -741,22 +732,22 @@ class Temple extends Object { $this->placeBlock($x, $y + 5, $z - 2, Block::AIR); $this->placeBlock($x, $y + 6, $z - 2, Block::AIR); // 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 + 2, $y, $z - 4), new Vector3($x - 2, $y + 4, $z - 9), Block::get(Block::SANDSTONE)); + // Other side pattern - foreach([ - 1, - 2, - 4 - ] as $h ) { + foreach ([ + 1, + 2, + 4 + ] 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, $y + $h, $z + 2, Block::STAINED_HARDENED_CLAY, 1); } - foreach([ - 3, - 5 - ] as $h ) { + foreach ([ + 3, + 5 + ] 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, $y + $h, $z + 2, Block::SANDSTONE, 1); @@ -768,12 +759,12 @@ class Temple extends Object { $this->placeBlock($x, $y + 7, $z + 2, Block::SANDSTONE, 2); $this->placeBlock($x + 1, $y + 7, $z + 2, Block::SANDSTONE, 2); break; - + case self::DIRECTION_MINZ : // z- (3) - // Stairs + // Stairs switch ($direction2) { 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 + 2, $z + 1); } @@ -781,19 +772,19 @@ class Temple extends Object { $this->placeBlock($x + 1, $y + 1, $z); $this->placeSlab($x + 1, $y + 2, $z); // Pattern - foreach([ - 1, - 2, - 4 - ] as $h ) { + foreach ([ + 1, + 2, + 4 + ] 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, Block::STAINED_HARDENED_CLAY, 1); } - foreach([ - 3, - 5 - ] as $h ) { + foreach ([ + 3, + 5 + ] 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, Block::SANDSTONE, 1); @@ -805,11 +796,11 @@ class Temple extends Object { $this->placeBlock($x + 2, $y + 7, $z, Block::SANDSTONE, 2); $this->placeBlock($x + 2, $y + 7, $z + 1, Block::SANDSTONE, 2); // Building entrance to second floor. - 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 + 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)); break; 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 + 2, $z + 1); } @@ -817,19 +808,19 @@ class Temple extends Object { $this->placeBlock($x - 1, $y + 1, $z); $this->placeSlab($x - 1, $y + 2, $z); // Pattern - foreach([ - 1, - 2, - 4 - ] as $h ) { + foreach ([ + 1, + 2, + 4 + ] 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, Block::STAINED_HARDENED_CLAY, 1); } - foreach([ - 3, - 5 - ] as $h ) { + foreach ([ + 3, + 5 + ] 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, Block::SANDSTONE, 1); @@ -841,11 +832,11 @@ class Temple extends Object { $this->placeBlock($x - 2, $y + 7, $z, Block::SANDSTONE, 2); $this->placeBlock($x - 2, $y + 7, $z + 1, Block::SANDSTONE, 2); // Building entrance to second floor. - 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 + 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)); break; } - + // Finishing stairs system $this->placeBlock($x, $y + 3, $z + 2, Block::SANDSTONE_STAIRS, 2); $this->placeBlock($x, $y + 4, $z + 3, Block::SANDSTONE_STAIRS, 2); @@ -853,22 +844,22 @@ class Temple extends Object { $this->placeBlock($x, $y + 5, $z + 2, Block::AIR); $this->placeBlock($x, $y + 6, $z + 2, Block::AIR); // 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 + 2, $y, $z + 4), new Vector3($x - 2, $y + 4, $z + 9), Block::get(Block::SANDSTONE)); + // Other side pattern - foreach([ - 1, - 2, - 4 - ] as $h ) { + foreach ([ + 1, + 2, + 4 + ] 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, $y + $h, $z - 2, Block::STAINED_HARDENED_CLAY, 1); } - foreach([ - 3, - 5 - ] as $h ) { + foreach ([ + 3, + 5 + ] 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, $y + $h, $z - 2, Block::SANDSTONE, 1); @@ -881,20 +872,36 @@ class Temple extends Object { $this->placeBlock($x + 1, $y + 7, $z - 2, Block::SANDSTONE, 2); break; } - + // 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, 1); $this->placeBlock($x, $y + 9, $z - 2, Block::SANDSTONE_STAIRS, 2); $this->placeBlock($x, $y + 9, $z + 2, Block::SANDSTONE_STAIRS, 3); } - + + /* + * 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 $y int + * @param $z int + * @param $direction1 int + * @param $direction2 int + * @return void + */ + + protected function placeSlab($x, $y, $z) { + $this->level->setBlockIdAt($x, $y, $z, 44); + $this->level->setBlockDataAt($x, $y, $z, 1); + } + /* * Inverses a direction * @param $direction int * @return int */ + protected function getInversedDirection(int $direction): int { switch ($direction) { case self::DIRECTION_PLUSX : // x+ (0) @@ -910,7 +917,7 @@ class Temple extends Object { return self::DIRECTION_PLUSZ; break; default : - return - 1; + return -1; break; } }