当前位置: 首页>>代码示例>>PHP>>正文


PHP CommandSender::getEyeHeight方法代码示例

本文整理汇总了PHP中pocketmine\command\CommandSender::getEyeHeight方法的典型用法代码示例。如果您正苦于以下问题:PHP CommandSender::getEyeHeight方法的具体用法?PHP CommandSender::getEyeHeight怎么用?PHP CommandSender::getEyeHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pocketmine\command\CommandSender的用法示例。


在下文中一共展示了CommandSender::getEyeHeight方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onCommand

 public function onCommand(CommandSender $sender, Command $cmd, $label, array $sub)
 {
     $mm = "[TeleportView] ";
     if ($sender->getName() == "CONSOLE") {
         $sender->sendMessage($mm . ($this->isKorean() ? "게임내에서만 사용가능합니다." : "Please run this command in-game"));
         return true;
     }
     $yaw = $sender->getYaw();
     $pitch = $sender->getPitch();
     $yawS = -sin($yaw / 180 * M_PI);
     $yawC = cos($yaw / 180 * M_PI);
     $pitchS = -sin($pitch / 180 * M_PI);
     $pitchC = cos($pitch / 180 * M_PI);
     $x = $sender->x;
     $y = $sender->y + $sender->getEyeHeight();
     $z = $sender->z;
     $l = $sender->getLevel();
     $ps = $this->getServer()->getOnlinePlayers();
     for ($f = 0; $f < 50; ++$f) {
         $x += $yawS * $pitchC;
         $y += $pitchS;
         $z += $yawC * $pitchC;
         $b = $l->getBlock(new Position($x, $y, $z, $l));
         if ($b->isSolid()) {
             break;
         }
         if ($f >= 50) {
             $sender->sendMessage($mm . ($this->isKorean() ? "타겟 블럭이 너무 멉니다." : "TargetBlock is too far"));
             return true;
         }
     }
     $sender->teleport(new Position($x, $y, $z, $sender->getLevel()));
     return true;
 }
开发者ID:Skull3x,项目名称:MineBlock,代码行数:34,代码来源:TeleportView.php

示例2: onCommand

 public function onCommand(CommandSender $sender, Command $cmd, $label, array $sub)
 {
     $mm = "[TeleportView] ";
     if ($sender->getName() == "CONSOLE") {
         $sender->sendMessage($mm . ($this->isKorean() ? "게임내에서만 사용가능합니다." : "Please run this command in-game"));
         return true;
     }
     $yaw = $sender->getYaw();
     $ptch = $sender->getPitch();
     $yawS = -sin($yaw / 180 * M_PI);
     $yawC = cos($yaw / 180 * M_PI);
     $ptchS = -sin($ptch / 180 * M_PI);
     $ptchC = cos($ptch / 180 * M_PI);
     $x = $sender->getX();
     $y = $sender->getY() + $sender->getEyeHeight();
     $z = $sender->getZ();
     $l = $sender->getLevel();
     for ($f = 0; $f < 50; ++$f) {
         $x += $yawS * $ptchC;
         $y += $ptchS;
         $z += $yawC * $ptchC;
         $b = $l->getBlock(new Position($x, $y, $z, $l));
         if ($b->isSolid) {
             $sender->teleport(new Position($x - $yawS * $ptchC, $y - $ptchS + 0.1, $z - $yawC * $ptchC, $l));
             $f = true;
         }
     }
     if (!isset($f)) {
         $sender->sendMessage($mm . ($this->isKorean() ? "타겟 블럭이 너무 멉니다." : "TargetBlock is too far"));
     }
     return true;
 }
开发者ID:stoastye85,项目名称:Plugins,代码行数:32,代码来源:TeleportView.php


注:本文中的pocketmine\command\CommandSender::getEyeHeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。