diff --git a/src/entity/Entity.php b/src/entity/Entity.php index c388a741b..69fc684a1 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -246,7 +246,7 @@ abstract class Entity{ if($nbt !== null){ $this->motion = EntityDataHelper::parseVec3($nbt, self::TAG_MOTION, true); }else{ - $this->motion = new Vector3(0, 0, 0); + $this->motion = Vector3::zero(); } $this->resetLastMovements(); diff --git a/src/entity/EntityDataHelper.php b/src/entity/EntityDataHelper.php index 1a15d7458..60e45e535 100644 --- a/src/entity/EntityDataHelper.php +++ b/src/entity/EntityDataHelper.php @@ -80,7 +80,7 @@ final class EntityDataHelper{ public static function parseVec3(CompoundTag $nbt, string $tagName, bool $optional) : Vector3{ $pos = $nbt->getTag($tagName); if($pos === null && $optional){ - return new Vector3(0, 0, 0); + return Vector3::zero(); } if(!($pos instanceof ListTag) || ($pos->getTagType() !== NBT::TAG_Double && $pos->getTagType() !== NBT::TAG_Float)){ throw new SavedDataLoadingException("'$tagName' should be a List or List"); diff --git a/src/entity/projectile/Projectile.php b/src/entity/projectile/Projectile.php index b04f8c61b..56a7eb57e 100644 --- a/src/entity/projectile/Projectile.php +++ b/src/entity/projectile/Projectile.php @@ -255,7 +255,7 @@ abstract class Projectile extends Entity{ } $this->isCollided = $this->onGround = true; - $this->motion = new Vector3(0, 0, 0); + $this->motion = Vector3::zero(); }else{ $this->isCollided = $this->onGround = false; $this->blockHit = null; diff --git a/src/event/player/PlayerInteractEvent.php b/src/event/player/PlayerInteractEvent.php index f28391364..39e94b5d8 100644 --- a/src/event/player/PlayerInteractEvent.php +++ b/src/event/player/PlayerInteractEvent.php @@ -59,7 +59,7 @@ class PlayerInteractEvent extends PlayerEvent implements Cancellable{ $this->player = $player; $this->item = $item; $this->blockTouched = $block; - $this->touchVector = $touchVector ?? new Vector3(0, 0, 0); + $this->touchVector = $touchVector ?? Vector3::zero(); $this->blockFace = $face; $this->action = $action; } diff --git a/src/player/Player.php b/src/player/Player.php index e54db939e..52eabac17 100644 --- a/src/player/Player.php +++ b/src/player/Player.php @@ -1376,7 +1376,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ if($this->spawned){ Timings::$playerMove->startTiming(); $this->processMostRecentMovements(); - $this->motion = new Vector3(0, 0, 0); //TODO: HACK! (Fixes player knockback being messed up) + $this->motion = Vector3::zero(); //TODO: HACK! (Fixes player knockback being messed up) if($this->onGround){ $this->inAirTicks = 0; }else{