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