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

Public Member Functions

 getWaterHeight ()
 
 __construct (array $settings=[])
 
 init (ChunkManager $level, Random $random)
 
 generateChunk ($chunkX, $chunkZ)
 
 populateChunk ($chunkX, $chunkZ)
 
 getSettings ()
 
 getName ()
 
 getSpawn ()
 

Static Public Member Functions

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  $settings = [])
abstract

Generator constructor.

Parameters
array$settings

Member Function Documentation

◆ addGenerator()

static addGenerator (   $object,
  $name 
)
static
Parameters
$object
$name
Returns
bool
42  {
43  if(is_subclass_of($object, Generator::class) and !isset(Generator::$list[$name = strtolower($name)])){
44  Generator::$list[$name] = $object;
45 
46  return true;
47  }
48 
49  return false;
50  }

◆ generateChunk()

generateChunk (   $chunkX,
  $chunkZ 
)
abstract
Parameters
$chunkX
$chunkZ
Returns
mixed

◆ getFastNoise1D()

static getFastNoise1D ( Noise  $noise,
  $xSize,
  $samplingRate,
  $x,
  $y,
  $z 
)
static
Parameters
Noise$noise
int$xSize
int$samplingRate
int$x
int$y
int$z
Returns
97  {
98  if($samplingRate === 0){
99  throw new \InvalidArgumentException("samplingRate cannot be 0");
100  }
101  if($xSize % $samplingRate !== 0){
102  throw new \InvalidArgumentCountException("xSize % samplingRate must return 0");
103  }
104 
105  $noiseArray = new \SplFixedArray($xSize + 1);
106 
107  for($xx = 0; $xx <= $xSize; $xx += $samplingRate){
108  $noiseArray[$xx] = $noise->noise3D($xx + $x, $y, $z);
109  }
110 
111  for($xx = 0; $xx < $xSize; ++$xx){
112  if($xx % $samplingRate !== 0){
113  $nx = (int) ($xx / $samplingRate) * $samplingRate;
114  $noiseArray[$xx] = Noise::linearLerp($xx, $nx, $nx + $samplingRate, $noiseArray[$nx], $noiseArray[$nx + $samplingRate]);
115  }
116  }
117 
118  return $noiseArray;
119  }

◆ getFastNoise2D()

static getFastNoise2D ( Noise  $noise,
  $xSize,
  $zSize,
  $samplingRate,
  $x,
  $y,
  $z 
)
static
Parameters
Noise$noise
int$xSize
int$zSize
int$samplingRate
int$x
int$y
int$z
Returns
132  {
133  if($samplingRate === 0){
134  throw new \InvalidArgumentException("samplingRate cannot be 0");
135  }
136  if($xSize % $samplingRate !== 0){
137  throw new \InvalidArgumentCountException("xSize % samplingRate must return 0");
138  }
139  if($zSize % $samplingRate !== 0){
140  throw new \InvalidArgumentCountException("zSize % samplingRate must return 0");
141  }
142 
143  $noiseArray = new \SplFixedArray($xSize + 1);
144 
145  for($xx = 0; $xx <= $xSize; $xx += $samplingRate){
146  $noiseArray[$xx] = new \SplFixedArray($zSize + 1);
147  for($zz = 0; $zz <= $zSize; $zz += $samplingRate){
148  $noiseArray[$xx][$zz] = $noise->noise3D($x + $xx, $y, $z + $zz);
149  }
150  }
151 
152  for($xx = 0; $xx < $xSize; ++$xx){
153  if($xx % $samplingRate !== 0){
154  $noiseArray[$xx] = new \SplFixedArray($zSize + 1);
155  }
156 
157  for($zz = 0; $zz < $zSize; ++$zz){
158  if($xx % $samplingRate !== 0 or $zz % $samplingRate !== 0){
159  $nx = (int) ($xx / $samplingRate) * $samplingRate;
160  $nz = (int) ($zz / $samplingRate) * $samplingRate;
161  $noiseArray[$xx][$zz] = Noise::bilinearLerp(
162  $xx, $zz, $noiseArray[$nx][$nz], $noiseArray[$nx][$nz + $samplingRate],
163  $noiseArray[$nx + $samplingRate][$nz], $noiseArray[$nx + $samplingRate][$nz + $samplingRate],
164  $nx, $nx + $samplingRate, $nz, $nz + $samplingRate
165  );
166  }
167  }
168  }
169 
170  return $noiseArray;
171  }

◆ getFastNoise3D()

