Removed masks for Y coordinates, fixed bugs related to out-of-bounds coordinates, fixed #914 (#915)

This commit is contained in:
Dylan K. Taylor
2017-06-21 10:55:38 +01:00
committed by GitHub
parent 69ae37d191
commit 0f79b19fdc
6 changed files with 105 additions and 36 deletions

View File

@ -31,9 +31,11 @@ class SimpleChunkManager implements ChunkManager{
protected $chunks = [];
protected $seed;
protected $worldHeight;
public function __construct($seed){
public function __construct($seed, int $worldHeight = Level::Y_MAX){
$this->seed = $seed;
$this->worldHeight = $worldHeight;
}
/**
@ -159,4 +161,16 @@ class SimpleChunkManager implements ChunkManager{
public function getSeed(){
return $this->seed;
}
public function getWorldHeight() : int{
return $this->worldHeight;
}
public function isInWorld(float $x, float $y, float $z) : bool{
return (
$x <= INT32_MAX and $x >= INT32_MIN and
$y < $this->worldHeight and $y >= 0 and
$z <= INT32_MAX and $z >= INT32_MIN
);
}
}