added desertwell structure and endportal structure

This commit is contained in:
ArkQuark 2023-03-02 19:18:12 +03:00
parent 6725bb1bea
commit 97cee528a3
5 changed files with 352 additions and 2 deletions

View file

@ -80,6 +80,7 @@ class BlockAPI{
[SNOW_BLOCK, 0],
[BROWN_MUSHROOM_BLOCK, 0],
[RED_MUSHROOM_BLOCK, 0],
[MYCELIUM, 0],
//Decoration
[COBBLESTONE_WALL, 0],

View file

@ -14,8 +14,8 @@ class MyceliumBlock extends SolidBlock{
return BLOCK_UPDATE_RANDOM;
}
public function onActivate(Item $item, Player $player){
//MonsterRoomStructure::buildStructure($this->level, $this->getX(), $this->getY(), $this->getZ());
public function onActivate(Item $item, Player $player){ //uwu
//StrongholdPortalRoomStructure::buildStructure($this->level, $this->getX(), $this->getY(), $this->getZ());
}
public function getDrops(Item $item, Player $player){

View file

@ -0,0 +1,84 @@
<?php
class DesertWellStructure{
public static $width = 5;
public static $structure = [
-2 => [
"SSSSS",
"SSSSS",
"SSSSS",
"SSSSS",
"SSSSS",
],
-1 => [
"SSSSS",
"SSWSS",
"SWWWS",
"SSWSS",
"SSSSS",
],
0 => [
"SSsSS",
"SS SS",
"s s",
"SS SS",
"SSsSS",
],
1 => [
"",
" S S ",
"",
" S S ",
"",
],
2 => [
"",
" S S ",
"",
" S S ",
"",
],
3 => [
"",
" sss ",
" sSs ",
" sss ",
"",
],
];
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 - floor(self::$width / 2) + $offsetZ);
switch($char){
case "S":
$level->setBlockRaw($vector, new SandStoneBlock());
break;
case "s":
$level->setBlockRaw($vector, new SlabBlock(1));
break;
case "W":
$level->setBlockRaw($vector, new WaterBlock());
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,58 @@
<?php
class StrongholdLibraryStructure{
public static $width = 14;
public static $structure = [-1 => []];
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 => []];
}
}

View file

@ -0,0 +1,207 @@
<?php
class StrongholdPortalRoomStructure{
public static $width = 11;
public static $lenght = 16;
public static $tmpStructure = [];
public static $structure = [
-1 => [
"SSSSSSSSSSS",
"SSSSSSSSSSS",
"SSSSSSSSSSS",
"SSSSSSSSSSS",
"SSSSSSSSSSS",
"SSSSSSSSSSS",
"SSSSSSSSSSS",
"SSSSSSSSSSS",
"SSSSSSSSSSS",
"SSSSSSSSSSS",
"SSSSSSSSSSS",
"SSSSSSSSSSS",
"SSSSSSSSSSS",
"SSSSSSSSSSS",
"SSSSSSSSSSS",
"SSSSSSSSSSS",
],
0 => [
"SSSSI ISSSS",
"SLS SLS",
"SLS SLS",
"SLS SLS",
"SSS sss SSS",
"S SSS S",
"S SSS S",
"S SSS S",
"S SSSSS S",
"S SLLLS S",
"S SLLLS S",
"S SLLLS S",
"S SSSSS S",
"S S",
"S S",
"SSSSSSSSSSS",
],
1 => [
"SSSSI ISSSS",
"S S",
"S S",
"S S",
"S S",
"S sss S",
"S SSS S",
"S SSS S",
"S S",
"S S",
"S S",
"S S",
"S S",
"S S",
"S S",
"SSSSSSSSSSS",
],
2 => [
"SSSSIIISSSS",
"S S",
"S S",
"I I",
"S S",
"I I",
"S s1s S",
"I SSS I",
"S PPP S",
"I P P I",
"S P P S",
"I P P I",
"S PPP S",
"I I",
"S S",
"SSSSSSSSSSS",
],
3 => [
"SSSSSSSSSSS",
"S S",
"S S",
"I I",
"S S",
"I I",
"S S",
"I I",
"S S",
"I I",
"S S",
"I I",
"S S",
"I I",
"S S",
"SSSSSSSSSSS",
],
4 => [
"SSSSSSSSSSS",
"S S",
"S S",
"S S",
"S S",
"S S",
"S S",
"S S",
"S S",
"S S",
"S S",
"S S",
"S S",
"S S",
"S S",
"SSSSSSSSSSS",
],
5 => [
"SSSSSSSSSSS",
"SSSSSSSSSSS",
"SSSSSSSSSSS",
"SSSSSSSSSSS",
"SSSSSSSSSSS",
"SSSSSSSSSSS",
"SSSSSSSSSSS",
"SSSSSSSSSSS",
"SSSSSSSSSSS",
"SSSSSSSSSSS",
"SSSSSSSSSSS",
"SSSSSSSSSSS",
"SSSSSSSSSSS",
"SSSSSSSSSSS",
"SSSSSSSSSSS",
"SSSSSSSSSSS",
]
];
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 buildStructure($level, $x, $y, $z){ /*use CENTER positions*/
self::replaceStoneBricks();
$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 - 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 "I":
$level->setBlockRaw($vector, new IronBarsBlock());
break;
case "L":
$level->setBlockRaw($vector, new LavaBlock());
break;
case "s":
$level->setBlockRaw($vector, new StoneBrickStairsBlock(2));
break;
case "1":
$level->setBlockRaw($vector, new MonsterSpawnerBlock());
break;
case "P":
$level->setBlockRaw($vector, new EndPortalFrameBlock(mt_rand(0, 4)));
break;
case " ":
$block = $level->getBlock($vector)->getID();
if($block === AIR){
break;
}
$level->setBlockRaw($vector, new AirBlock());
break;
}
++$offsetX;
}
++$offsetZ;
$offsetX = 0;
}
$offsetZ = 0;
}
}
}