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

Public Member Functions

 getSettings ()
 
 getName ()
 
 __construct (array $options=[])
 
 init (ChunkManager $level, Random $random)
 
 generateChunk ($chunkX, $chunkZ)
 
 populateChunk ($chunkX, $chunkZ)
 
 getSpawn ()
 
- Public Member Functions inherited from Generator
 getWaterHeight ()
 
 __construct (array $settings=[])
 
 init (ChunkManager $level, Random $random)
 
 generateChunk ($chunkX, $chunkZ)
 
 populateChunk ($chunkX, $chunkZ)
 
 getSettings ()
 
 getName ()
 
 getSpawn ()
 

Static Public Member Functions

static parseLayers (string $layers)
 
- Static Public Member Functions inherited from Generator
static addGenerator ($object, $name)
 
static getGeneratorList ()
 
static getGenerator ($name)
 
static getGeneratorName ($class)
 
static getFastNoise1D (Noise $noise, $xSize, $samplingRate, $x, $y, $z)
 
static getFastNoise2D (Noise $noise, $xSize, $zSize, $samplingRate, $x, $y, $z)
 
static getFastNoise3D (Noise $noise, $xSize, $ySize, $zSize, $xSamplingRate, $ySamplingRate, $zSamplingRate, $x, $y, $z)
 

Data Fields

 $chunks
 
 $options
 
 $floorLevel
 
 $preset
 

Protected Member Functions

 parsePreset ($preset, $chunkX, $chunkZ)
 

Constructor & Destructor Documentation

◆ __construct()

__construct ( array  $options = [])

Flat constructor.

Parameters
array$options
70  {
71  $this->preset = "2;7,2x3,2;1;";
72  $this->options = $options;
73  $this->chunk = null;
74 
75  if(isset($this->options["decoration"])){
76  $ores = new Ore();
77  $ores->setOreTypes([
78  new object\OreType(new CoalOre(), 20, 16, 0, 128),
79  new object\OreType(New IronOre(), 20, 8, 0, 64),
80  new object\OreType(new RedstoneOre(), 8, 7, 0, 16),
81  new object\OreType(new LapisOre(), 1, 6, 0, 32),
82  new object\OreType(new GoldOre(), 2, 8, 0, 32),
83  new object\OreType(new DiamondOre(), 1, 7, 0, 16),
84  new object\OreType(new Dirt(), 20, 32, 0, 128),
85  new object\OreType(new Gravel(), 10, 16, 0, 128),
86  ]);
87  $this->populators[] = $ores;
88  }
89 
90  }

Member Function Documentation

◆ generateChunk()

generateChunk (   $chunkX,
  $chunkZ 
)
Parameters
$chunkX
$chunkZ
Returns
mixed|void
190  {
191  if($this->chunk === null){
192  if(isset($this->options["preset"]) and $this->options["preset"] != ""){
193  $this->parsePreset($this->options["preset"], $chunkX, $chunkZ);
194  }else{
195  $this->parsePreset($this->preset, $chunkX, $chunkZ);
196  }
197  }
198  $chunk = clone $this->chunk;
199  $chunk->setX($chunkX);
200  $chunk->setZ($chunkZ);
201  $this->level->setChunk($chunkX, $chunkZ, $chunk);
202  }

◆ getName()

getName ( )
Returns
string
61  : string{
62  return "flat";
63  }

◆ getSettings()

getSettings ( )
Returns
array
54  {
55  return $this->options;
56  }

◆ getSpawn()

getSpawn ( )
Returns
Vector3
221  {
222  return new Vector3(128, $this->floorLevel, 128);
223  }

◆ init()

init ( ChunkManager  $level,
Random  $random 
)
Parameters
ChunkManager$level
Random$random
Returns
mixed|void
170  {
171  $this->level = $level;
172  $this->random = $random;
173 
174  /*
175  // Commented out : We want to delay this
176  if(isset($this->options["preset"]) and $this->options["preset"] != ""){
177  $this->parsePreset($this->options["preset"]);
178  }else{
179  $this->parsePreset($this->preset);
180  }
181  */
182  }

◆ parseLayers()

static parseLayers ( string  $layers)
static
Parameters
string$layers
Returns
array
97  : array{
98  $result = [];
99  preg_match_all('#^(([0-9]*x|)([0-9]{1,3})(|:[0-9]{0,2}))$#m', str_replace(",", "\n", $layers), $matches);
100  $y = 0;
101  foreach($matches[3] as $i => $b){
102  $b = Item::fromString($b . $matches[4][$i]);
103  $cnt = $matches[2][$i] === "" ? 1 : intval($matches[2][$i]);
104  for($cY = $y, $y += $cnt; $cY < $y; ++$cY){
105  $result[$cY] = [$b->getId(), $b->getDamage()];
106  }
107  }
108 
109  return $result;
110  }

◆ parsePreset()

parsePreset (   $preset,
  $chunkX,
  $chunkZ 
)
protected
Parameters
$preset
$chunkX
$chunkZ
117  {
118  $this->preset = $preset;
119  $preset = explode(";", $preset);
120  $blocks = $preset[1] ?? "";
121  $biome = $preset[2] ?? 1;
122  $options = $preset[3] ?? "";
123  $this->structure = self::parseLayers($blocks);
124 
125  $this->chunks = [];
126 
127  $this->floorLevel = $y = count($this->structure);
128 
129  for(; $y < 0xFF; ++$y){
130  $this->structure[$y] = [0, 0];
131  }
132 
133 
134  $this->chunk = clone $this->level->getChunk($chunkX, $chunkZ);
135  $this->chunk->setGenerated();
136 
137  for($Z = 0; $Z < 16; ++$Z){
138  for($X = 0; $X < 16; ++$X){
139  $this->chunk->setBiomeId($X, $Z, $biome);
140  for($y = 0; $y < 128; ++$y){
141  $this->chunk->setBlock($X, $y, $Z, ...$this->structure[$y]);
142  }
143  }
144  }
145 
146 
147  preg_match_all('#(([0-9a-z_]{1,})\(?([0-9a-z_ =:]{0,})\)?),?#', $options, $matches);
148  foreach($matches[2] as $i => $option){
149  $params = true;
150  if($matches[3][$i] !== ""){
151  $params = [];
152  $p = explode(" ", $matches[3][$i]);
153  foreach($p as $k){
154  $k = explode("=", $k);
155  if(isset($k[1])){
156  $params[$k[0]] = $k[1];
157  }
158  }
159  }
160  $this->options[$option] = $params;
161  }
162  }

◆ populateChunk()

populateChunk (   $chunkX,
  $chunkZ 
)
Parameters
$chunkX
$chunkZ
Returns
mixed|void
210  {
211  $this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed());
212  foreach($this->populators as $populator){
213  $populator->populate($this->level, $chunkX, $chunkZ, $this->random);
214  }
215 
216  }

Field Documentation

◆ $chunks

$chunks

◆ $floorLevel

$floorLevel

◆ $options

$options

◆ $preset

$preset

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