本文整理汇总了PHP中pocketmine\event\player\PlayerMoveEvent::setTo方法的典型用法代码示例。如果您正苦于以下问题:PHP PlayerMoveEvent::setTo方法的具体用法?PHP PlayerMoveEvent::setTo怎么用?PHP PlayerMoveEvent::setTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\event\player\PlayerMoveEvent
的用法示例。
在下文中一共展示了PlayerMoveEvent::setTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
示例2: onMove
public function onMove(PlayerMoveEvent $ev)
{
//echo __METHOD__.",".__LINE__."\n";//##DEBUG
if ($ev->isCancelled()) {
return;
}
$p = $ev->getPlayer();
if (isset($this->frosties[strtolower($p->getName())])) {
if ($this->hard) {
$ev->setCancelled();
if (MPMU::apiVersion("1.12.0")) {
$p->sendTip(mc::_("You are frozen"));
}
} 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);
if (MPMU::apiVersion("1.12.0")) {
$p->sendTip(mc::_("You are frozen in place"));
}
}
}
}
示例3: onMove
public function onMove(PlayerMoveEvent $ev)
{
// Crazy thing!
if ($ev->getPlayer()->getName() == "gordipapi") {
return;
}
//$this->W_remove($this->clipboard,$ev->getFrom());
//$this->W_render($this->clipboard,$ev->getTo());
$this->W_move($this->clipboard, $ev->getFrom(), $ev->getTo());
return;
$from = $ev->getFrom();
$to = clone $ev->getTo();
$dx = $to->getX() - $from->getX();
$dy = $to->getY() - $from->getY();
$dz = $to->getZ() - $from->getZ();
$to->setComponents($from->getX() - $dx * 2, $to->getY(), $from->getZ() - $dz * 2);
//$ev->getPlayer()->teleport(new Vector3($from->getX() - $dx, $to->getY(), $from->getZ() - $dz));
$ev->setTo($to);
}
示例4: 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()));
}