Liquid: make flow vector calculation less cancerous to read

This commit is contained in:
Dylan K. Taylor 2021-09-18 23:04:28 +01:00
parent 6b2ab15ea1
commit 576c33ee8f
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -30,6 +30,7 @@ use pocketmine\event\block\BlockFormEvent;
use pocketmine\event\block\BlockSpreadEvent; use pocketmine\event\block\BlockSpreadEvent;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Facing;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use pocketmine\world\sound\FizzSound; use pocketmine\world\sound\FizzSound;
use pocketmine\world\sound\Sound; use pocketmine\world\sound\Sound;
@ -221,17 +222,15 @@ abstract class Liquid extends Transparent{
$vector = new Vector3($vX, $vY, $vZ); $vector = new Vector3($vX, $vY, $vZ);
if($this->falling){ if($this->falling){
if( foreach(Facing::HORIZONTAL as $facing){
!$this->canFlowInto($world->getBlockAt($this->position->x, $this->position->y, $this->position->z - 1)) or $pos = $this->position->getSide($facing);
!$this->canFlowInto($world->getBlockAt($this->position->x, $this->position->y, $this->position->z + 1)) or if(
!$this->canFlowInto($world->getBlockAt($this->position->x - 1, $this->position->y, $this->position->z)) or !$this->canFlowInto($world->getBlockAt($pos->x, $pos->y, $pos->z)) ||
!$this->canFlowInto($world->getBlockAt($this->position->x + 1, $this->position->y, $this->position->z)) or !$this->canFlowInto($world->getBlockAt($pos->x, $pos->y + 1, $pos->z))
!$this->canFlowInto($world->getBlockAt($this->position->x, $this->position->y + 1, $this->position->z - 1)) or ){
!$this->canFlowInto($world->getBlockAt($this->position->x, $this->position->y + 1, $this->position->z + 1)) or $vector = $vector->normalize()->add(0, -6, 0);
!$this->canFlowInto($world->getBlockAt($this->position->x - 1, $this->position->y + 1, $this->position->z)) or break;
!$this->canFlowInto($world->getBlockAt($this->position->x + 1, $this->position->y + 1, $this->position->z)) }
){
$vector = $vector->normalize()->add(0, -6, 0);
} }
} }