diff --git a/src/block/Liquid.php b/src/block/Liquid.php index 3a84728ae..6404cf908 100644 --- a/src/block/Liquid.php +++ b/src/block/Liquid.php @@ -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; diff --git a/tests/phpstan/configs/actual-problems.neon b/tests/phpstan/configs/actual-problems.neon index 5763c4367..a9d3a96a2 100644 --- a/tests/phpstan/configs/actual-problems.neon +++ b/tests/phpstan/configs/actual-problems.neon @@ -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