diff --git a/src/material/block/solid/MyceliumBlock.php b/src/material/block/solid/MyceliumBlock.php index af31e1e6..4d4659a9 100644 --- a/src/material/block/solid/MyceliumBlock.php +++ b/src/material/block/solid/MyceliumBlock.php @@ -17,9 +17,9 @@ class MyceliumBlock extends SolidBlock{ public function onActivate(Item $item, Player $player){ //uwu //$oldtime = microtime(true); //if(mt_rand(0, 1) === 0){ - // Structures::$SMALLFARM_VILLAGE->rotate(Structure::DEG_240, $this->level)->build($this->level, $this->x, $this->y, $this->z); + //Structures::$SMALLFARM_VILLAGE->rotate(Structure::DEG_240, $this->level)->build($this->level, $this->x, $this->y, $this->z); //}else{ - // Structures::$SMALLFARM_VILLAGE->build($this->level, $this->x, $this->y, $this->z); + //(new OakTreeStructure())->build($this->level, $this->x, $this->y, $this->z); //} //$time = microtime(true); //console("builded in ".($time - $oldtime)); diff --git a/src/structure/Structure.php b/src/structure/Structure.php index d81863ba..b41e6471 100644 --- a/src/structure/Structure.php +++ b/src/structure/Structure.php @@ -94,7 +94,7 @@ abstract class Structure{ ConsoleAPI::warn(self::class." tried to rotate to invalid state($rotationLevel)"); return $this; } - var_dump($str); + //var_dump($str); return (clone $this)->setStructure($str, $this->width, $this->length); } diff --git a/src/structure/tree/OakTreeStructure.php b/src/structure/tree/OakTreeStructure.php new file mode 100644 index 00000000..01945249 --- /dev/null +++ b/src/structure/tree/OakTreeStructure.php @@ -0,0 +1,154 @@ + WOOD, + //" " => 0, + "D" => DIRT, + "L" => LEAVES, + "V" => [VINES, 2] + ]; + protected $dead = false; + + protected function getType(){ + if(mt_rand(0, 1)){ + return 0; //normal oak + } + //return 1; //fallen oak + //return 2; //fancy oak + return 3; //balloon oak + //return 4; //swamp oak + } + + protected function makeFallen(){ + + } + + protected function makeDead(){ + if(mt_rand(0, 1)){ + $this->dead = true; + } + } + + protected function createLog(){ + $this->trunk = mt_rand(3, 5); + $layers = []; + for($i = 0; $i < $this->trunk - 2; $i++){ + if($this->dead){ + $layers[$i] = [ + "", + " V ", + " VWV ", + " V ", + ]; + } + else{ + $layers[$i] = [ + "", + "", + " W ", + ]; + } + } + $this->structure = $layers; + } + + protected function createLeaves(){ + $type = $this->getType(); + $layers = []; + if($type == 0){ + $layers[$this->trunk - 2] = [ + "0LLL0", + "LLLLL", + "LLWLL", + "LLLLL", + "0LLL0", + ]; + $layers[$this->trunk - 1] = [ + "0LLL0", + "LLLLL", + "LLWLL", + "LLLLL", + "0LLL0", + ]; + $layers[$this->trunk] = [ + "", + " 0L0 ", + " LWL ", + " 0L0 ", + ]; + $layers[$this->trunk + 1] = [ + "", + " L ", + " LLL ", + " L ", + ]; + } + elseif($type == 3){ + $layers[$this->trunk == 3 ? $this->trunk - 2 : $this->trunk - 3] = [ + "", + " L ", + " LWL ", + " L ", + ]; + if($this->trunk != 3){ + $layers[$this->trunk - 2] = [ + " LLL ", + "LLLLL", + "LLWLL", + "LLLLL", + " LLL ", + ]; + } + $layers[$this->trunk - 1] = [ + " LLL ", + "LLLLL", + "LLWLL", + "LLLLL", + " LLL ", + ]; + $layers[$this->trunk] = [ + " LLL ", + "LLLLL", + "LLWLL", + "LLLLL", + " LLL ", + ]; + $layers[$this->trunk + 1] = [ + "", + " L ", + " LLL ", + " L ", + ]; + } + + foreach($layers as $layerID => $arrays){ + foreach($arrays as $lineID => $str){ + $line = str_split($str); + for($i = 0; $i < count($line); $i++){ + if(is_numeric($line[$i]) and Utils::chance(75)){ + $line[$i] = " "; + } + elseif(is_numeric($line[$i])){ + $line[$i] = "L"; + } + } + $this->structure[$layerID][$lineID] = implode("", $line); + } + } + } + + protected function getFinalStructure(Level $level, $x, $y, $z){ + //$this->makeDead(); + $this->createLog(); + $this->createLeaves(); + + return $this->structure; + //return parent::getFinalStructure($level, $x, $y, $z); + } +} \ No newline at end of file diff --git a/src/structure/tree/TreeStructure.php b/src/structure/tree/TreeStructure.php new file mode 100644 index 00000000..8277df8b --- /dev/null +++ b/src/structure/tree/TreeStructure.php @@ -0,0 +1,13 @@ +