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

Public Member Functions

 setRandomAmount ($amount)
 
 setBaseAmount ($amount)
 
 addType ($type)
 
 getTypes ()
 
 populate (ChunkManager $level, $chunkX, $chunkZ, Random $random)
 
- Public Member Functions inherited from Populator
 populate (ChunkManager $level, $chunkX, $chunkZ, Random $random)
 

Member Function Documentation

◆ addType()

addType (   $type)
Parameters
$type
54  {
55  $this->flowerTypes[] = $type;
56  }

◆ getTypes()

getTypes ( )
Returns
array
61  {
62  return $this->flowerTypes;
63  }

◆ populate()

populate ( ChunkManager  $level,
  $chunkX,
  $chunkZ,
Random  $random 
)
Parameters
ChunkManager$level
$chunkX
$chunkZ
Random$random
Returns
mixed|void
73  {
74  $this->level = $level;
75  $amount = $random->nextRange(0, $this->randomAmount + 1) + $this->baseAmount;
76 
77  if(count($this->flowerTypes) === 0){
78  $this->addType([Block::DANDELION, 0]);
79  $this->addType([Block::RED_FLOWER, FlowerBlock::TYPE_POPPY]);
80  }
81 
82  $endNum = count($this->flowerTypes) - 1;
83 
84  for($i = 0; $i < $amount; ++$i){
85  $x = $random->nextRange($chunkX * 16, $chunkX * 16 + 15);
86  $z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15);
87  $y = $this->getHighestWorkableBlock($x, $z);
88  if($y !== -1 and $this->canFlowerStay($x, $y, $z)){
89  $type = mt_rand(0, $endNum);
90  $this->level->setBlockIdAt($x, $y, $z, $this->flowerTypes[$type][0]);
91  $this->level->setBlockDataAt($x, $y, $z, $this->flowerTypes[$type][1]);
92  }
93  }
94  }

◆ setBaseAmount()

setBaseAmount (   $amount)
Parameters
$amount
47  {
48  $this->baseAmount = $amount;
49  }

◆ setRandomAmount()

setRandomAmount (   $amount)
Parameters
$amount
40  {
41  $this->randomAmount = $amount;
42  }

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