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

Public Member Functions

 __construct (Random $random, callable $lookup, Biome $fallback)
 
 recalculate ()
 
 addBiome (Biome $biome)
 
 getTemperature ($x, $z)
 
 getRainfall ($x, $z)
 
 pickBiome ($x, $z)
 

Constructor & Destructor Documentation

◆ __construct()

__construct ( Random  $random,
callable  $lookup,
Biome  $fallback 
)
44  {
45  $this->fallback = $fallback;
46  $this->lookup = $lookup;
47  $this->temperature = new Simplex($random, 2, 1 / 16, 1 / 512);
48  $this->rainfall = new Simplex($random, 2, 1 / 16, 1 / 512);
49  }

Member Function Documentation

◆ addBiome()

addBiome ( Biome  $biome)
61  {
62  $this->biomes[$biome->getId()] = $biome;
63  }

◆ getRainfall()

getRainfall (   $x,
  $z 
)
69  {
70  return ($this->rainfall->noise2D($x, $z, true) + 1) / 2;
71  }

◆ getTemperature()

getTemperature (   $x,
  $z 
)
65  {
66  return ($this->temperature->noise2D($x, $z, true) + 1) / 2;
67  }

◆ pickBiome()

pickBiome (   $x,
  $z 
)
Parameters
$x
$z
Returns
Biome
79  {
80  $temperature = (int) ($this->getTemperature($x, $z) * 63);
81  $rainfall = (int) ($this->getRainfall($x, $z) * 63);
82 
83  $biomeId = $this->map[$temperature + ($rainfall << 6)];
84  return isset($this->biomes[$biomeId]) ? $this->biomes[$biomeId] : $this->fallback;
85  }

◆ recalculate()

recalculate ( )
51  {
52  $this->map = new \SplFixedArray(64 * 64);
53 
54  for($i = 0; $i < 64; ++$i){
55  for($j = 0; $j < 64; ++$j){
56  $this->map[$i + ($j << 6)] = call_user_func($this->lookup, $i / 63, $j / 63);
57  }
58  }
59  }

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