From 42637f97c61916dc909bbac6d43144eca750cf19 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 20 Jun 2020 21:32:24 +0100 Subject: [PATCH] Liquid: eliminate some unnecessary Vector3 field mutations --- src/block/Liquid.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/block/Liquid.php b/src/block/Liquid.php index 3cf491640..14371b3bc 100644 --- a/src/block/Liquid.php +++ b/src/block/Liquid.php @@ -168,7 +168,7 @@ abstract class Liquid extends Transparent{ return $this->flowVector; } - $vector = new Vector3(0, 0, 0); + $vX = $vY = $vZ = 0; $decay = $this->getEffectiveFlowDecay($this); @@ -200,20 +200,22 @@ abstract class Liquid extends Transparent{ if($blockDecay >= 0){ $realDecay = $blockDecay - ($decay - 8); - $vector->x += ($x - $this->pos->x) * $realDecay; - $vector->y += ($y - $this->pos->y) * $realDecay; - $vector->z += ($z - $this->pos->z) * $realDecay; + $vX += ($x - $this->pos->x) * $realDecay; + $vY += ($y - $this->pos->y) * $realDecay; + $vZ += ($z - $this->pos->z) * $realDecay; } continue; }else{ $realDecay = $blockDecay - $decay; - $vector->x += ($x - $this->pos->x) * $realDecay; - $vector->y += ($y - $this->pos->y) * $realDecay; - $vector->z += ($z - $this->pos->z) * $realDecay; + $vX += ($x - $this->pos->x) * $realDecay; + $vY += ($y - $this->pos->y) * $realDecay; + $vZ += ($z - $this->pos->z) * $realDecay; } } + $vector = new Vector3($vX, $vY, $vZ); + if($this->falling){ if( !$this->canFlowInto($this->pos->getWorldNonNull()->getBlockAt($this->pos->x, $this->pos->y, $this->pos->z - 1)) or