mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-03 16:45:13 +00:00
Added some asserts
This commit is contained in:
@ -78,9 +78,7 @@ class Position extends Vector3{
|
||||
* @throws LevelException
|
||||
*/
|
||||
public function getSide($side, $step = 1){
|
||||
if(!$this->isValid()){
|
||||
throw new LevelException("Undefined Level reference");
|
||||
}
|
||||
assert($this->isValid());
|
||||
|
||||
return Position::fromObject(parent::getSide($side, $step), $this->level);
|
||||
}
|
||||
|
@ -118,15 +118,10 @@ abstract class Generator{
|
||||
* @return \SplFixedArray
|
||||
*/
|
||||
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);
|
||||
|
||||
@ -173,24 +168,14 @@ abstract class Generator{
|
||||
* @return \SplFixedArray
|
||||
*/
|
||||
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, []));
|
||||
|
||||
|
Reference in New Issue
Block a user