mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-05 17:36:12 +00:00
PHP7 to master
This commit is contained in:
@ -123,15 +123,10 @@ abstract class Generator{
|
||||
* @throws \InvalidArgumentCountException
|
||||
*/
|
||||
public static function getFastNoise2D(Noise $noise, $xSize, $zSize, $samplingRate, $x, $y, $z){
|
||||
if($samplingRate === 0){
|
||||
throw new \InvalidArgumentException("samplingRate cannot be 0");
|
||||
}
|
||||
if ($xSize % $samplingRate !== 0) {
|
||||
throw new \InvalidArgumentCountException("xSize % samplingRate must return 0");
|
||||
}
|
||||
if ($zSize % $samplingRate !== 0) {
|
||||
throw new \InvalidArgumentCountException("zSize % samplingRate must return 0");
|
||||
}
|
||||
assert($samplingRate !== 0, new \InvalidArgumentException("samplingRate cannot be 0"));
|
||||
|
||||
assert($xSize % $samplingRate === 0, new \InvalidArgumentCountException("xSize % samplingRate must return 0"));
|
||||
assert($zSize % $samplingRate === 0, new \InvalidArgumentCountException("zSize % samplingRate must return 0"));
|
||||
|
||||
$noiseArray = new \SplFixedArray($xSize + 1);
|
||||
|
||||
@ -181,24 +176,14 @@ abstract class Generator{
|
||||
* @throws \InvalidArgumentCountException
|
||||
*/
|
||||
public static function getFastNoise3D(Noise $noise, $xSize, $ySize, $zSize, $xSamplingRate, $ySamplingRate, $zSamplingRate, $x, $y, $z){
|
||||
if($xSamplingRate === 0){
|
||||
throw new \InvalidArgumentException("xSamplingRate cannot be 0");
|
||||
}
|
||||
if($zSamplingRate === 0){
|
||||
throw new \InvalidArgumentException("zSamplingRate cannot be 0");
|
||||
}
|
||||
if($ySamplingRate === 0){
|
||||
throw new \InvalidArgumentException("ySamplingRate cannot be 0");
|
||||
}
|
||||
if ($xSize % $xSamplingRate !== 0) {
|
||||
throw new \InvalidArgumentCountException("xSize % xSamplingRate must return 0");
|
||||
}
|
||||
if ($zSize % $zSamplingRate !== 0) {
|
||||
throw new \InvalidArgumentCountException("zSize % zSamplingRate must return 0");
|
||||
}
|
||||
if ($ySize % $ySamplingRate !== 0) {
|
||||
throw new \InvalidArgumentCountException("ySize % ySamplingRate must return 0");
|
||||
}
|
||||
|
||||
assert($xSamplingRate !== 0, new \InvalidArgumentException("xSamplingRate cannot be 0"));
|
||||
assert($zSamplingRate !== 0, new \InvalidArgumentException("zSamplingRate cannot be 0"));
|
||||
assert($ySamplingRate !== 0, new \InvalidArgumentException("ySamplingRate cannot be 0"));
|
||||
|
||||
assert($xSize % $xSamplingRate === 0, new \InvalidArgumentCountException("xSize % xSamplingRate must return 0"));
|
||||
assert($zSize % $zSamplingRate === 0, new \InvalidArgumentCountException("zSize % zSamplingRate must return 0"));
|
||||
assert($ySize % $ySamplingRate === 0, new \InvalidArgumentCountException("ySize % ySamplingRate must return 0"));
|
||||
|
||||
$noiseArray = array_fill(0, $xSize + 1, array_fill(0, $zSize + 1, []));
|
||||
|
||||
|
@ -39,7 +39,7 @@ class GeneratorRegisterTask extends AsyncTask{
|
||||
|
||||
public function __construct(Level $level, Generator $generator){
|
||||
$this->generator = get_class($generator);
|
||||
$this->settings = $generator->getSettings();
|
||||
$this->settings = serialize($generator->getSettings());
|
||||
$this->seed = $level->getSeed();
|
||||
$this->levelId = $level->getId();
|
||||
}
|
||||
@ -51,7 +51,7 @@ class GeneratorRegisterTask extends AsyncTask{
|
||||
$this->saveToThreadStore("generation.level{$this->levelId}.manager", $manager);
|
||||
/** @var Generator $generator */
|
||||
$generator = $this->generator;
|
||||
$generator = new $generator($this->settings);
|
||||
$generator = new $generator(unserialize($this->settings));
|
||||
$generator->init($manager, new Random($manager->getSeed()));
|
||||
$this->saveToThreadStore("generation.level{$this->levelId}.generator", $generator);
|
||||
}
|
||||
|
Reference in New Issue
Block a user