GenisysPro  for Minecraft PE/Windows 10 v1.1.x
Feature-rich server software for Minecraft PE and Windows 10 Edition
SpruceTree Class Reference

Public Member Functions

 __construct ()
 
 placeObject (ChunkManager $level, $x, $y, $z, Random $random)
 
- Public Member Functions inherited from Tree
 canPlaceObject (ChunkManager $level, $x, $y, $z, Random $random)
 
 placeObject (ChunkManager $level, $x, $y, $z, Random $random)
 

Additional Inherited Members

- Static Public Member Functions inherited from Tree
static growTree (ChunkManager $level, $x, $y, $z, Random $random, $type=0, bool $noBigTree=true)
 
- Data Fields inherited from Tree
 $overridable
 
 $type = 0
 
 $trunkBlock = Block::LOG
 
 $leafBlock = Block::LEAVES
 
 $treeHeight = 7
 
 $leafType = 0
 
- Protected Member Functions inherited from Tree
 placeTrunk (ChunkManager $level, $x, $y, $z, Random $random, $trunkHeight)
 

Constructor & Destructor Documentation

◆ __construct()

__construct ( )

SpruceTree constructor.

35  {
36  $this->trunkBlock = Block::LOG;
37  $this->leafBlock = Block::LEAVES;
38  $this->leafType = Leaves::SPRUCE;
39  $this->type = Wood::SPRUCE;
40  $this->treeHeight = 10;
41  }

Member Function Documentation

◆ placeObject()

placeObject ( ChunkManager  $level,
  $x,
  $y,
  $z,
Random  $random 
)
Parameters
ChunkManager$level
$x
$y
$z
Random$random
50  {
51  $this->treeHeight = $random->nextBoundedInt(4) + 6;
52 
53  $topSize = $this->treeHeight - (1 + $random->nextBoundedInt(2));
54  $lRadius = 2 + $random->nextBoundedInt(2);
55 
56  $this->placeTrunk($level, $x, $y, $z, $random, $this->treeHeight - $random->nextBoundedInt(3));
57 
58  $radius = $random->nextBoundedInt(2);
59  $maxR = 1;
60  $minR = 0;
61 
62  for($yy = 0; $yy <= $topSize; ++$yy){
63  $yyy = $y + $this->treeHeight - $yy;
64 
65  for($xx = $x - $radius; $xx <= $x + $radius; ++$xx){
66  $xOff = abs($xx - $x);
67  for($zz = $z - $radius; $zz <= $z + $radius; ++$zz){
68  $zOff = abs($zz - $z);
69  if($xOff === $radius and $zOff === $radius and $radius > 0){
70  continue;
71  }
72 
73  if(!Block::$solid[$level->getBlockIdAt($xx, $yyy, $zz)]){
74  $level->setBlockIdAt($xx, $yyy, $zz, $this->leafBlock);
75  $level->setBlockDataAt($xx, $yyy, $zz, $this->type);
76  }
77  }
78  }
79 
80  if($radius >= $maxR){
81  $radius = $minR;
82  $minR = 1;
83  if(++$maxR > $lRadius){
84  $maxR = $lRadius;
85  }
86  }else{
87  ++$radius;
88  }
89  }
90  }

The documentation for this class was generated from the following file: