From 89f55674765ab134d0e68bdb95eb7233b03e18fe Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 3 Sep 2017 12:08:40 +0100 Subject: [PATCH] Use Entity->getDirectionVector() more --- src/pocketmine/Player.php | 6 +----- src/pocketmine/item/Bow.php | 8 +++++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 5cb528a02..3e07ebaea 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -2376,11 +2376,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ $this->level->sendBlocks([$this], [$target, $block], UpdateBlockPacket::FLAG_ALL_PRIORITY); return true; }elseif($packet->face === -1){ - $directionVector = new Vector3( - -sin($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI), - -sin($this->pitch / 180 * M_PI), - cos($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI) - ); + $directionVector = $this->getDirectionVector(); if($this->isCreative()){ $item = $this->inventory->getItemInHand(); diff --git a/src/pocketmine/item/Bow.php b/src/pocketmine/item/Bow.php index 08313b9c2..5ff357c7f 100644 --- a/src/pocketmine/item/Bow.php +++ b/src/pocketmine/item/Bow.php @@ -54,6 +54,8 @@ class Bow extends Tool{ return false; } + $directionVector = $player->getDirectionVector(); + $nbt = new CompoundTag("", [ new ListTag("Pos", [ new DoubleTag("", $player->x), @@ -61,9 +63,9 @@ class Bow extends Tool{ new DoubleTag("", $player->z) ]), new ListTag("Motion", [ - new DoubleTag("", -sin($player->yaw / 180 * M_PI) * cos($player->pitch / 180 * M_PI)), - new DoubleTag("", -sin($player->pitch / 180 * M_PI)), - new DoubleTag("", cos($player->yaw / 180 * M_PI) * cos($player->pitch / 180 * M_PI)) + new DoubleTag("", $directionVector->x), + new DoubleTag("", $directionVector->y), + new DoubleTag("", $directionVector->z) ]), new ListTag("Rotation", [ //yaw/pitch for arrows taken crosswise, not along the arrow shaft.