mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 17:29:44 +00:00
World: prevent getHighestAdjacentBlockLight() and getHighestAdjacentBlockSkyLight() trying to exceed world bounds
this creates a problem for sky light above y=256, but this problem exists in lots of other places already anyway.
This commit is contained in:
parent
9d3637c999
commit
b8c857df64
@ -1354,14 +1354,21 @@ class World implements ChunkManager{
|
||||
* @return int
|
||||
*/
|
||||
public function getHighestAdjacentBlockSkyLight(int $x, int $y, int $z) : int{
|
||||
return max([
|
||||
$this->getBlockSkyLightAt($x + 1, $y, $z),
|
||||
$this->getBlockSkyLightAt($x - 1, $y, $z),
|
||||
$this->getBlockSkyLightAt($x, $y + 1, $z),
|
||||
$this->getBlockSkyLightAt($x, $y - 1, $z),
|
||||
$this->getBlockSkyLightAt($x, $y, $z + 1),
|
||||
$this->getBlockSkyLightAt($x, $y, $z - 1)
|
||||
]);
|
||||
$max = 0;
|
||||
foreach([
|
||||
[$x + 1, $y, $z],
|
||||
[$x - 1, $y, $z],
|
||||
[$x, $y + 1, $z],
|
||||
[$x, $y - 1, $z],
|
||||
[$x, $y, $z + 1],
|
||||
[$x, $y, $z - 1]
|
||||
] as [$x1, $y1, $z1]){
|
||||
if(!$this->isInWorld($x1, $y1, $z1)){
|
||||
continue;
|
||||
}
|
||||
$max = max($max, $this->getBlockSkyLightAt($x1, $y1, $z1));
|
||||
}
|
||||
return $max;
|
||||
}
|
||||
|
||||
public function updateBlockSkyLight(int $x, int $y, int $z){
|
||||
@ -1385,14 +1392,21 @@ class World implements ChunkManager{
|
||||
* @return int
|
||||
*/
|
||||
public function getHighestAdjacentBlockLight(int $x, int $y, int $z) : int{
|
||||
return max([
|
||||
$this->getBlockLightAt($x + 1, $y, $z),
|
||||
$this->getBlockLightAt($x - 1, $y, $z),
|
||||
$this->getBlockLightAt($x, $y + 1, $z),
|
||||
$this->getBlockLightAt($x, $y - 1, $z),
|
||||
$this->getBlockLightAt($x, $y, $z + 1),
|
||||
$this->getBlockLightAt($x, $y, $z - 1)
|
||||
]);
|
||||
$max = 0;
|
||||
foreach([
|
||||
[$x + 1, $y, $z],
|
||||
[$x - 1, $y, $z],
|
||||
[$x, $y + 1, $z],
|
||||
[$x, $y - 1, $z],
|
||||
[$x, $y, $z + 1],
|
||||
[$x, $y, $z - 1]
|
||||
] as [$x1, $y1, $z1]){
|
||||
if(!$this->isInWorld($x1, $y1, $z1)){
|
||||
continue;
|
||||
}
|
||||
$max = max($max, $this->getBlockLightAt($x1, $y1, $z1));
|
||||
}
|
||||
return $max;
|
||||
}
|
||||
|
||||
public function updateBlockLight(int $x, int $y, int $z){
|
||||
|
Loading…
x
Reference in New Issue
Block a user