World: added getHighestAdjacentFullLightAt()

This commit is contained in:
Dylan K. Taylor 2021-04-18 20:20:08 +01:00
parent 51b0685881
commit 53ebe4f9f9
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
3 changed files with 12 additions and 22 deletions

View File

@ -69,10 +69,7 @@ class FrostedIce extends Ice{
public function onRandomTick() : void{
if((!$this->checkAdjacentBlocks(4) or mt_rand(0, 2) === 0) and
max( //TODO: move this to World
$this->pos->getWorld()->getHighestAdjacentBlockLight($this->pos->x, $this->pos->y, $this->pos->z),
$this->pos->getWorld()->getHighestAdjacentRealBlockSkyLight($this->pos->x, $this->pos->y, $this->pos->z)
) >= 12 - $this->age){
$this->pos->getWorld()->getHighestAdjacentFullLightAt($this->pos->x, $this->pos->y, $this->pos->z) >= 12 - $this->age){
if($this->tryMelt()){
foreach($this->getAllSides() as $block){
if($block instanceof FrostedIce){

View File

@ -1293,6 +1293,14 @@ class World implements ChunkManager{
}
}
/**
* Returns the highest available level of any type of light at, or adjacent to, the given coordinates, adjusted for
* the current weather and time of day.
*/
public function getHighestAdjacentFullLightAt(int $x, int $y, int $z) : int{
return $this->getHighestAdjacentLight($x, $y, $z, \Closure::fromCallable([$this, 'getFullLightAt']));
}
/**
* Gets the raw block skylight level
*

View File

@ -171,12 +171,7 @@ parameters:
path: ../../../src/block/FrostedIce.php
-
message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:getHighestAdjacentBlockLight\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/block/FrostedIce.php
-
message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:getHighestAdjacentRealBlockSkyLight\\(\\) expects int, float\\|int given\\.$#"
message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:getHighestAdjacentFullLightAt\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/block/FrostedIce.php
@ -186,12 +181,7 @@ parameters:
path: ../../../src/block/FrostedIce.php
-
message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:getHighestAdjacentBlockLight\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/block/FrostedIce.php
-
message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:getHighestAdjacentRealBlockSkyLight\\(\\) expects int, float\\|int given\\.$#"
message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:getHighestAdjacentFullLightAt\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/block/FrostedIce.php
@ -201,12 +191,7 @@ parameters:
path: ../../../src/block/FrostedIce.php
-
message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:getHighestAdjacentBlockLight\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/block/FrostedIce.php
-
message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:getHighestAdjacentRealBlockSkyLight\\(\\) expects int, float\\|int given\\.$#"
message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:getHighestAdjacentFullLightAt\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/block/FrostedIce.php