mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
Block: Avoid useless Vector3 allocations in getHorizontalSides and getAllSides
This commit is contained in:
parent
eb935ca80f
commit
1f461977d4
@ -768,8 +768,14 @@ class Block{
|
||||
*/
|
||||
public function getHorizontalSides() : \Generator{
|
||||
$world = $this->position->getWorld();
|
||||
foreach($this->position->sidesAroundAxis(Axis::Y) as $vector3){
|
||||
yield $world->getBlock($vector3);
|
||||
foreach(Facing::HORIZONTAL as $facing){
|
||||
[$dx, $dy, $dz] = Facing::OFFSET[$facing];
|
||||
//TODO: yield Facing as the key?
|
||||
yield $world->getBlockAt(
|
||||
$this->position->x + $dx,
|
||||
$this->position->y + $dy,
|
||||
$this->position->z + $dz
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -781,8 +787,13 @@ class Block{
|
||||
*/
|
||||
public function getAllSides() : \Generator{
|
||||
$world = $this->position->getWorld();
|
||||
foreach($this->position->sides() as $vector3){
|
||||
yield $world->getBlock($vector3);
|
||||
foreach(Facing::OFFSET as [$dx, $dy, $dz]){
|
||||
//TODO: yield Facing as the key?
|
||||
yield $world->getBlockAt(
|
||||
$this->position->x + $dx,
|
||||
$this->position->y + $dy,
|
||||
$this->position->z + $dz
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user