Merge branch 'next-minor' into next-major

This commit is contained in:
Dylan K. Taylor
2022-07-20 20:55:33 +01:00
40 changed files with 189 additions and 136 deletions

View File

@ -51,16 +51,18 @@ class FrostedIce extends Ice{
}
public function onNearbyBlockChange() : void{
$world = $this->position->getWorld();
if(!$this->checkAdjacentBlocks(2)){
$this->position->getWorld()->useBreakOn($this->position);
$world->useBreakOn($this->position);
}else{
$this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, mt_rand(20, 40));
$world->scheduleDelayedBlockUpdate($this->position, mt_rand(20, 40));
}
}
public function onRandomTick() : void{
$world = $this->position->getWorld();
if((!$this->checkAdjacentBlocks(4) || mt_rand(0, 2) === 0) &&
$this->position->getWorld()->getHighestAdjacentFullLightAt($this->position->x, $this->position->y, $this->position->z) >= 12 - $this->age){
$world->getHighestAdjacentFullLightAt($this->position->x, $this->position->y, $this->position->z) >= 12 - $this->age){
if($this->tryMelt()){
foreach($this->getAllSides() as $block){
if($block instanceof FrostedIce){
@ -69,7 +71,7 @@ class FrostedIce extends Ice{
}
}
}else{
$this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, mt_rand(20, 40));
$world->scheduleDelayedBlockUpdate($this->position, mt_rand(20, 40));
}
}
@ -101,18 +103,19 @@ class FrostedIce extends Ice{
* @return bool Whether the ice was destroyed.
*/
private function tryMelt() : bool{
$world = $this->position->getWorld();
if($this->age >= self::MAX_AGE){
$ev = new BlockMeltEvent($this, VanillaBlocks::WATER());
$ev->call();
if(!$ev->isCancelled()){
$this->position->getWorld()->setBlock($this->position, $ev->getNewState());
$world->setBlock($this->position, $ev->getNewState());
}
return true;
}
$this->age++;
$this->position->getWorld()->setBlock($this->position, $this);
$this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, mt_rand(20, 40));
$world->setBlock($this->position, $this);
$world->scheduleDelayedBlockUpdate($this->position, mt_rand(20, 40));
return false;
}
}