本文整理汇总了PHP中pocketmine\event\player\PlayerMoveEvent::getFrom方法的典型用法代码示例。如果您正苦于以下问题:PHP PlayerMoveEvent::getFrom方法的具体用法?PHP PlayerMoveEvent::getFrom怎么用?PHP PlayerMoveEvent::getFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\event\player\PlayerMoveEvent
的用法示例。
在下文中一共展示了PlayerMoveEvent::getFrom方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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));
}
}
示例2: 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();
}
}
示例3: 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"]));
}
}
示例4: 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;
}
}
}
}
示例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);
}
}
示例6: 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);
}
}
}
}
示例7: onPlayerMove
public function onPlayerMove(PlayerMoveEvent $event)
{
if ($event->getFrom()->getLevel() === $event->getTo()->getLevel()) {
return;
}
$this->checkItemCase($event->getPlayer());
}
示例8: onPlayerMove
public function onPlayerMove(PlayerMoveEvent $event)
{
if (!$this->plugin->getConfig()->get("ShowPlotPopup", true)) {
return;
}
$levelName = $event->getPlayer()->getLevel()->getName();
if (!$this->plugin->isLevelLoaded($levelName)) {
return;
}
$plot = $this->plugin->getPlotByPosition($event->getTo());
if ($plot !== null and $plot !== $this->plugin->getPlotByPosition($event->getFrom())) {
$plotName = TextFormat::GREEN . $plot;
$popup = $this->plugin->getLanguage()->translateString("popup", [$plotName]);
if ($plot->owner != "") {
$owner = TextFormat::GREEN . $plot->owner;
$ownerPopup = $this->plugin->getLanguage()->translateString("popup.owner", [$owner]);
$paddingSize = floor((strlen($popup) - strlen($ownerPopup)) / 2);
$paddingPopup = str_repeat(" ", max(0, -$paddingSize));
$paddingOwnerPopup = str_repeat(" ", max(0, $paddingSize));
$popup = TextFormat::WHITE . $paddingPopup . $popup . "\n" . TextFormat::WHITE . $paddingOwnerPopup . $ownerPopup;
}
$event->getPlayer()->sendTip($popup);
}
}
示例9: onMoveEvent
public function onMoveEvent(PlayerMoveEvent $event)
{
$player = $event->getPlayer();
if (($fromLevel = $event->getFrom()->getLevel()->getFolderName()) !== ($toLevel = $event->getTo()->getLevel()->getFolderName())) {
if (isset($this->worlds[$toLevel])) {
$this->players[$event->getPlayer()->getName()] = $toLevel;
$this->getWorldManagerByWorldFolderName($toLevel)->onPlayerMoveToWorld($event->getPlayer());
}
if (isset($this->worlds[$fromLevel])) {
if ($this->players[$event->getPlayer()->getName()] === $fromLevel) {
$this->players[$event->getPlayer()->getName()] = $this->getServer()->getDefaultLevel()->getFolderName();
}
$this->getWorldManagerByWorldFolderName($fromLevel)->onPlayerMoveToAnotherWorld($event->getPlayer(), $toLevel);
}
foreach ($this->npcs as $npc) {
if ($npc->getLevel()->getFolderName() === $toLevel) {
$npc->spawnTo($player);
}
}
}
if (isset($this->worlds[$toLevel])) {
if ($event->getTo()->getY() <= $this->getConfiguration("MIN_Y")) {
$this->worlds[$toLevel]["manager"]->onPlayerDrown($event->getPlayer());
}
}
foreach ($this->npcs as $npc) {
if ($npc->getLevel()->getFolderName() === $event->getPlayer()->getLevel()->getFolderName()) {
$npc->seePlayer($player);
}
}
}
示例10: 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"));
}
}
}
}
示例11: onPlayerMove
public function onPlayerMove(PlayerMoveEvent $event)
{
$player = $event->getPlayer();
if (!isset(self::$players[$player->getName()])) {
return;
}
$xcelPlayer = self::$players[$player->getName()];
if (($fromLevel = $event->getFrom()->getLevel()->getFolderName()) !== ($toLevel = $event->getTo()->getLevel()->getFolderName())) {
if ($xcelPlayer->getGame() !== null) {
$xcelPlayer->getGame()->onPlayerMoveToAnotherWorld($xcelPlayer);
}
if (isset(self::$worlds[$toLevel])) {
self::$worlds[$toLevel]->warpPlayerTo($xcelPlayer);
}
}
}
示例12: onMove
public function onMove(PlayerMoveEvent $e)
{
$p = $e->getPlayer();
if ($this->inArena($p) && $this->game === 0 && (floor($e->getFrom()->x) !== floor($e->getTo()->x) || floor($e->getFrom()->z) !== floor($e->getTo()->z))) {
$e->setCancelled();
return;
}
if ($this->game > 1) {
$e->getHandlers()->unregister($this);
}
}
示例13: onPlayerMove
public function onPlayerMove(PlayerMoveEvent $event)
{
$player = $event->getPlayer();
$x = round($event->getFrom()->x);
$y = round($event->getFrom()->y);
$z = round($event->getFrom()->z);
foreach ($this->plugin->getAvailableLevels() as &$lv) {
if ($lv instanceof GameLevelModel) {
if ($lv->status === GameLevelModel::STATUS_AVAILABLE) {
if ($player->getLevel()->getName() != $lv->levelName) {
continue;
}
if ($lv->portalEnter($this->plugin, $lv, $player)) {
return;
break;
}
} elseif ($lv->currentStep === GameLevelModel::STEP_WAITING) {
if (strtolower($player->level->getName()) === strtolower($lv->currentMap->levelName)) {
$player->onGround = true;
$event->setCancelled(true);
} else {
$player->onGround = false;
}
break;
}
}
}
}
示例14: onPlayerMove
public function onPlayerMove(PlayerMoveEvent $event)
{
$Player = $event->getPlayer();
$Level = $Player->getLevel();
if (!$this->plugin->game || $this->plugin->game->level_name != $Level->getFolderName()) {
return;
}
if ($Player->getGamemode() == Player::SPECTATOR) {
return;
}
$event->setCancelled($this->plugin->game->PlayerMove($event->getPlayer(), $event->getFrom(), $event->getTo()));
$X = $Player->getFloorX();
$Y = intval($Player->getY());
$Z = $Player->getFloorZ();
$Block = $Level->getBlock(new Vector3($X, $Y, $Z));
if ($Block->getId() == 133) {
$Player->setMotion(new Vector3(0, 0, 0));
} elseif ($Block->getId() == 44 && $Block->getDamage() % 8 == 4) {
$Player->setMotion(new Vector3(rand(-50, 50) / 50, rand(100, 250) / 100, rand(-50, 50) / 50));
$Level->setBlock(new Vector3($X, $Y, $Z), Block::get(0), true, true);
} elseif ($Block->getId() == 96 && $Block->getDamage() < 4) {
$Level->getBlock(new Vector3($X, $Y, $Z))->onActivate(Item::get(0));
}
}
示例15: mon_onMove
public function mon_onMove(PlayerMoveEvent $event)
{
$game = Settings::portal($this->getPlayer(), $this->main);
if ($game instanceof Game) {
$this->getPlayer()->getInventory()->clearAll();
if ($game->onJoin($this)) {
$this->tell("You have entered the game: %s", $game->getName());
$this->switchSession($game->getSessionId());
} else {
$this->tell("You are refused to enter this game!");
}
} else {
Settings::portalBoost2($this->getPlayer());
$from = Settings::checkInvisibility($event->getFrom());
$to = Settings::checkInvisibility($event->getTo());
if ($from and !$to) {
$this->setVisible(self::INVISIBLE_SPAWN);
} elseif (!$from and $to) {
$this->setInvisible(self::INVISIBLE_SPAWN);
}
}
}