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

Public Member Functions

 __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 = "Normal"
 

Protected Attributes

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

Constructor & Destructor Documentation

◆ __construct()

__construct ( array  $options = [])
76  {
77  if(self::$GAUSSIAN_KERNEL === null){
78  self::generateKernel();
79  }
80  }

Member Function Documentation

◆ generateChunk()

generateChunk (   $chunkX,
  $chunkZ 
)
207  {
208  $this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed());
209 
210  $noise = Generator::getFastNoise3D($this->noiseBase, 16, 128, 16, 4, 8, 4, $chunkX * 16, 0, $chunkZ * 16);
211 
212  $chunk = $this->level->getChunk($chunkX, $chunkZ);
213 
214  $biomeCache = [];
215 
216  for($x = 0; $x < 16; ++$x){
217  for($z = 0; $z < 16; ++$z){
218  $minSum = 0;
219  $maxSum = 0;
220  $weightSum = 0;
221 
222  $biome = $this->pickBiome($chunkX * 16 + $x, $chunkZ * 16 + $z);
223  $chunk->setBiomeId($x, $z, $biome->getId());
224 
225  for($sx = -self::$SMOOTH_SIZE; $sx <= self::$SMOOTH_SIZE; ++$sx){
226  for($sz = -self::$SMOOTH_SIZE; $sz <= self::$SMOOTH_SIZE; ++$sz){
227 
228  $weight = self::$GAUSSIAN_KERNEL[$sx + self::$SMOOTH_SIZE][$sz + self::$SMOOTH_SIZE];
229 
230  if($sx === 0 and $sz === 0){
231  $adjacent = $biome;
232  }else{
233  $index = Level::chunkHash($chunkX * 16 + $x + $sx, $chunkZ * 16 + $z + $sz);
234  if(isset($biomeCache[$index])){
235  $adjacent = $biomeCache[$index];
236  }else{
237  $biomeCache[$index] = $adjacent = $this->pickBiome($chunkX * 16 + $x + $sx, $chunkZ * 16 + $z + $sz);
238  }
239  }
240 
241  $minSum += ($adjacent->getMinElevation() - 1) * $weight;
242  $maxSum += $adjacent->getMaxElevation() * $weight;
243 
244  $weightSum += $weight;
245  }
246  }
247 
248  $minSum /= $weightSum;
249  $maxSum /= $weightSum;
250 
251  $solidLand = false;
252  for($y = 127; $y >= 0; --$y){
253  if($y === 0){
254  $chunk->setBlockId($x, $y, $z, Block::BEDROCK);
255  continue;
256  }
257 
258  // A noiseAdjustment of 1 will guarantee ground, a noiseAdjustment of -1 will guarantee air.
259  //$effHeight = min($y - $smoothHeight - $minSum,
260  $noiseAdjustment = 2 * (($maxSum - $y) / ($maxSum - $minSum)) - 1;
261 
262 
263  // To generate caves, we bring the noiseAdjustment down away from 1.
264  $caveLevel = $minSum - 10;
265  $distAboveCaveLevel = max(0, $y - $caveLevel); // must be positive
266 
267  $noiseAdjustment = min($noiseAdjustment, 0.4 + ($distAboveCaveLevel / 10));
268  $noiseValue = $noise[$x][$z][$y] + $noiseAdjustment;
269 
270  if($noiseValue > 0){
271  $chunk->setBlockId($x, $y, $z, Block::STONE);
272  $solidLand = true;
273  }elseif($y <= $this->waterHeight && $solidLand == false){
274  $chunk->setBlockId($x, $y, $z, Block::STILL_WATER);
275  }
276  }
277  }
278  }
279 
280  foreach($this->generationPopulators as $populator){
281  $populator->populate($this->level, $chunkX, $chunkZ, $this->random);
282  }
283  }

◆ getName()

getName ( )
99  : string{
100  return self::NAME;
101  }

◆ getSettings()

getSettings ( )
107  {
108  return [];
109  }

◆ getSpawn()

getSpawn ( )
296  {
297  return new Vector3(127.5, 128, 127.5);
298  }

◆ getWaterHeight()

getWaterHeight ( )
103  : int{
104  return $this->waterHeight;
105  }

◆ init()

