Block: make getAllSides() and getHorizontalSides() use underlying Vector3 generators

This commit is contained in:
Dylan K. Taylor 2020-06-29 22:13:07 +01:00
parent 8673a4872e
commit da3f0752a6

View File

@ -492,10 +492,10 @@ class Block{
* @phpstan-return \Generator<int, Block, void, void>
*/
public function getHorizontalSides() : \Generator{
yield $this->getSide(Facing::NORTH);
yield $this->getSide(Facing::SOUTH);
yield $this->getSide(Facing::WEST);
yield $this->getSide(Facing::EAST);
$world = $this->pos->getWorld();
foreach($this->pos->sidesAroundAxis(Facing::AXIS_Y) as $vector3){
yield $world->getBlock($vector3);
}
}
/**
@ -505,9 +505,10 @@ class Block{
* @phpstan-return \Generator<int, Block, void, void>
*/
public function getAllSides() : \Generator{
yield $this->getSide(Facing::DOWN);
yield $this->getSide(Facing::UP);
yield from $this->getHorizontalSides();
$world = $this->pos->getWorld();
foreach($this->pos->sides() as $vector3){
yield $world->getBlock($vector3);
}
}
/**