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

Public Member Functions

 pickBiome ($x, $z)
 
 init (ChunkManager $level, Random $random)
 
 generateChunk ($chunkX, $chunkZ)
 
 populateChunk ($chunkX, $chunkZ)
 
 getSpawn ()
 
- Public Member Functions inherited from Normal
 __construct (array $options=[])
 
 getName ()
 
 getWaterHeight ()
 
 getSettings ()
 
 pickBiome ($x, $z)
 
 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 ()
 

Data Fields

const NAME = "Normal2"
 
- Data Fields inherited from Normal
const NAME = "Normal"
 

Protected Attributes

 $bedrockDepth = 5
 
- Protected Attributes inherited from Normal
 $populators = []
 
 $level
 
 $random
 
 $waterHeight = 62
 
 $bedrockDepth = 5
 
 $generationPopulators = []
 
 $noiseBase
 
 $selector
 

Additional Inherited Members

- 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)
 

Member Function Documentation

◆ generateChunk()

generateChunk (   $chunkX,
  $chunkZ 
)
177  {
178  $this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed());
179 
180  $seaFloorNoise = Generator::getFastNoise2D($this->noiseSeaFloor, 16, 16, 4, $chunkX * 16, 0, $chunkZ * 16);
181  $landNoise = Generator::getFastNoise2D($this->noiseLand, 16, 16, 4, $chunkX * 16, 0, $chunkZ * 16);
182  $mountainNoise = Generator::getFastNoise2D($this->noiseMountains, 16, 16, 4, $chunkX * 16, 0, $chunkZ * 16);
183  $baseNoise = Generator::getFastNoise2D($this->noiseBaseGround, 16, 16, 4, $chunkX * 16, 0, $chunkZ * 16);
184  $riverNoise = Generator::getFastNoise2D($this->noiseRiver, 16, 16, 4, $chunkX * 16, 0, $chunkZ * 16);
185 
186  $chunk = $this->level->getChunk($chunkX, $chunkZ);
187 
188  for($genx = 0; $genx < 16; $genx++){
189  for($genz = 0; $genz < 16; $genz++){
190  $canBaseGround = false;
191  $canRiver = true;
192 
193  //using a quadratic function which smooth the world
194  //y = (2.956x)^2 - 0.6, (0 <= x <= 2)
195  $landHeightNoise = $landNoise[$genx][$genz] + 1;
196  $landHeightNoise *= 2.956;
197  $landHeightNoise = $landHeightNoise * $landHeightNoise;
198  $landHeightNoise = $landHeightNoise - 0.6;
199  $landHeightNoise = $landHeightNoise > 0 ? $landHeightNoise : 0;
200 
201  //generate mountains
202  $mountainHeightGenerate = $mountainNoise[$genx][$genz] - 0.2;
203  $mountainHeightGenerate = $mountainHeightGenerate > 0 ? $mountainHeightGenerate : 0;
204  $mountainGenerate = (int) ($this->mountainHeight * $mountainHeightGenerate);
205 
206  $landHeightGenerate = (int) ($this->landHeightRange * $landHeightNoise);
207  if($landHeightGenerate > $this->landHeightRange){
208  if($landHeightGenerate > $this->landHeightRange){
209  $canBaseGround = true;
210  }
211  $landHeightGenerate = $this->landHeightRange;
212  }
213 
214  $genyHeight = $this->seaFloorHeight + $landHeightGenerate;
215  $genyHeight += $mountainGenerate;
216 
217  //prepare for generate ocean, desert, and land
218  if($genyHeight < $this->beathStartHeight){
219  if($genyHeight < $this->beathStartHeight - 5){
220  $genyHeight += (int) ($this->seaFloorGenerateRange * $seaFloorNoise[$genx][$genz]);
221  }
222  $biome = Biome::getBiome(Biome::OCEAN);
223  if($genyHeight < $this->seaFloorHeight - $this->seaFloorGenerateRange){
224  $genyHeight = $this->seaFloorHeight;
225  }
226  $canRiver = false;
227  }else if($genyHeight <= $this->beathStopHeight && $genyHeight >= $this->beathStartHeight){
228  $biome = Biome::getBiome(Biome::BEACH);
229  }else{
230  $biome = $this->pickBiome($chunkX * 16 + $genx, $chunkZ * 16 + $genz);
231  if($canBaseGround){
232  $baseGroundHeight = (int) ($this->landHeightRange * $landHeightNoise) - $this->landHeightRange;
233  $baseGroundHeight2 = (int) ($this->basegroundHeight * ($baseNoise[$genx][$genz] + 1));
234  if($baseGroundHeight2 > $baseGroundHeight) $baseGroundHeight2 = $baseGroundHeight;
235  if($baseGroundHeight2 > $mountainGenerate)
236  $baseGroundHeight2 = $baseGroundHeight2 - $mountainGenerate;
237  else $baseGroundHeight2 = 0;
238  $genyHeight += $baseGroundHeight2;
239  }
240  }
241  if($canRiver && $genyHeight <= $this->seaHeight - 5){
242  $canRiver = false;
243  }
244  //generate river
245  if($canRiver){
246  $riverGenerate = $riverNoise[$genx][$genz];
247  if($riverGenerate > -0.25 && $riverGenerate < 0.25){
248  $riverGenerate = $riverGenerate > 0 ? $riverGenerate : -$riverGenerate;
249  $riverGenerate = 0.25 - $riverGenerate;
250  //y=x^2 * 4 - 0.0000001
251  $riverGenerate = $riverGenerate * $riverGenerate * 4;
252  //smooth again
253  $riverGenerate = $riverGenerate - 0.0000001;
254  $riverGenerate = $riverGenerate > 0 ? $riverGenerate : 0;
255  $genyHeight -= $riverGenerate * 64;
256  if($genyHeight < $this->seaHeight){
257  $biome = Biome::getBiome(Biome::RIVER);
258  //to generate river floor
259  if($genyHeight <= $this->seaHeight - 8){
260  $genyHeight1 = $this->seaHeight - 9 + (int) ($this->basegroundHeight * ($baseNoise[$genx][$genz] + 1));
261  $genyHeight2 = $genyHeight < $this->seaHeight - 7 ? $this->seaHeight - 7 : $genyHeight;
262  $genyHeight = $genyHeight1 > $genyHeight2 ? $genyHeight1 : $genyHeight2;
263  }
264  }
265  }
266  }
267  $chunk->setBiomeId($genx, $genz, $biome->getId());
268 
269  //generating
270  $generateHeight = $genyHeight > $this->seaHeight ? $genyHeight : $this->seaHeight;
271  for($geny = 0; $geny <= $generateHeight; $geny++){
272  if($geny <= $this->bedrockDepth && ($geny == 0 or $this->random->nextRange(1, 5) == 1)){
273  $chunk->setBlockId($genx, $geny, $genz, Block::BEDROCK);
274  }elseif($geny > $genyHeight){
275  if(($biome->getId() == Biome::ICE_PLAINS or $biome->getId() == Biome::TAIGA) and $geny == $this->seaHeight){
276  $chunk->setBlockId($genx, $geny, $genz, Block::ICE);
277  }else{
278  $chunk->setBlockId($genx, $geny, $genz, Block::STILL_WATER);
279  }
280  }else{
281  $chunk->setBlockId($genx, $geny, $genz, Block::STONE);
282  }
283  }
284  }
285  }
286 
287  //populator chunk
288  foreach($this->generationPopulators as $populator){
289  $populator->populate($this->level, $chunkX, $chunkZ, $this->random);
290  }
291 
292  }

