Lava: implement basalt generators

This commit is contained in:
Dylan K. Taylor 2022-07-05 20:49:53 +01:00
parent a005cd6e33
commit e5b038ebcd
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -54,31 +54,43 @@ 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;
protected function checkForHarden() : bool{
if($this->falling){
return false;
}
foreach($this->getAdjacentBlocksExceptDown() as $colliding){
if($colliding instanceof Water){
if($this->decay === 0){
$this->liquidCollide($colliding, VanillaBlocks::OBSIDIAN());
return true;
}elseif($this->decay <= 4){
$this->liquidCollide($colliding, VanillaBlocks::COBBLESTONE());
return true;
}
} }
} }
if($colliding !== null){ if($this->getSide(Facing::DOWN)->getTypeId() === BlockTypeIds::SOUL_SOIL){
if($this->decay === 0){ foreach($this->getAdjacentBlocksExceptDown() as $colliding){
$this->liquidCollide($colliding, VanillaBlocks::OBSIDIAN()); if($colliding->getTypeId() === BlockTypeIds::BLUE_ICE){
return true; $this->liquidCollide($colliding, VanillaBlocks::BASALT());
}elseif($this->decay <= 4){ return true;
$this->liquidCollide($colliding, VanillaBlocks::COBBLESTONE()); }
return true;
} }
} }
return false; return false;
} }