init ( ChunkManager  $level,
Random  $random 
)
126  {
127  $this->level = $level;
128  $this->random = $random;
129  $this->random->setSeed($this->level->getSeed());
130  $this->noiseBase = new Simplex($this->random, 4, 1 / 4, 1 / 32);
131  $this->random->setSeed($this->level->getSeed());
132  $this->selector = new BiomeSelector($this->random, function($temperature, $rainfall){
133  if($rainfall < 0.25){
134  if($temperature < 0.7){
135  return Biome::OCEAN;
136  }elseif($temperature < 0.85){
137  return Biome::RIVER;
138  }else{
139  return Biome::SWAMP;
140  }
141  }elseif($rainfall < 0.60){
142  if($temperature < 0.25){
143  return Biome::ICE_PLAINS;
144  }elseif($temperature < 0.75){
145  return Biome::PLAINS;
146  }else{
147  return Biome::DESERT;
148  }
149  }elseif($rainfall < 0.80){
150  if($temperature < 0.25){
151  return Biome::TAIGA;
152  }elseif($temperature < 0.75){
153  return Biome::FOREST;
154  }else{
155  return Biome::BIRCH_FOREST;
156  }
157  }else{
158  if($temperature < 0.25){
159  return Biome::MOUNTAINS;
160  }elseif($temperature < 0.70){
161  return Biome::SMALL_MOUNTAINS;
162  }else{
163  return Biome::RIVER;
164  }
165  }
167 
168  $this->selector->addBiome(Biome::getBiome(Biome::OCEAN));
169  $this->selector->addBiome(Biome::getBiome(Biome::PLAINS));
170  $this->selector->addBiome(Biome::getBiome(Biome::DESERT));
171  $this->selector->addBiome(Biome::getBiome(Biome::MOUNTAINS));
172  $this->selector->addBiome(Biome::getBiome(Biome::FOREST));
173  $this->selector->addBiome(Biome::getBiome(Biome::TAIGA));
174  $this->selector->addBiome(Biome::getBiome(Biome::SWAMP));
175  $this->selector->addBiome(Biome::getBiome(Biome::RIVER));
176  $this->selector->addBiome(Biome::getBiome(Biome::ICE_PLAINS));
177  $this->selector->addBiome(Biome::getBiome(Biome::SMALL_MOUNTAINS));
178  $this->selector->addBiome(Biome::getBiome(Biome::BIRCH_FOREST));
179  $this->selector->addBiome(Biome::getBiome(Biome::BEACH));
180  $this->selector->addBiome(Biome::getBiome(Biome::MESA));
181 
182  $this->selector->recalculate();
183 
184  $cover = new GroundCover();
185  $this->generationPopulators[] = $cover;
186 
187  $cave = new Cave();
188  $this->populators[] = $cave;
189 
190  $ores = new Ore();
191  $ores->setOreTypes([
192  new OreType(new CoalOre(), 20, 16, 0, 128),
193  new OreType(New IronOre(), 20, 8, 0, 64),
194  new OreType(new RedstoneOre(), 8, 7, 0, 16),
195  new OreType(new LapisOre(), 1, 6, 0, 32),
196  new OreType(new GoldOre(), 2, 8, 0, 32),
197  new OreType(new DiamondOre(), 1, 7, 0, 16),
198  new OreType(new Dirt(), 20, 32, 0, 128),
199  new OreType(new Stone(Stone::GRANITE), 20, 32, 0, 128),
200  new OreType(new Stone(Stone::DIORITE), 20, 32, 0, 128),
201  new OreType(new Stone(Stone::ANDESITE), 20, 32, 0, 128),
202  new OreType(new Gravel(), 10, 16, 0, 128)
203  ]);
204  $this->populators[] = $ores;
205  }

◆ pickBiome()

pickBiome (   $x,
  $z 
)
111  {
112  $hash = $x * 2345803 ^ $z * 9236449 ^ $this->level->getSeed();
113  $hash *= $hash + 223;
114  $xNoise = $hash >> 20 & 3;
115  $zNoise = $hash >> 22 & 3;
116  if($xNoise == 3){
117  $xNoise = 1;
118  }
119  if($zNoise == 3){
120  $zNoise = 1;
121  }
122 
123  return $this->selector->pickBiome($x + $xNoise - 1, $z + $zNoise - 1);
124  }

◆ populateChunk()

populateChunk (   $chunkX,
  $chunkZ 
)
285  {
286  $this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed());
287  foreach($this->populators as $populator){
288  $populator->populate($this->level, $chunkX, $chunkZ, $this->random);
289  }
290 
291  $chunk = $this->level->getChunk($chunkX, $chunkZ);
292  $biome = Biome::getBiome($chunk->getBiomeId(7, 7));
293  $biome->populateChunk($this->level, $chunkX, $chunkZ, $this->random);
294  }

Field Documentation

◆ $bedrockDepth

$bedrockDepth = 5
protected

◆ $generationPopulators

$generationPopulators = []
protected

◆ $level

$level
protected

◆ $noiseBase

$noiseBase
protected

◆ $populators

$populators = []
protected

◆ $random

$random
protected

◆ $selector

$selector
protected

◆ $waterHeight

$waterHeight = 62
protected

◆ NAME

const NAME = "Normal"

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