◆ getSpawn()

getSpawn ( )
306  {
307  return new Vector3(127.5, 128, 127.5);
308  }

◆ init()

init ( ChunkManager  $level,
Random  $random 
)
89  {
90  $this->level = $level;
91  $this->random = $random;
92  $this->random->setSeed($this->level->getSeed());
93  $this->noiseSeaFloor = new Simplex($this->random, 1, 1 / 8, 1 / 64);
94  $this->noiseLand = new Simplex($this->random, 2, 1 / 8, 1 / 512);
95  $this->noiseMountains = new Simplex($this->random, 4, 1, 1 / 500);
96  $this->noiseBaseGround = new Simplex($this->random, 4, 1 / 4, 1 / 64);
97  $this->noiseRiver = new Simplex($this->random, 2, 1, 1 / 512);
98  $this->random->setSeed($this->level->getSeed());
99  $this->selector = new BiomeSelector($this->random, function($temperature, $rainfall){
100  if($rainfall < 0.25){
101  if($temperature < 0.7){
102  return Biome::OCEAN;
103  }elseif($temperature < 0.85){
104  return Biome::RIVER;
105  }else{
106  return Biome::SWAMP;
107  }
108  }elseif($rainfall < 0.60){
109  if($temperature < 0.25){
110  return Biome::ICE_PLAINS;
111  }elseif($temperature < 0.75){
112  return Biome::PLAINS;
113  }else{
114  return Biome::DESERT;
115  }
116  }elseif($rainfall < 0.80){
117  if($temperature < 0.25){
118  return Biome::TAIGA;
119  }elseif($temperature < 0.75){
120  return Biome::FOREST;
121  }else{
122  return Biome::BIRCH_FOREST;
123  }
124  }else{
125  if($temperature < 0.25){
126  return Biome::MOUNTAINS;
127  }elseif($temperature < 0.70){
128  return Biome::SMALL_MOUNTAINS;
129  }else{
130  return Biome::RIVER;
131  }
132  }
134 
135  $this->heightOffset = $random->nextRange(-5, 3);
136 
137  $this->selector->addBiome(Biome::getBiome(Biome::OCEAN));
138  $this->selector->addBiome(Biome::getBiome(Biome::PLAINS));
139  $this->selector->addBiome(Biome::getBiome(Biome::DESERT));
140  $this->selector->addBiome(Biome::getBiome(Biome::MOUNTAINS));
141  $this->selector->addBiome(Biome::getBiome(Biome::FOREST));
142  $this->selector->addBiome(Biome::getBiome(Biome::TAIGA));
143  $this->selector->addBiome(Biome::getBiome(Biome::SWAMP));
144  $this->selector->addBiome(Biome::getBiome(Biome::RIVER));
145  $this->selector->addBiome(Biome::getBiome(Biome::ICE_PLAINS));
146  $this->selector->addBiome(Biome::getBiome(Biome::SMALL_MOUNTAINS));
147  $this->selector->addBiome(Biome::getBiome(Biome::BIRCH_FOREST));
148  $this->selector->addBiome(Biome::getBiome(Biome::BEACH));
149  $this->selector->addBiome(Biome::getBiome(Biome::MESA));
150 
151  $this->selector->recalculate();
152 
153  $cover = new GroundCover();
154  $this->generationPopulators[] = $cover;
155 
156  $cave = new Cave();
157  $this->populators[] = $cave;
158 
159  $ores = new Ore();
160  $ores->setOreTypes([
161  new OreType(new CoalOre(), 20, 17, 0, 128),
162  new OreType(new IronOre(), 20, 9, 0, 64),
163  new OreType(new RedstoneOre(), 8, 8, 0, 16),
164  new OreType(new LapisOre(), 1, 7, 0, 16),
165  new OreType(new GoldOre(), 2, 9, 0, 32),
166  new OreType(new DiamondOre(), 1, 8, 0, 16),
167  new OreType(new Dirt(), 10, 33, 0, 128),
168  new OreType(new Gravel(), 8, 33, 0, 128),
169  new OreType(new Stone(Stone::GRANITE), 10, 33, 0, 80),
170  new OreType(new Stone(Stone::DIORITE), 10, 33, 0, 80),
171  new OreType(new Stone(Stone::ANDESITE), 10, 33, 0, 80)
172  ]);
173  $this->populators[] = $ores;
174  }

◆ pickBiome()

pickBiome (   $x,
  $z 
)
71  : Biome{
72  $hash = $x * 2345803 ^ $z * 9236449 ^ $this->level->getSeed();
73  $hash *= $hash + 223;
74 
75  $xNoise = $hash >> 20 & 3;
76  $zNoise = $hash >> 22 & 3;
77 
78  if($xNoise == 3){
79  $xNoise = 1;
80  }
81  if($zNoise == 3){
82  $zNoise = 1;
83  }
84 
85  return $this->selector->pickBiome($x + $xNoise - 1, $z + $zNoise - 1);
86  }

◆ populateChunk()

populateChunk (   $chunkX,
  $chunkZ 
)
295  {
296  $this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed());
297  foreach($this->populators as $populator){
298  $populator->populate($this->level, $chunkX, $chunkZ, $this->random);
299  }
300 
301  $chunk = $this->level->getChunk($chunkX, $chunkZ);
302  $biome = Biome::getBiome($chunk->getBiomeId(7, 7));
303  $biome->populateChunk($this->level, $chunkX, $chunkZ, $this->random);
304  }

Field Documentation

◆ $bedrockDepth

$bedrockDepth = 5
protected

◆ NAME

const NAME = "Normal2"

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