mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-15 10:19:39 +00:00
Block: make getAllSides() and getHorizontalSides() return generators
This commit is contained in:
parent
e61a08a56b
commit
43ae1a5cb4
@ -43,7 +43,6 @@ use pocketmine\player\Player;
|
|||||||
use pocketmine\world\BlockTransaction;
|
use pocketmine\world\BlockTransaction;
|
||||||
use pocketmine\world\Position;
|
use pocketmine\world\Position;
|
||||||
use pocketmine\world\World;
|
use pocketmine\world\World;
|
||||||
use function array_merge;
|
|
||||||
use function assert;
|
use function assert;
|
||||||
use function count;
|
use function count;
|
||||||
use function dechex;
|
use function dechex;
|
||||||
@ -489,30 +488,26 @@ class Block{
|
|||||||
/**
|
/**
|
||||||
* Returns the 4 blocks on the horizontal axes around the block (north, south, east, west)
|
* Returns the 4 blocks on the horizontal axes around the block (north, south, east, west)
|
||||||
*
|
*
|
||||||
* @return Block[]
|
* @return Block[]|\Generator
|
||||||
|
* @phpstan-return \Generator<int, Block, void, void>
|
||||||
*/
|
*/
|
||||||
public function getHorizontalSides() : array{
|
public function getHorizontalSides() : \Generator{
|
||||||
return [
|
yield $this->getSide(Facing::NORTH);
|
||||||
$this->getSide(Facing::NORTH),
|
yield $this->getSide(Facing::SOUTH);
|
||||||
$this->getSide(Facing::SOUTH),
|
yield $this->getSide(Facing::WEST);
|
||||||
$this->getSide(Facing::WEST),
|
yield $this->getSide(Facing::EAST);
|
||||||
$this->getSide(Facing::EAST)
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the six blocks around this block.
|
* Returns the six blocks around this block.
|
||||||
*
|
*
|
||||||
* @return Block[]
|
* @return Block[]|\Generator
|
||||||
|
* @phpstan-return \Generator<int, Block, void, void>
|
||||||
*/
|
*/
|
||||||
public function getAllSides() : array{
|
public function getAllSides() : \Generator{
|
||||||
return array_merge(
|
yield $this->getSide(Facing::DOWN);
|
||||||
[
|
yield $this->getSide(Facing::UP);
|
||||||
$this->getSide(Facing::DOWN),
|
yield from $this->getHorizontalSides();
|
||||||
$this->getSide(Facing::UP)
|
|
||||||
],
|
|
||||||
$this->getHorizontalSides()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user