Added some Village Houses

This commit is contained in:
ArkQuark 2023-03-02 23:59:07 +03:00
parent 7929a44b80
commit b92ed8004b
4 changed files with 391 additions and 1 deletions

View file

@ -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){

View file

@ -0,0 +1,113 @@
<?php
class SmallHouseStructure{
public static $width = 5;
public static $lenght = 5;
public static $tmpStructure;
public static $structure = [
0 => [
"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;
}
}
}

View file

@ -0,0 +1,164 @@
<?php
class VillageLibraryStructure{
public static $width = 9;
public static $lenght = 8;
public static $structure = [
0 => [
" 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;
}
}
}

View file

@ -0,0 +1,110 @@
<?php
class WoodHutStructure{
public static $width = 4;
public static $lenght = 6;
public static $structure = [
0 => [
" 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;
}
}
}