From 1d8e7abdd438999ff1919ad7f91ba30896ba3cb4 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 25 Sep 2020 18:38:41 +0100 Subject: [PATCH] Entity: avoid direct mutation of Vector3 in checkObstruction(), use withComponents() instead this ugly code can be simplified quite a lot further, but that's a job for later. --- src/entity/Entity.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/entity/Entity.php b/src/entity/Entity.php index cb93cf9c02..f1d7bc7e6a 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -853,37 +853,37 @@ abstract class Entity{ $force = lcg_value() * 0.2 + 0.1; if($direction === Facing::WEST){ - $this->motion->x = -$force; + $this->motion = $this->motion->withComponents(-$force, null, null); return true; } if($direction === Facing::EAST){ - $this->motion->x = $force; + $this->motion = $this->motion->withComponents($force, null, null); return true; } if($direction === Facing::DOWN){ - $this->motion->y = -$force; + $this->motion = $this->motion->withComponents(null, -$force, null); return true; } if($direction === Facing::UP){ - $this->motion->y = $force; + $this->motion = $this->motion->withComponents(null, $force, null); return true; } if($direction === Facing::NORTH){ - $this->motion->z = -$force; + $this->motion = $this->motion->withComponents(null, null, -$force); return true; } if($direction === Facing::SOUTH){ - $this->motion->z = $force; + $this->motion = $this->motion->withComponents(null, null, $force); return true; }