mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
Normal oak tree and Balloon oak tree structure
This commit is contained in:
parent
22edf4ab8f
commit
24c5ef8d3d
5 changed files with 170 additions and 5 deletions
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
154
src/structure/tree/OakTreeStructure.php
Normal file
154
src/structure/tree/OakTreeStructure.php
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
<?php
|
||||
|
||||
class OakTreeStructure extends Structure{// implements TreeStructure{
|
||||
public $width = 5;
|
||||
public $length = 5;
|
||||
public $name = "Oak Tree";
|
||||
protected $structure = [
|
||||
];
|
||||
protected $map = [
|
||||
"W" => 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);
|
||||
}
|
||||
}
|
||||
13
src/structure/tree/TreeStructure.php
Normal file
13
src/structure/tree/TreeStructure.php
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
/*interface TreeStructure{
|
||||
protected function getType();
|
||||
|
||||
protected function makeDead();
|
||||
|
||||
protected function makeFallen();
|
||||
|
||||
protected function createLog();
|
||||
|
||||
protected function createLeaves();
|
||||
}*/
|
||||
|
|
@ -63,6 +63,4 @@ class SmallFarmStructure extends Structure{
|
|||
}
|
||||
return parent::getMappingFor($char);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue