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


PHP PlayerMoveEvent::getTo方法代码示例

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


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

示例1: onPlayerMove

 /**
  * @param PlayerMoveEvent $event
  */
 public function onPlayerMove(PlayerMoveEvent $event)
 {
     if (isset($this->blockMans[spl_object_hash($event->getPlayer())])) {
         foreach ($this->blockMans[spl_object_hash($event->getPlayer())] as $p) {
             /** @var $p Player */
             $motion = $event->getPlayer()->getMotion();
             $p->addEntityMovement($event->getPlayer()->getId(), $event->getTo()->getX(), $event->getTo()->getY() + 0.5, $event->getTo()->getZ(), $event->getPlayer()->getYaw(), $event->getPlayer()->getPitch());
             $p->addEntityMotion($event->getPlayer()->getId(), $motion->getX(), $motion->getY(), $motion->getZ());
         }
     }
 }
开发者ID:Jerry6o,项目名称:BlockMan,代码行数:14,代码来源:BlockMan.php

示例2: onMove

 public function onMove(PlayerMoveEvent $event)
 {
     $player = $event->getPlayer();
     $from = $event->getFrom();
     $to = $event->getTo();
     if ($from->getLevel()->getBlockIdAt($from->x, $from->y - 1, $from->z) === Block::REDSTONE_BLOCK) {
         $player->setMotion((new Vector3($to->x - $from->x, $to->y - $from->y, $to->z - $from->z))->multiply(5));
     }
 }
开发者ID:somenabzofturtles,项目名称:Small-PM-Plugins,代码行数:9,代码来源:Main.php

示例3: onMove

 public function onMove(PlayerMoveEvent $event)
 {
     if (isset($this->move[$event->getPlayer()->getName()])) {
         unset($this->move[$event->getPlayer()->getName()]);
         return;
     }
     if ($event->getFrom()->distance($event->getTo()) > 7) {
         $event->setCancelled();
     }
 }
开发者ID:EmreTr1,项目名称:rtr,代码行数:10,代码来源:placebo.php

示例4: onMove

 public function onMove(PlayerMoveEvent $ev)
 {
     if ($ev->isCancelled()) {
         return;
     }
     if ($this->checkMove($ev->getTo())) {
         $ev->setCancelled();
     }
     return;
 }
开发者ID:DWWf,项目名称:pocketmine-plugins,代码行数:10,代码来源:Main.php

示例5: onMove

 /**
  * Handle player move events.
  * @param PlayerMoveEvent $ev - Move event
  */
 public function onMove(PlayerMoveEvent $ev)
 {
     //echo __METHOD__.",".__LINE__."\n";//##DEBUG
     if ($ev->isCancelled()) {
         return;
     }
     $p = $ev->getPlayer();
     if (!$this->getState("fz", $p, false)) {
         return;
     }
     if ($this->hard) {
         $ev->setCancelled();
     } else {
         // Lock position but still allow to turn around
         $to = clone $ev->getFrom();
         $to->yaw = $ev->getTo()->yaw;
         $to->pitch = $ev->getTo()->pitch;
         $ev->setTo($to);
     }
 }
开发者ID:HeechFive,项目名称:pocketmine-plugins,代码行数:24,代码来源:FreezeSession.php

示例6: onPlayerMove

 public function onPlayerMove(PlayerMoveEvent $event)
 {
     if (isset($this->activeZones[$event->getPlayer()->getLevel()->getId()])) {
         foreach ($this->activeZones[$event->getPlayer()->getLevel()->getId()] as $zone) {
             if ($this->isInsideZone($event->getTo(), $zone[0], $zone[1])) {
                 $event->setCancelled();
                 $event->getPlayer()->sendMessage("You can't go in there, a mine is resetting.");
                 return;
             }
         }
     }
 }
开发者ID:MCPEGamerJPatGitHub,项目名称:MineReset,代码行数:12,代码来源:RegionBlocker.php

示例7: onMove

 public function onMove(PlayerMoveEvent $ev)
 {
     if ($ev->isCancelled()) {
         return;
     }
     $from = $ev->getFrom();
     $to = $ev->getTo();
     $dir = ["dx" => $to->getX() - $from->getX(), "dy" => $to->getY() - $from->getY(), "dz" => $to->getZ() - $from->getZ()];
     if (!$dir["dy"]) {
         return;
     }
     $id = $to->getLevel()->getBlockIdAt($to->getX(), $to->getY() - 1, $to->getZ());
     if (isset($this->blocks[$id])) {
         $ev->getPlayer()->setMotion(new Vector3($dir["dx"], -$dir["dy"] * 1.1, $dir["dz"]));
     }
 }
开发者ID:DWWf,项目名称:pocketmine-plugins,代码行数:16,代码来源:Trampoline.php

示例8: onVoidLoop

 public function onVoidLoop(PlayerMoveEvent $event)
 {
     if ($event->getTo()->getFloorY() < 1) {
         $player = $event->getPlayer();
         $name = $event->getPlayer()->getName();
         $name = strtolower($name);
         $pos = $this->data->get($name);
         if (is_array($pos)) {
             $player->sendMessage("{$this->getConfig()->get("TeleportMessage")}");
             $level = $this->getServer()->getLevelByName($pos[3]);
             $player->teleport(new Position($pos[0], $pos[1], $pos[2], $level));
         } else {
             $player->sendMessage("{$this->getConfig()->get("No-Checkpoint")}");
             $player->teleport($player->getLevel()->getSafeSpawn());
         }
     }
 }
开发者ID:linuzo,项目名称:Parkour,代码行数:17,代码来源:Main.php

示例9: onVoidLoop

 public function onVoidLoop(PlayerMoveEvent $event)
 {
     if ($event->getTo()->getFloorY() < 0) {
         $enableConf = $this->getConfig()->get("enableConf");
         $X = $this->getConfig()->get("X");
         $Y = $this->getConfig()->get("Y");
         $Z = $this->getConfig()->get("Z");
         $Level = $this->getConfig()->get("Level");
         $player = $event->getPlayer();
         if ($enableConf === false) {
             $player->teleport($this->getServer()->getDefaultLevel()->getSpawn());
             $player->setHealth($player->getHealth() - $this->getConfig()->get("hearts"));
         } else {
             $player->teleport(new Vector3($X, $Y + 4, $Z, $Level));
             $player->setHealth($player->getHealth() - $this->getConfig()->get("hearts"));
         }
     }
 }
开发者ID:gitter-badger,项目名称:Parkour,代码行数:18,代码来源:Main.php

示例10: onPlayerMove

 public function onPlayerMove(PlayerMoveEvent $event)
 {
     $p = $event->getPlayer();
     if (!$p->hasPermission("debe.worldinventory.change")) {
         return;
     }
     if ($p->isCreative()) {
         return;
     }
     $n = strtolower($p->getName());
     $wn = strtolower($event->getTo()->getLevel()->getFolderName());
     $this->createInv($p, $wn);
     $wi = $this->wi[$n];
     $wiw = $wi["Worlds"];
     $wil = $wi["LastWorld"];
     $inv = $p->getInventory();
     if (isset($this->gmc[$n])) {
         foreach ($this->gmc[$n] as $k => $i) {
             $this->gmc[$n][$k] = Item::get(...explode(":", $i));
         }
         $inv->setContents($this->gmc[$n]);
         unset($this->gmc[$n]);
         $change = true;
     }
     if ($wil !== $wn) {
         $wiw[$wil] = [];
         if (!isset($wiw[$wn])) {
             $wiw[$wn] = [];
         }
         foreach ($inv->getContents() as $i) {
             if ($i->getID() !== 0 and $i->getCount() > 0) {
                 $wiw[$wil][] = $i->getID() . ":" . $i->getDamage() . ":" . $i->getCount();
             }
         }
         foreach ($wiw[$wn] as $k => $i) {
             $wiw[$wn][$k] = Item::get(...explode(":", $i));
         }
         $inv->setContents($wiw[$wn]);
         $wiw[$wn] = [];
         $this->wi[$n] = ["LastWorld" => $wn, "Worlds" => $wiw];
         $this->saveYml();
         $p->sendMessage("[WorldInventory] " . ($this->isKorean() ? "인벤토리가 교체되었습니다." : "Inventory is change") . " : WorldChange");
     }
 }
开发者ID:stoastye85,项目名称:Plugins,代码行数:44,代码来源:WorldInventory.php

示例11: onMove

 /**
  * @param PlayerMoveEvent $event
  *
  * @priority HIGHEST
  */
 public function onMove(PlayerMoveEvent $event)
 {
     $player = $event->getPlayer();
     $gamer = $this->hub->getGamerForPlayer($player);
     $delta = $event->getTo()->subtract($event->getFrom());
     $bb = clone $player->getBoundingBox();
     $bb->offset($delta->x, $delta->y, $delta->z);
     foreach ($this->hub->getJoinMethods() as $method) {
         if (!$method->isLevelCorrect($player->getLevel())) {
             continue;
         }
         if ($method instanceof PortalJoinMethod) {
             if ($method->isLevelCorrect($player->getLevel()) and $method->bb->intersectsWith($bb)) {
                 $gamer->setModule($this->hub->getModule($method->target));
                 return;
             }
         }
     }
 }
开发者ID:gitter-badger,项目名称:DynamicHub,代码行数:24,代码来源:JoinListener.php

