From 7929a44b80d6df960b38d2dfe3f2a16896e94db0 Mon Sep 17 00:00:00 2001 From: ArkQuark <74979909+ArkQuark@users.noreply.github.com> Date: Thu, 2 Mar 2023 21:48:21 +0300 Subject: [PATCH] Added StrongholdLibrary structure --- src/material/block/solid/MyceliumBlock.php | 2 +- src/structure/StrongholdLibraryStructure.php | 58 ---- .../stronghold/StrongholdLibraryStructure.php | 298 ++++++++++++++++++ .../StrongholdPortalRoomStructure.php | 2 +- 4 files changed, 300 insertions(+), 60 deletions(-) delete mode 100644 src/structure/StrongholdLibraryStructure.php create mode 100644 src/structure/stronghold/StrongholdLibraryStructure.php rename src/structure/{ => stronghold}/StrongholdPortalRoomStructure.php (98%) diff --git a/src/material/block/solid/MyceliumBlock.php b/src/material/block/solid/MyceliumBlock.php index 064bb96e..d5fd2bb4 100644 --- a/src/material/block/solid/MyceliumBlock.php +++ b/src/material/block/solid/MyceliumBlock.php @@ -15,7 +15,7 @@ class MyceliumBlock extends SolidBlock{ } public function onActivate(Item $item, Player $player){ //uwu - //StrongholdPortalRoomStructure::buildStructure($this->level, $this->getX(), $this->getY(), $this->getZ()); + //StrongholdLibraryStructure::buildStructure($this->level, $this->getX(), $this->getY(), $this->getZ()); } public function getDrops(Item $item, Player $player){ diff --git a/src/structure/StrongholdLibraryStructure.php b/src/structure/StrongholdLibraryStructure.php deleted file mode 100644 index 43f33b19..00000000 --- a/src/structure/StrongholdLibraryStructure.php +++ /dev/null @@ -1,58 +0,0 @@ - []]; - - public static function generateFloor(){ - for($i = 0; $i < self::$width; $i++){ - $line = ""; - for($j = 0; $j < self::$width; $j++){ - if(Utils::chance(33)){ - $line .= "S"; - } - else{ - $line .= Utils::chance(50) ? "m" : "c"; - } - } - array_push(self::$structure[-1], $line); - } - } - - public static function buildStructure($level, $x, $y, $z){ /*use CENTER positions*/ - self::generateFloor(); - $offsetX = 0; - $offsetZ = 0; - foreach(self::$structure as $layerCount => $layer){ - foreach($layer as $line){ - $line = rtrim($line); //remove useless spaces(only from right) - foreach(str_split($line) as $char){ - $vector = new Vector3($x - floor(self::$width / 2) + $offsetX, $y + $layerCount, $z - floor(self::$width / 2) + $offsetZ); - switch($char){ - case "S": - $level->setBlockRaw($vector, new StoneBricksBlock(0)); - break; - case "m": - $level->setBlockRaw($vector, new StoneBricksBlock(1)); - break; - case "c": - $level->setBlockRaw($vector, new StoneBricksBlock(2)); - break; - case " ": - $block = $level->getBlock($vector)->getID(); - if($block === AIR){ - break; - } - $level->setBlockRaw($vector, new AirBlock()); - break; - } - ++$offsetX; - } - ++$offsetZ; - $offsetX = 0; - } - $offsetZ = 0; - } - self::$structure = [-1 => []]; - } -} \ No newline at end of file diff --git a/src/structure/stronghold/StrongholdLibraryStructure.php b/src/structure/stronghold/StrongholdLibraryStructure.php new file mode 100644 index 00000000..d8f4f125 --- /dev/null +++ b/src/structure/stronghold/StrongholdLibraryStructure.php @@ -0,0 +1,298 @@ + [ + "SSSSSSSSSSSSSS", + "SSSSSSSSSSSSSS", + "SSSSSSSSSSSSSS", + "SSSSSSSSSSSSSS", + "SSSSSSSSSSSSSS", + "SSSSSSSSSSSSSS", + "SSSSSSSSSSSSSS", + "SSSSSSSSSSSSSS", + "SSSSSSSSSSSSSS", + "SSSSSSSSSSSSSS", + "SSSSSSSSSSSSSS", + "SSSSSSSSSSSSSS", + "SSSSSSSSSSSSSS", + "SSSSSSSSSSSSSS", + "SSSSSSSSSSSSSS", + ], + 0 => [ + "SSSSSSI ISSSSS", + "SP L PS", + "SB BS", + "SB BB BB BB BS", + "SB BS", + "SP BB BB BB PS", + "SB BS", + "SB BB BB BB BS", + "SB BS", + "SP BB BB BB PS", + "SB BS", + "SB BB BB BB BS", + "SB BS", + "SP PS", + "SSSSSSSSSSSSSS", + ], + 1 => [ + "SSSSSSI ISSSSS", + "SP L PS", + "SB BS", + "SB BB BB BB BS", + "SB BS", + "SP BB BB BB PS", + "SB BS", + "SB BB BB BB BS", + "SB BS", + "SP BB BB BB PS", + "SB BS", + "SB BB BB BB BS", + "SB BS", + "SP PS", + "SSSSSSSSSSSSSS", + ], + 2 => [ + "SSSSSSIIISSSSS", + "SPT L PS", + "SB BS", + "SB BB BB BB BS", + "SB BS", + "SPTBB BB BB PS", + "SB BS", + "SB BB BB BB BS", + "SB BS", + "SPTBB BB BB PS", + "SB BS", + "SB BB BB BB BS", + "SB BS", + "SPT PS", + "SSSSSSSSSSSSSS", + ], + 3 => [ + "SSSSSSIIISSSSS", + "SP L PS", + "SB BS", + "SB BS", + "SB BS", + "SP PS", + "SB BS", + "SB BS", + "SB BS", + "SP PS", + "SB BS", + "SB BS", + "SB BS", + "SP PS", + "SSSSSSSSSSSSSS", + ], + 4 => [ + "SSSSSSSSSSSSSS", + "SPPPPPPPPPLPPS", + "SPPPPPPPPPPPPS", + "SPPP PPPPPS", + "SPPP PPPPS", + "SPPP PPPS", + "SPPP PPPS", + "SPPP PPPS", + "SPPP PPPS", + "SPPP PPPS", + "SPPP PPPS", + "SPPP PPPS", + "SPPPPPPPPPPPPS", + "SPPPPPPPPPPPPS", + "SSSSSSSSSSSSSS", + ], + 5 =>[ + "SSSSSSSSSSSSSS", + "SP L PS", + "SB FFFFFF BS", + "SB F FF BS", + "SB F FF BS", + "SP F F PS", + "SB F F BS", + "SB F F BS", + "SB F F BS", + "SP F F PS", + "SB F F BS", + "SB F F BS", + "SB FFFFFFFF BS", + "SP PS", + "SSSSSSSSSSSSSS", + ], + 6 => [ + "SSSSSSSSSSSSSS", + "SP L PS", + "SB BS", + "SB BS", + "SB BS", + "SP PS", + "SB FF BS", + "SB FFFF BS", + "SB FF BS", + "SP PS", + "SB BS", + "SB BS", + "SB BS", + "SP PS", + "SSSSSSSSSSSSSS", + ], + 7 => [ + "SSSSSSSSSSSSSS", + "SP PS", + "SB BS", + "SB BS", + "SB BS", + "SP PS", + "SB TT BS", + "SB TFFT BS", + "SB TT BS", + "SP PS", + "SB BS", + "SB BS", + "SB BS", + "SP PS", + "SSSSSSSSSSSSSS", + ], + 8 => [ + "SSSSSSSSSSSSSS", + "SP PS", + "SB BS", + "SB BS", + "SB BS", + "SP PS", + "SB BS", + "SB FF BS", + "SB BS", + "SP PS", + "SB BS", + "SB BS", + "SB BS", + "SP PS", + "SSSSSSSSSSSSSS", + ], + 9 => [ + "SSSSSSSSSSSSSS", + "SSSSSSSSSSSSSS", + "SSSSSSSSSSSSSS", + "SSSSSSSSSSSSSS", + "SSSSSSSSSSSSSS", + "SSSSSSSSSSSSSS", + "SSSSSSSSSSSSSS", + "SSSSSSSSSSSSSS", + "SSSSSSSSSSSSSS", + "SSSSSSSSSSSSSS", + "SSSSSSSSSSSSSS", + "SSSSSSSSSSSSSS", + "SSSSSSSSSSSSSS", + "SSSSSSSSSSSSSS", + "SSSSSSSSSSSSSS", + ] + ]; + + public static function replaceStoneBricks(){ + foreach(self::$structure as $layerInt => $layer){ + foreach($layer as $key => $str){ + $line = str_split($str); + for($i = 0; $i < count($line); $i++){ + $str = $line[$i]; + if($str == "S"){ + if(Utils::chance(33)){ + $line[$i] = "S"; + } + else{ + $line[$i] = Utils::chance(50) ? "M" : "C"; + } + } + } + self::$tmpStructure[$layerInt][$key] = implode("", $line); + } + } + } + + public static function placeCobweb(){ + foreach(self::$tmpStructure as $layerInt => $layer){ + if($layerInt >= 0 and $layerInt <= 3){ + foreach($layer as $key => $str){ + $line = str_split($str); + for($i = 0; $i < count($line); $i++){ + $str = $line[$i]; + if($str == " "){ + if(Utils::chance(5)){ + $line[$i] = "W"; + } + else{ + $line[$i] = " "; + } + } + } + self::$tmpStructure[$layerInt][$key] = implode("", $line); + } + } + } + } + + public static function buildStructure($level, $x, $y, $z){ /*use CENTER positions*/ + self::replaceStoneBricks(); + self::placeCobweb(); + + $offsetX = 0; + $offsetZ = 0; + foreach(self::$tmpStructure as $layerCount => $layer){ + foreach($layer as $line){ + $line = rtrim($line); //remove useless spaces(only from right) + foreach(str_split($line) as $char){ + $vector = new Vector3($x - floor(self::$width / 2) + $offsetX, $y + $layerCount, $z + $offsetZ); + switch($char){ + case "S": + $level->setBlockRaw($vector, new StoneBricksBlock(0)); + break; + case "M": + $level->setBlockRaw($vector, new StoneBricksBlock(1)); + break; + case "C": + $level->setBlockRaw($vector, new StoneBricksBlock(2)); + break; + case "B": + $level->setBlockRaw($vector, new BookshelfBlock()); + break; + case "W": + $level->setBlockRaw($vector, new CobwebBlock()); + break; + case "P": + $level->setBlockRaw($vector, new PlanksBlock()); + break; + case "T": + if($layerCount == 2) $level->setBlockRaw($vector, new TorchBlock(1)); + else $level->setBlockRaw($vector, new TorchBlock(0)); + break; + case "F": + $level->setBlockRaw($vector, new FenceBlock()); + break; + case "L": + $level->setBlockRaw($vector, new LadderBlock(3)); + break; + case "I": + $level->setBlockRaw($vector, new IronBarsBlock()); + break; + case " ": + $block = $level->getBlock($vector)->getID(); + if($block === AIR){ + break; + } + $level->setBlockRaw($vector, new AirBlock()); + break; + } + ++$offsetX; + } + ++$offsetZ; + $offsetX = 0; + } + $offsetZ = 0; + } + } +} \ No newline at end of file diff --git a/src/structure/StrongholdPortalRoomStructure.php b/src/structure/stronghold/StrongholdPortalRoomStructure.php similarity index 98% rename from src/structure/StrongholdPortalRoomStructure.php rename to src/structure/stronghold/StrongholdPortalRoomStructure.php index bc20d122..6b160caf 100644 --- a/src/structure/StrongholdPortalRoomStructure.php +++ b/src/structure/stronghold/StrongholdPortalRoomStructure.php @@ -162,7 +162,7 @@ class StrongholdPortalRoomStructure{ foreach($layer as $line){ $line = rtrim($line); //remove useless spaces(only from right) foreach(str_split($line) as $char){ - $vector = new Vector3($x - floor(self::$width / 2) + $offsetX, $y + $layerCount, $z - floor(self::$width / 2) + $offsetZ); + $vector = new Vector3($x - floor(self::$width / 2) + $offsetX, $y + $layerCount, $z + $offsetZ); switch($char){ case "S": $level->setBlockRaw($vector, new StoneBricksBlock(0));