static getFastNoise3D ( Noise  $noise,
  $xSize,
  $ySize,
  $zSize,
  $xSamplingRate,
  $ySamplingRate,
  $zSamplingRate,
  $x,
  $y,
  $z 
)
static
Parameters
Noise$noise
int$xSize
int$ySize
int$zSize
int$xSamplingRate
int$ySamplingRate
int$zSamplingRate
int$x
int$y
int$z
Returns
187  {
188  if($xSamplingRate === 0){
189  throw new \InvalidArgumentException("xSamplingRate cannot be 0");
190  }
191  if($zSamplingRate === 0){
192  throw new \InvalidArgumentException("zSamplingRate cannot be 0");
193  }
194  if($ySamplingRate === 0){
195  throw new \InvalidArgumentException("ySamplingRate cannot be 0");
196  }
197  if($xSize % $xSamplingRate !== 0){
198  throw new \InvalidArgumentCountException("xSize % xSamplingRate must return 0");
199  }
200  if($zSize % $zSamplingRate !== 0){
201  throw new \InvalidArgumentCountException("zSize % zSamplingRate must return 0");
202  }
203  if($ySize % $ySamplingRate !== 0){
204  throw new \InvalidArgumentCountException("ySize % ySamplingRate must return 0");
205  }
206 
207  $noiseArray = array_fill(0, $xSize + 1, array_fill(0, $zSize + 1, []));
208 
209  for($xx = 0; $xx <= $xSize; $xx += $xSamplingRate){
210  for($zz = 0; $zz <= $zSize; $zz += $zSamplingRate){
211  for($yy = 0; $yy <= $ySize; $yy += $ySamplingRate){
212  $noiseArray[$xx][$zz][$yy] = $noise->noise3D($x + $xx, $y + $yy, $z + $zz, true);
213  }
214  }
215  }
216 
217  for($xx = 0; $xx < $xSize; ++$xx){
218  for($zz = 0; $zz < $zSize; ++$zz){
219  for($yy = 0; $yy < $ySize; ++$yy){
220  if($xx % $xSamplingRate !== 0 or $zz % $zSamplingRate !== 0 or $yy % $ySamplingRate !== 0){
221  $nx = (int) ($xx / $xSamplingRate) * $xSamplingRate;
222  $ny = (int) ($yy / $ySamplingRate) * $ySamplingRate;
223  $nz = (int) ($zz / $zSamplingRate) * $zSamplingRate;
224 
225  $nnx = $nx + $xSamplingRate;
226  $nny = $ny + $ySamplingRate;
227  $nnz = $nz + $zSamplingRate;
228 
229  $dx1 = (($nnx - $xx) / ($nnx - $nx));
230  $dx2 = (($xx - $nx) / ($nnx - $nx));
231  $dy1 = (($nny - $yy) / ($nny - $ny));
232  $dy2 = (($yy - $ny) / ($nny - $ny));
233 
234  $noiseArray[$xx][$zz][$yy] = (($nnz - $zz) / ($nnz - $nz)) * (
235  $dy1 * (
236  $dx1 * $noiseArray[$nx][$nz][$ny] + $dx2 * $noiseArray[$nnx][$nz][$ny]
237  ) + $dy2 * (
238  $dx1 * $noiseArray[$nx][$nz][$nny] + $dx2 * $noiseArray[$nnx][$nz][$nny]
239  )
240  ) + (($zz - $nz) / ($nnz - $nz)) * (
241  $dy1 * (
242  $dx1 * $noiseArray[$nx][$nnz][$ny] + $dx2 * $noiseArray[$nnx][$nnz][$ny]
243  ) + $dy2 * (
244  $dx1 * $noiseArray[$nx][$nnz][$nny] + $dx2 * $noiseArray[$nnx][$nnz][$nny]
245  )
246  );
247  }
248  }
249  }
250  }
251 
252  return $noiseArray;
253  }

◆ getGenerator()

static getGenerator (   $name)
static
Parameters
$name
Returns
Generator
64  {
65  if(isset(Generator::$list[$name = strtolower($name)])){
66  return Generator::$list[$name];
67  }
68 
69  return Normal::class;
70  }

◆ getGeneratorList()

static getGeneratorList ( )
static
Returns
string[]
55  {
56  return array_keys(Generator::$list);
57  }

◆ getGeneratorName()

static getGeneratorName (   $class)
static
Parameters
$class
Returns
int|string
77  {
78  foreach(Generator::$list as $name => $c){
79  if($c === $class){
80  return $name;
81  }
82  }
83 
84  return "unknown";
85  }

◆ getName()

getName ( )
abstract

◆ getSettings()

getSettings ( )
abstract

◆ getSpawn()

getSpawn ( )
abstract

◆ getWaterHeight()

getWaterHeight ( )
Returns
int
258  : int{
259  return 0;
260  }

◆ init()

init ( ChunkManager  $level,
Random  $random 
)
abstract
Parameters
ChunkManager$level
Random$random
Returns
mixed

◆ populateChunk()

populateChunk (   $chunkX,
  $chunkZ 
)
abstract
Parameters
$chunkX
$chunkZ
Returns
mixed

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