Lava: implement basalt generators

This commit is contained in:
Dylan K. Taylor
2022-07-05 20:49:53 +01:00
parent a005cd6e33
commit e5b038ebcd

View File

@ -54,23 +54,24 @@ class Lava extends Liquid{
return 2; //TODO: this is 1 in the nether return 2; //TODO: this is 1 in the nether
} }
protected function checkForHarden() : bool{ /**
if($this->falling){ * @phpstan-return \Generator<int, Block, void, void>
return false; */
} private function getAdjacentBlocksExceptDown() : \Generator{
$colliding = null;
foreach(Facing::ALL as $side){ foreach(Facing::ALL as $side){
if($side === Facing::DOWN){ if($side === Facing::DOWN){
continue; continue;
} }
$blockSide = $this->getSide($side); yield $this->getSide($side);
if($blockSide instanceof Water){
$colliding = $blockSide;
break;
} }
} }
if($colliding !== null){ protected function checkForHarden() : bool{
if($this->falling){
return false;
}
foreach($this->getAdjacentBlocksExceptDown() as $colliding){
if($colliding instanceof Water){
if($this->decay === 0){ if($this->decay === 0){
$this->liquidCollide($colliding, VanillaBlocks::OBSIDIAN()); $this->liquidCollide($colliding, VanillaBlocks::OBSIDIAN());
return true; return true;
@ -79,6 +80,17 @@ class Lava extends Liquid{
return true; return true;
} }
} }
}
if($this->getSide(Facing::DOWN)->getTypeId() === BlockTypeIds::SOUL_SOIL){
foreach($this->getAdjacentBlocksExceptDown() as $colliding){
if($colliding->getTypeId() === BlockTypeIds::BLUE_ICE){
$this->liquidCollide($colliding, VanillaBlocks::BASALT());
return true;
}
}
}
return false; return false;
} }