mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-13 15:05:33 +00:00
World: Rearrange some light-related methods
these things are all over the place ...
This commit is contained in:
parent
5dfa6a2296
commit
f29ababf8d
@ -1215,19 +1215,6 @@ class World implements ChunkManager{
|
|||||||
return $collides;
|
return $collides;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFullLight(Vector3 $pos) : int{
|
|
||||||
return $this->getFullLightAt($pos->x, $pos->y, $pos->z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFullLightAt(int $x, int $y, int $z) : int{
|
|
||||||
$skyLight = $this->getRealBlockSkyLightAt($x, $y, $z);
|
|
||||||
if($skyLight < 15){
|
|
||||||
return max($skyLight, $this->getBlockLightAt($x, $y, $z));
|
|
||||||
}else{
|
|
||||||
return $skyLight;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes the percentage of a circle away from noon the sun is currently at. This can be multiplied by 2 * M_PI to
|
* Computes the percentage of a circle away from noon the sun is currently at. This can be multiplied by 2 * M_PI to
|
||||||
* get an angle in radians, or by 360 to get an angle in degrees.
|
* get an angle in radians, or by 360 to get an angle in degrees.
|
||||||
@ -1285,6 +1272,34 @@ class World implements ChunkManager{
|
|||||||
return $this->skyLightReduction;
|
return $this->skyLightReduction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getFullLight(Vector3 $pos) : int{
|
||||||
|
return $this->getFullLightAt($pos->x, $pos->y, $pos->z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFullLightAt(int $x, int $y, int $z) : int{
|
||||||
|
$skyLight = $this->getRealBlockSkyLightAt($x, $y, $z);
|
||||||
|
if($skyLight < 15){
|
||||||
|
return max($skyLight, $this->getBlockLightAt($x, $y, $z));
|
||||||
|
}else{
|
||||||
|
return $skyLight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the raw block skylight level
|
||||||
|
*
|
||||||
|
* @return int 0-15
|
||||||
|
*/
|
||||||
|
public function getPotentialBlockSkyLightAt(int $x, int $y, int $z) : int{
|
||||||
|
if(!$this->isInWorld($x, $y, $z)){
|
||||||
|
return $y >= self::Y_MAX ? 15 : 0;
|
||||||
|
}
|
||||||
|
if(($chunk = $this->getChunk($x >> 4, $z >> 4)) !== null && $chunk->isLightPopulated() === true){
|
||||||
|
return $chunk->getSubChunk($y >> 4)->getBlockSkyLightArray()->get($x & 0x0f, $y & 0xf, $z & 0x0f);
|
||||||
|
}
|
||||||
|
return 0; //TODO: this should probably throw instead (light not calculated yet)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the sky light level at the specified coordinates, offset by the current time and weather.
|
* Returns the sky light level at the specified coordinates, offset by the current time and weather.
|
||||||
*
|
*
|
||||||
@ -1295,6 +1310,21 @@ class World implements ChunkManager{
|
|||||||
return $light < 0 ? 0 : $light;
|
return $light < 0 ? 0 : $light;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the raw block light level
|
||||||
|
*
|
||||||
|
* @return int 0-15
|
||||||
|
*/
|
||||||
|
public function getBlockLightAt(int $x, int $y, int $z) : int{
|
||||||
|
if(!$this->isInWorld($x, $y, $z)){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if(($chunk = $this->getChunk($x >> 4, $z >> 4)) !== null && $chunk->isLightPopulated() === true){
|
||||||
|
return $chunk->getSubChunk($y >> 4)->getBlockLightArray()->get($x & 0x0f, $y & 0xf, $z & 0x0f);
|
||||||
|
}
|
||||||
|
return 0; //TODO: this should probably throw instead (light not calculated yet)
|
||||||
|
}
|
||||||
|
|
||||||
public function updateAllLight(int $x, int $y, int $z) : void{
|
public function updateAllLight(int $x, int $y, int $z) : void{
|
||||||
if(($chunk = $this->getChunk($x >> 4, $z >> 4)) === null || $chunk->isLightPopulated() !== true){
|
if(($chunk = $this->getChunk($x >> 4, $z >> 4)) === null || $chunk->isLightPopulated() !== true){
|
||||||
$this->logger->debug("Skipped runtime light update of x=$x,y=$y,z=$z because the target area has not received base light calculation");
|
$this->logger->debug("Skipped runtime light update of x=$x,y=$y,z=$z because the target area has not received base light calculation");
|
||||||
@ -1937,36 +1967,6 @@ class World implements ChunkManager{
|
|||||||
return ($chunk = $this->loadChunk($x >> 4, $z >> 4)) !== null ? $chunk->getTile($x & 0x0f, $y, $z & 0x0f) : null;
|
return ($chunk = $this->loadChunk($x >> 4, $z >> 4)) !== null ? $chunk->getTile($x & 0x0f, $y, $z & 0x0f) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the raw block skylight level
|
|
||||||
*
|
|
||||||
* @return int 0-15
|
|
||||||
*/
|
|
||||||
public function getPotentialBlockSkyLightAt(int $x, int $y, int $z) : int{
|
|
||||||
if(!$this->isInWorld($x, $y, $z)){
|
|
||||||
return $y >= self::Y_MAX ? 15 : 0;
|
|
||||||
}
|
|
||||||
if(($chunk = $this->getChunk($x >> 4, $z >> 4)) !== null && $chunk->isLightPopulated() === true){
|
|
||||||
return $chunk->getSubChunk($y >> 4)->getBlockSkyLightArray()->get($x & 0x0f, $y & 0xf, $z & 0x0f);
|
|
||||||
}
|
|
||||||
return 0; //TODO: this should probably throw instead (light not calculated yet)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the raw block light level
|
|
||||||
*
|
|
||||||
* @return int 0-15
|
|
||||||
*/
|
|
||||||
public function getBlockLightAt(int $x, int $y, int $z) : int{
|
|
||||||
if(!$this->isInWorld($x, $y, $z)){
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if(($chunk = $this->getChunk($x >> 4, $z >> 4)) !== null && $chunk->isLightPopulated() === true){
|
|
||||||
return $chunk->getSubChunk($y >> 4)->getBlockLightArray()->get($x & 0x0f, $y & 0xf, $z & 0x0f);
|
|
||||||
}
|
|
||||||
return 0; //TODO: this should probably throw instead (light not calculated yet)
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getBiomeId(int $x, int $z) : int{
|
public function getBiomeId(int $x, int $z) : int{
|
||||||
if(($chunk = $this->loadChunk($x >> 4, $z >> 4)) !== null){
|
if(($chunk = $this->loadChunk($x >> 4, $z >> 4)) !== null){
|
||||||
return $chunk->getBiomeId($x & 0x0f, $z & 0x0f);
|
return $chunk->getBiomeId($x & 0x0f, $z & 0x0f);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user