mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-22 10:56:35 +00:00
Liquid: eliminate unnecessary Position allocations and getSide() calls
This commit is contained in:
parent
9474324f75
commit
dbb5a32a96
@ -165,6 +165,10 @@ abstract class Liquid extends Transparent{
|
||||
|
||||
$vX = $vY = $vZ = 0;
|
||||
|
||||
$x = $this->position->getFloorX();
|
||||
$y = $this->position->getFloorY();
|
||||
$z = $this->position->getFloorZ();
|
||||
|
||||
$decay = $this->getEffectiveFlowDecay($this);
|
||||
|
||||
$world = $this->position->getWorld();
|
||||
@ -172,11 +176,11 @@ abstract class Liquid extends Transparent{
|
||||
foreach(Facing::HORIZONTAL as $j){
|
||||
[$dx, $dy, $dz] = Facing::OFFSET[$j];
|
||||
|
||||
$x = $this->position->x + $dx;
|
||||
$y = $this->position->y + $dy;
|
||||
$z = $this->position->z + $dz;
|
||||
$sideX = $x + $dx;
|
||||
$sideY = $y + $dy;
|
||||
$sideZ = $z + $dz;
|
||||
|
||||
$sideBlock = $world->getBlockAt($x, $y, $z);
|
||||
$sideBlock = $world->getBlockAt($sideX, $sideY, $sideZ);
|
||||
$blockDecay = $this->getEffectiveFlowDecay($sideBlock);
|
||||
|
||||
if($blockDecay < 0){
|
||||
@ -184,7 +188,7 @@ abstract class Liquid extends Transparent{
|
||||
continue;
|
||||
}
|
||||
|
||||
$blockDecay = $this->getEffectiveFlowDecay($world->getBlockAt($x, $y - 1, $z));
|
||||
$blockDecay = $this->getEffectiveFlowDecay($world->getBlockAt($sideX, $sideY - 1, $sideZ));
|
||||
|
||||
if($blockDecay >= 0){
|
||||
$realDecay = $blockDecay - ($decay - 8);
|
||||
@ -206,10 +210,10 @@ abstract class Liquid extends Transparent{
|
||||
|
||||
if($this->falling){
|
||||
foreach(Facing::HORIZONTAL as $facing){
|
||||
$pos = $this->position->getSide($facing);
|
||||
[$dx, $dy, $dz] = Facing::OFFSET[$facing];
|
||||
if(
|
||||
!$this->canFlowInto($world->getBlockAt($pos->x, $pos->y, $pos->z)) ||
|
||||
!$this->canFlowInto($world->getBlockAt($pos->x, $pos->y + 1, $pos->z))
|
||||
!$this->canFlowInto($world->getBlockAt($x + $dx, $y + $dy, $z + $dz)) ||
|
||||
!$this->canFlowInto($world->getBlockAt($x + $dx, $y + $dy + 1, $z + $dz))
|
||||
){
|
||||
$vector = $vector->normalize()->add(0, -6, 0);
|
||||
break;
|
||||
|
@ -285,31 +285,16 @@ parameters:
|
||||
count: 1
|
||||
path: ../../../src/block/Leaves.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#"
|
||||
count: 4
|
||||
path: ../../../src/block/Liquid.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:isInWorld\\(\\) expects int, float\\|int given\\.$#"
|
||||
count: 1
|
||||
path: ../../../src/block/Liquid.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#"
|
||||
count: 4
|
||||
path: ../../../src/block/Liquid.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:isInWorld\\(\\) expects int, float\\|int given\\.$#"
|
||||
count: 1
|
||||
path: ../../../src/block/Liquid.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#"
|
||||
count: 4
|
||||
path: ../../../src/block/Liquid.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:isInWorld\\(\\) expects int, float\\|int given\\.$#"
|
||||
count: 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user