mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-11 05:55:33 +00:00
Use Entity->getDirectionVector() more
This commit is contained in:
parent
4df261b75a
commit
89f5567476
@ -2376,11 +2376,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
|||||||
$this->level->sendBlocks([$this], [$target, $block], UpdateBlockPacket::FLAG_ALL_PRIORITY);
|
$this->level->sendBlocks([$this], [$target, $block], UpdateBlockPacket::FLAG_ALL_PRIORITY);
|
||||||
return true;
|
return true;
|
||||||
}elseif($packet->face === -1){
|
}elseif($packet->face === -1){
|
||||||
$directionVector = new Vector3(
|
$directionVector = $this->getDirectionVector();
|
||||||
-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)
|
|
||||||
);
|
|
||||||
|
|
||||||
if($this->isCreative()){
|
if($this->isCreative()){
|
||||||
$item = $this->inventory->getItemInHand();
|
$item = $this->inventory->getItemInHand();
|
||||||
|
@ -54,6 +54,8 @@ class Bow extends Tool{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$directionVector = $player->getDirectionVector();
|
||||||
|
|
||||||
$nbt = new CompoundTag("", [
|
$nbt = new CompoundTag("", [
|
||||||
new ListTag("Pos", [
|
new ListTag("Pos", [
|
||||||
new DoubleTag("", $player->x),
|
new DoubleTag("", $player->x),
|
||||||
@ -61,9 +63,9 @@ class Bow extends Tool{
|
|||||||
new DoubleTag("", $player->z)
|
new DoubleTag("", $player->z)
|
||||||
]),
|
]),
|
||||||
new ListTag("Motion", [
|
new ListTag("Motion", [
|
||||||
new DoubleTag("", -sin($player->yaw / 180 * M_PI) * cos($player->pitch / 180 * M_PI)),
|
new DoubleTag("", $directionVector->x),
|
||||||
new DoubleTag("", -sin($player->pitch / 180 * M_PI)),
|
new DoubleTag("", $directionVector->y),
|
||||||
new DoubleTag("", cos($player->yaw / 180 * M_PI) * cos($player->pitch / 180 * M_PI))
|
new DoubleTag("", $directionVector->z)
|
||||||
]),
|
]),
|
||||||
new ListTag("Rotation", [
|
new ListTag("Rotation", [
|
||||||
//yaw/pitch for arrows taken crosswise, not along the arrow shaft.
|
//yaw/pitch for arrows taken crosswise, not along the arrow shaft.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user