mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 03:59:43 +00:00
Fixed doors, ladders in smallHouse and added Small Farm
This commit is contained in:
parent
f3a7fa538d
commit
9a476ffdd1
4 changed files with 139 additions and 15 deletions
127
src/structure/village/SmallFarmStructure.php
Normal file
127
src/structure/village/SmallFarmStructure.php
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
<?php
|
||||
|
||||
class SmallFarmStructure{
|
||||
public static $width = 7;
|
||||
public static $lenght = 9;
|
||||
public static $tmpStructure;
|
||||
public static $structure = [
|
||||
0 => [
|
||||
"WWWWWWW",
|
||||
"WFFwFFW",
|
||||
"WFFwFFW",
|
||||
"WFFwFFW",
|
||||
"WFFwFFW",
|
||||
"WFFwFFW",
|
||||
"WFFwFFW",
|
||||
"WFFwFFW",
|
||||
"WWWWWWW",
|
||||
]
|
||||
];
|
||||
|
||||
public static function generateCrops(){
|
||||
self::$tmpStructure = self::$structure;
|
||||
$f = Utils::randomFloat();
|
||||
if($f <= 0.25){
|
||||
self::$tmpStructure[1] = [
|
||||
"",
|
||||
" HH HH ",
|
||||
" HH HH ",
|
||||
" HH HH ",
|
||||
" HH HH ",
|
||||
" HH HH ",
|
||||
" HH HH ",
|
||||
" HH HH ",
|
||||
"",
|
||||
];
|
||||
}
|
||||
elseif($f <= 0.5){
|
||||
self::$tmpStructure[1] = [
|
||||
"",
|
||||
" CC CC ",
|
||||
" CC CC ",
|
||||
" CC CC ",
|
||||
" CC CC ",
|
||||
" CC CC ",
|
||||
" CC CC ",
|
||||
" CC CC ",
|
||||
"",
|
||||
];
|
||||
}
|
||||
elseif($f <= 0.75){
|
||||
self::$tmpStructure[1] = [
|
||||
"",
|
||||
" PP PP ",
|
||||
" PP PP ",
|
||||
" PP PP ",
|
||||
" PP PP ",
|
||||
" PP PP ",
|
||||
" PP PP ",
|
||||
" PP PP ",
|
||||
"",
|
||||
];
|
||||
}
|
||||
else{
|
||||
self::$tmpStructure[1] = [
|
||||
"",
|
||||
" BB BB ",
|
||||
" BB BB ",
|
||||
" BB BB ",
|
||||
" BB BB ",
|
||||
" BB BB ",
|
||||
" BB BB ",
|
||||
" BB BB ",
|
||||
"",
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public static function buildStructure($level, $x, $y, $z){ /*use CENTER positions*/
|
||||
self::generateCrops();
|
||||
|
||||
$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 "W":
|
||||
$level->setBlockRaw($vector, new WoodBlock());
|
||||
break;
|
||||
case "F":
|
||||
$level->setBlockRaw($vector, new FarmlandBlock());
|
||||
break;
|
||||
case "w":
|
||||
$level->setBlockRaw($vector, new WaterBlock());
|
||||
break;
|
||||
|
||||
case "H":
|
||||
$level->setBlockRaw($vector, new WheatBlock());
|
||||
break;
|
||||
case "C":
|
||||
$level->setBlockRaw($vector, new CarrotBlock());
|
||||
break;
|
||||
case "P":
|
||||
$level->setBlockRaw($vector, new PotatoBlock());
|
||||
break;
|
||||
case "B":
|
||||
$level->setBlockRaw($vector, new BeetrootBlock());
|
||||
break;
|
||||
case " ":
|
||||
$block = $level->getBlock($vector)->getID();
|
||||
if($block === AIR){
|
||||
break;
|
||||
}
|
||||
$level->setBlockRaw($vector, new AirBlock());
|
||||
break;
|
||||
}
|
||||
++$offsetX;
|
||||
}
|
||||
++$offsetZ;
|
||||
$offsetX = 0;
|
||||
}
|
||||
$offsetZ = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -16,21 +16,21 @@ class SmallHouseStructure{
|
|||
"CP PC",
|
||||
"P P",
|
||||
"P P",
|
||||
"P L P",
|
||||
"P P",
|
||||
"CPPPC",
|
||||
],
|
||||
2 => [
|
||||
"CP PC",
|
||||
"P P",
|
||||
"G G",
|
||||
"P L P",
|
||||
"P P",
|
||||
"CPPPC",
|
||||
],
|
||||
3 => [
|
||||
"CPPPC",
|
||||
"P P",
|
||||
"P P",
|
||||
"P L P",
|
||||
"P P",
|
||||
"CPPPC",
|
||||
],
|
||||
4 => [
|
||||
|
|
@ -43,15 +43,12 @@ class SmallHouseStructure{
|
|||
];
|
||||
|
||||
public static function generateFence(){
|
||||
self::$tmpStructure = self::$structure;
|
||||
self::$tmpStructure = self::$structure;
|
||||
if(Utils::chance(50)){
|
||||
self::$tmpStructure[4] = [
|
||||
"WWWWW",
|
||||
"WPPPW",
|
||||
"WPPPW",
|
||||
"WPLPW",
|
||||
"WWWWW",
|
||||
];
|
||||
self::$tmpStructure[1][3] = "P L P";
|
||||
self::$tmpStructure[2][3] = "P L P";
|
||||
self::$tmpStructure[3][3] = "P L P";
|
||||
self::$tmpStructure[4][3] = "WPLPW";
|
||||
self::$tmpStructure[5] = [
|
||||
"FFFFF",
|
||||
"F F",
|
||||
|
|
|
|||
|
|
@ -118,8 +118,8 @@ class VillageLibraryStructure{
|
|||
$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));
|
||||
if($layerCount == 1) $level->setBlockRaw($vector, new DoorBlock(64));
|
||||
else $level->setBlockRaw($vector, new DoorBlock(64, 0x08));
|
||||
break;
|
||||
case "G":
|
||||
$level->setBlockRaw($vector, new GlassPaneBlock());
|
||||
|
|
|
|||
|
|
@ -79,8 +79,8 @@ class WoodHutStructure{
|
|||
$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));
|
||||
if($layerCount == 1) $level->setBlockRaw($vector, new DoorBlock(64));
|
||||
else $level->setBlockRaw($vector, new DoorBlock(64, 0x08));
|
||||
break;
|
||||
case "G":
|
||||
$level->setBlockRaw($vector, new GlassPaneBlock());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue