From 32a34d249473d172e85eb7a8a1f8a66055f1727f Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 29 Oct 2021 15:43:09 +0100 Subject: [PATCH] Location: change order of constructor parameters to be consistent with Position::__construct() and Location::fromObject() (although Location::fromObject() has no choice, thanks to the anti-feature known as late static binding ...) --- src/command/defaults/TeleportCommand.php | 2 +- src/entity/Entity.php | 4 ++-- src/entity/Location.php | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/command/defaults/TeleportCommand.php b/src/command/defaults/TeleportCommand.php index 1ece20f30..e3bbff7d0 100644 --- a/src/command/defaults/TeleportCommand.php +++ b/src/command/defaults/TeleportCommand.php @@ -113,7 +113,7 @@ class TeleportCommand extends VanillaCommand{ $x = $this->getRelativeDouble($base->x, $sender, $targetArgs[0]); $y = $this->getRelativeDouble($base->y, $sender, $targetArgs[1], 0, 256); $z = $this->getRelativeDouble($base->z, $sender, $targetArgs[2]); - $targetLocation = new Location($x, $y, $z, $yaw, $pitch, $base->getWorld()); + $targetLocation = new Location($x, $y, $z, $base->getWorld(), $yaw, $pitch); $subject->teleport($targetLocation); Command::broadcastCommandMessage($sender, KnownTranslationFactory::commands_tp_success_coordinates( diff --git a/src/entity/Entity.php b/src/entity/Entity.php index 6289a896b..c917f6001 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -1185,9 +1185,9 @@ abstract class Entity{ ($this->boundingBox->minX + $this->boundingBox->maxX) / 2, $this->boundingBox->minY - $this->ySize, ($this->boundingBox->minZ + $this->boundingBox->maxZ) / 2, + $this->location->world, $this->location->yaw, - $this->location->pitch, - $this->location->world + $this->location->pitch ); $this->getWorld()->onEntityMoved($this); diff --git a/src/entity/Location.php b/src/entity/Location.php index fe02f6eec..c04ac9acb 100644 --- a/src/entity/Location.php +++ b/src/entity/Location.php @@ -34,7 +34,7 @@ class Location extends Position{ /** @var float */ public $pitch; - public function __construct(float $x, float $y, float $z, float $yaw, float $pitch, ?World $world){ + public function __construct(float $x, float $y, float $z, ?World $world, float $yaw, float $pitch){ $this->yaw = $yaw; $this->pitch = $pitch; parent::__construct($x, $y, $z, $world); @@ -44,14 +44,14 @@ class Location extends Position{ * @return Location */ public static function fromObject(Vector3 $pos, ?World $world, float $yaw = 0.0, float $pitch = 0.0){ - return new Location($pos->x, $pos->y, $pos->z, $yaw, $pitch, $world ?? (($pos instanceof Position) ? $pos->world : null)); + return new Location($pos->x, $pos->y, $pos->z, $world ?? (($pos instanceof Position) ? $pos->world : null), $yaw, $pitch); } /** * Return a Location instance */ public function asLocation() : Location{ - return new Location($this->x, $this->y, $this->z, $this->yaw, $this->pitch, $this->world); + return new Location($this->x, $this->y, $this->z, $this->world, $this->yaw, $this->pitch); } public function getYaw() : float{