Merge commit 'a2543ff80d2906bccda1a4e2fdbd9d8e7d147fb3'

This commit is contained in:
Dylan K. Taylor
2020-04-18 17:33:05 +01:00
76 changed files with 286 additions and 238 deletions

View File

@ -50,17 +50,17 @@ class FrostedIce extends Ice{
public function onNearbyBlockChange() : void{
if(!$this->checkAdjacentBlocks(2)){
$this->pos->getWorld()->useBreakOn($this->pos);
$this->pos->getWorldNonNull()->useBreakOn($this->pos);
}else{
$this->pos->getWorld()->scheduleDelayedBlockUpdate($this->pos, mt_rand(20, 40));
$this->pos->getWorldNonNull()->scheduleDelayedBlockUpdate($this->pos, mt_rand(20, 40));
}
}
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()->getHighestAdjacentBlockSkyLight($this->pos->x, $this->pos->y, $this->pos->z) - $this->pos->getWorld()->getSkyLightReduction()
$this->pos->getWorldNonNull()->getHighestAdjacentBlockLight($this->pos->x, $this->pos->y, $this->pos->z),
$this->pos->getWorldNonNull()->getHighestAdjacentBlockSkyLight($this->pos->x, $this->pos->y, $this->pos->z) - $this->pos->getWorldNonNull()->getSkyLightReduction()
) >= 12 - $this->age){
if($this->tryMelt()){
foreach($this->getAllSides() as $block){
@ -70,7 +70,7 @@ class FrostedIce extends Ice{
}
}
}else{
$this->pos->getWorld()->scheduleDelayedBlockUpdate($this->pos, mt_rand(20, 40));
$this->pos->getWorldNonNull()->scheduleDelayedBlockUpdate($this->pos, mt_rand(20, 40));
}
}
@ -86,7 +86,7 @@ class FrostedIce extends Ice{
continue;
}
if(
$this->pos->getWorld()->getBlockAt($this->pos->x + $x, $this->pos->y, $this->pos->z + $z) instanceof FrostedIce and
$this->pos->getWorldNonNull()->getBlockAt($this->pos->x + $x, $this->pos->y, $this->pos->z + $z) instanceof FrostedIce and
++$found >= $requirement
){
return true;
@ -103,13 +103,13 @@ class FrostedIce extends Ice{
*/
private function tryMelt() : bool{
if($this->age >= 3){
$this->pos->getWorld()->useBreakOn($this->pos);
$this->pos->getWorldNonNull()->useBreakOn($this->pos);
return true;
}
$this->age++;
$this->pos->getWorld()->setBlock($this->pos, $this);
$this->pos->getWorld()->scheduleDelayedBlockUpdate($this->pos, mt_rand(20, 40));
$this->pos->getWorldNonNull()->setBlock($this->pos, $this);
$this->pos->getWorldNonNull()->scheduleDelayedBlockUpdate($this->pos, mt_rand(20, 40));
return false;
}
}