diff --git a/src/material/block/solid/MyceliumBlock.php b/src/material/block/solid/MyceliumBlock.php index d5fd2bb4..6472cf15 100644 --- a/src/material/block/solid/MyceliumBlock.php +++ b/src/material/block/solid/MyceliumBlock.php @@ -15,7 +15,10 @@ class MyceliumBlock extends SolidBlock{ } public function onActivate(Item $item, Player $player){ //uwu - //StrongholdLibraryStructure::buildStructure($this->level, $this->getX(), $this->getY(), $this->getZ()); + /*$f = Utils::randomFloat(); + if($f <= 0.33) VillageLibraryStructure::buildStructure($this->level, $this->getX(), $this->getY(), $this->getZ()); + elseif($f <= 0.67) SmallHouseStructure::buildStructure($this->level, $this->getX(), $this->getY(), $this->getZ()); + else WoodHutStructure::buildStructure($this->level, $this->getX(), $this->getY(), $this->getZ());*/ } public function getDrops(Item $item, Player $player){ diff --git a/src/structure/village/SmallHouseStructure.php b/src/structure/village/SmallHouseStructure.php new file mode 100644 index 00000000..bfbd51a3 --- /dev/null +++ b/src/structure/village/SmallHouseStructure.php @@ -0,0 +1,113 @@ + [ + "CCCCC", + "CCCCC", + "CCCCC", + "CCCCC", + "CCCCC", + ], + 1 => [ + "CP PC", + "P P", + "P P", + "P L P", + "CPPPC", + ], + 2 => [ + "CP PC", + "P P", + "G G", + "P L P", + "CPPPC", + ], + 3 => [ + "CPPPC", + "P P", + "P P", + "P L P", + "CPPPC", + ], + 4 => [ + "WWWWW", + "WPPPW", + "WPPPW", + "WPPPW", + "WWWWW", + ] + ]; + + public static function generateFence(){ + self::$tmpStructure = self::$structure; + if(Utils::chance(50)){ + self::$tmpStructure[4] = [ + "WWWWW", + "WPPPW", + "WPPPW", + "WPLPW", + "WWWWW", + ]; + self::$tmpStructure[5] = [ + "FFFFF", + "F F", + "F F", + "F F", + "FFFFF", + ]; + } + } + + public static function buildStructure($level, $x, $y, $z){ /*use CENTER positions*/ + self::generateFence(); + + $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 "C": + $level->setBlockRaw($vector, new CobbleStoneBlock()); + break; + case "P": + $level->setBlockRaw($vector, new PlanksBlock()); + break; + case "W": + $level->setBlockRaw($vector, new WoodBlock()); + break; + case "D": + $level->setBlockRaw($vector, new DirtBlock()); + break; + case "G": + $level->setBlockRaw($vector, new GlassPaneBlock()); + break; + case "L": + $level->setBlockRaw($vector, new LadderBlock(2)); + break; + case "F": + $level->setBlockRaw($vector, new FenceBlock()); + 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/village/VillageLibraryStructure.php b/src/structure/village/VillageLibraryStructure.php new file mode 100644 index 00000000..f4977e1b --- /dev/null +++ b/src/structure/village/VillageLibraryStructure.php @@ -0,0 +1,164 @@ + [ + " S ", + "CCCCCCCCC", + "CCCCCCCCC", + "CCCCCCCCC", + "CCCCCCCCC", + "CCCCCCCCC", + "CCCCCCCCC", + "", + ], + 1 => [ + "", + "CdCCCCCCC", + "C TC", + "C C", + "C F F1C", + "C 2222PC", + "CCCCCCCCC", + "", + ], + 2 => [ + "", + "CdPPGGGPC", + "P P", + "G G", + "G c c G", + "P P", + "CPGGPGGPC", + "", + ], + 3 => [ + "", + "CPPPGGGPC", + "P P", + "G G", + "G G", + "PBBBBBBBP", + "CPPPPPPPC", + "", + ], + 4 => [ + "", + "CPPPPPPPC", + "PPPPPPPPP", + "P P", + "P P", + "PPPPPPPPP", + "CPPPPPPPC", + "", + ], + 5 => [ + "222222222", + "CCCCCCCCC", + "CCCCCCCCC", + "CCCCCCCCC", + "CCCCCCCCC", + "CCCCCCCCC", + "CCCCCCCCC", + "333333333", + ], + 6 => [ + "", + "222222222", + "CCCCCCCCC", + "CCCCCCCCC", + "CCCCCCCCC", + "CCCCCCCCC", + "333333333", + "", + ], + 7 => [ + "", + "", + "222222222", + "CCCCCCCCC", + "CCCCCCCCC", + "333333333", + "", + "", + ], + 8 => [ + "", + "", + "", + "222222222", + "333333333", + "", + "", + "", + ] + ]; + + public static function buildStructure($level, $x, $y, $z){ /*use CENTER positions*/ + $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 + $offsetZ); + switch($char){ + case "S": + $level->setBlockRaw($vector, new CobbleStoneStairsBlock(2)); + break; + case "C": + $level->setBlockRaw($vector, new CobbleStoneBlock()); + break; + case "P": + $level->setBlockRaw($vector, new PlanksBlock()); + break; + case "W": + $level->setBlockRaw($vector, new WoodBlock()); + break; + case "d": + if($layerCount == 1) $level->setBlockRaw($vector, new DoorBlock(WOODEN_DOOR)); + else $level->setBlockRaw($vector, new DoorBlock(WOODEN_DOOR, 0x08)); + break; + case "G": + $level->setBlockRaw($vector, new GlassPaneBlock()); + break; + case "B": + $level->setBlockRaw($vector, new BookshelfBlock()); + break; + case "F": + $level->setBlockRaw($vector, new FenceBlock()); + break; + case "c": + $level->setBlockRaw($vector, new CarpetBlock(12)); + break; + case "1": + $level->setBlockRaw($vector, new WoodStairsBlock(1)); + break; + case "2": + $level->setBlockRaw($vector, new WoodStairsBlock(2)); + break; + case "3": + $level->setBlockRaw($vector, new WoodStairsBlock(3)); + break; + case "T": + $level->setBlockRaw($vector, new WorkbenchBlock()); + 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/village/WoodHutStructure.php b/src/structure/village/WoodHutStructure.php new file mode 100644 index 00000000..26cada61 --- /dev/null +++ b/src/structure/village/WoodHutStructure.php @@ -0,0 +1,110 @@ + [ + " S ", + "CCCC", + "CDDC", + "CDDC", + "CDDC", + "CCCC", + ], + 1 => [ + "", + "WdPW", + "P P", + "P P", + "P FP", + "WPPW", + ], + 2 => [ + "", + "WdPW", + "P P", + "G G", + "P cP", + "WPPW", + ], + 3 => [ + "", + "WPPW", + "P P", + "P P", + "P P", + "WPPW", + ], + 4 => [ + "", + " WW ", + "W W", + "W W", + "W W", + " WW ", + ], + 5 => [ + "", + "", + " WW ", + " WW ", + " WW ", + "", + ] + ]; + + public static function buildStructure($level, $x, $y, $z){ /*use CENTER positions*/ + $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 + $offsetZ); + switch($char){ + case "S": + $level->setBlockRaw($vector, new CobbleStoneStairsBlock(2)); + break; + case "C": + $level->setBlockRaw($vector, new CobbleStoneBlock()); + break; + case "P": + $level->setBlockRaw($vector, new PlanksBlock()); + break; + case "W": + $level->setBlockRaw($vector, new WoodBlock()); + break; + case "D": + $level->setBlockRaw($vector, new DirtBlock()); + break; + case "d": + if($layerCount == 1) $level->setBlockRaw($vector, new DoorBlock(WOODEN_DOOR)); + else $level->setBlockRaw($vector, new DoorBlock(WOODEN_DOOR, 0x08)); + break; + case "G": + $level->setBlockRaw($vector, new GlassPaneBlock()); + break; + case "F": + $level->setBlockRaw($vector, new FenceBlock()); + break; + case "c": + $level->setBlockRaw($vector, new CarpetBlock(12)); + 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