mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-13 23:15:29 +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{
|
public function getHorizontalSides() : \Generator{
|
||||||
$world = $this->position->getWorld();
|
$world = $this->position->getWorld();
|
||||||
foreach($this->position->sidesAroundAxis(Axis::Y) as $vector3){
|
foreach(Facing::HORIZONTAL as $facing){
|
||||||
yield $world->getBlock($vector3);
|
[$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{
|
public function getAllSides() : \Generator{
|
||||||
$world = $this->position->getWorld();
|
$world = $this->position->getWorld();
|
||||||
foreach($this->position->sides() as $vector3){
|
foreach(Facing::OFFSET as [$dx, $dy, $dz]){
|
||||||
yield $world->getBlock($vector3);
|
//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