示例12: onPlayerMove

 public function onPlayerMove(PlayerMoveEvent $ev)
 {
     if ($ev->isCancelled()) {
         return;
     }
     $pl = $ev->getPlayer();
     $pos = $ev->getTo();
     if ($this->checkMove($pl->getLevel()->getName(), $pos->getX(), $pos->getZ())) {
         return;
     }
     $this->owner->msg($pl, mc::_("You have reached the end of the world"));
     $ev->setCancelled();
 }
开发者ID:Gabriel865,项目名称:pocketmine-plugins,代码行数:13,代码来源:WpBordersMgr.php

示例13: onPlayerTeleport

 public function onPlayerTeleport(PlayerMoveEvent $event)
 {
     if ($event->getFrom()->getLevel() !== $event->getTo()->getLevel()) {
         $to = $event->getTo()->getLevel();
         if (isset($this->items[$to->getFolderName()])) {
             $player = $event->getPlayer();
             foreach ($this->items[$to->getFolderName()] as $displayer) {
                 $displayer->spawnTo($player);
             }
         }
     }
 }
开发者ID:PocketMine-PHP7,项目名称:EconomyS-PHP7,代码行数:12,代码来源:EconomyShop.php

示例14: onPlayerMove

 public function onPlayerMove(PlayerMoveEvent $event)
 {
     if ($this->gameStatus > 1 && $this->playerIsInGame($event->getPlayer()->getName()) === 2) {
         foreach ($event->getPlayer()->getLevel()->getPlayers() as $p) {
             $motion = $event->getPlayer()->getMotion();
             $p->addEntityMovement($event->getPlayer()->getId(), $event->getTo()->getX(), $event->getTo()->getY() + 0.5, $event->getTo()->getZ(), $event->getPlayer()->getYaw(), $event->getPlayer()->getPitch());
             $p->addEntityMotion($event->getPlayer()->getId(), $motion->getX(), $motion->getY(), $motion->getZ());
         }
         $to = $event->getTo();
         if ($this->players[$event->getPlayer()->getName()]->gameInfo->isHide) {
             if ((int) ($this->players[$event->getPlayer()->getName()]->gameInfo->hideX - $to->x) != 0 || (int) ($this->players[$event->getPlayer()->getName()]->gameInfo->hideY - $to->y) != 0 || (int) ($this->players[$event->getPlayer()->getName()]->gameInfo->hideZ - $to->z) != 0) {
                 $this->players[$event->getPlayer()->getName()]->sendMessage("[游戏系统] [躲猫猫] 你脱离了真实方块的状态");
                 $pk = new UpdateBlockPacket();
                 $pk->x = $this->players[$event->getPlayer()->getName()]->gameInfo->hideX;
                 $pk->y = $this->players[$event->getPlayer()->getName()]->gameInfo->hideY;
                 $pk->z = $this->players[$event->getPlayer()->getName()]->gameInfo->hideZ;
                 $pk->block = $this->players[$event->getPlayer()->getName()]->gameInfo->oldID;
                 $pk->meta = $this->players[$event->getPlayer()->getName()]->gameInfo->oldData;
                 $this->packetToAll($pk);
                 $this->showPlayer($this->players[$event->getPlayer()->getName()], $this->players[$event->getPlayer()->getName()]->gameInfo);
                 $this->players[$event->getPlayer()->getName()]->gameInfo->isHide = false;
             }
         } else {
             if (abs($this->players[$event->getPlayer()->getName()]->gameInfo->hideX - $to->x) >= 0.15 || abs($this->players[$event->getPlayer()->getName()]->gameInfo->hideY - $to->y) >= 0.15 || abs($this->players[$event->getPlayer()->getName()]->gameInfo->hideZ - $to->z) >= 0.15) {
                 $this->players[$event->getPlayer()->getName()]->gameInfo->hideTime = 0;
             }
         }
     }
     unset($to, $event, $val, $pk);
 }
开发者ID:rubbendu91,项目名称:FBlockHunt,代码行数:30,代码来源:Main.php

示例15: playerMove

 public function playerMove(XcelPlayer $player, PlayerMoveEvent $event)
 {
     if (!$player->isAlive()) {
         return;
     }
     if (!XcelNgien::isSameGame($player->getGame(), $this)) {
         return;
     }
     $oldTo = $event->getTo();
     $x = $oldTo->getX() < -1 ? -1 : $oldTo->getX();
     $x = $x > 2 ? 2 : $x;
     $event->setTo(new Location($x, $oldTo->getY(), $oldTo->getZ(), $oldTo->getYaw(), $oldTo->getPitch(), $oldTo->getLevel()));
 }
开发者ID:HelloWorld017,项目名称:RainbowRun,代码行数:13,代码来源:RainbowRun.php


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