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


PHP Player::getDirectionVector方法代码示例

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


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

示例1: spawnDiscourager

 public function spawnDiscourager()
 {
     $dir = $this->player->getDirectionVector();
     if ($this->player->pitch > 45 or $this->player->pitch < -45) {
         $face = 0;
         // y
     } else {
         $face = self::$conversionTable[$this->player->getDirection()];
     }
     $center = $this->player->subtract($dir->multiply($this->main->getDistance()))->add(0, $this->player->eyeHeight)->floor();
     $l = $this->player->getLevel();
     if ($face === self::Y) {
         $this->overridenBlocks = [$l->getBlock($center->add(1, 0, 1)), $l->getBlock($center->add(1, 0, 0)), $l->getBlock($center->add(1, 0, -1)), $l->getBlock($center->add(0, 0, 1)), $l->getBlock($center), $l->getBlock($center->add(0, 0, -1)), $l->getBlock($center->add(-1, 0, 1)), $l->getBlock($center->add(-1, 0, 0)), $l->getBlock($center->add(-1, 0, -1))];
     } elseif ($face === self::X) {
         $this->overridenBlocks = [$l->getBlock($center->add(0, 1, 1)), $l->getBlock($center->add(0, 1, 0)), $l->getBlock($center->add(0, 1, -1)), $l->getBlock($center->add(0, 0, 1)), $l->getBlock($center), $l->getBlock($center->add(0, 0, -1)), $l->getBlock($center->add(0, -1, 1)), $l->getBlock($center->add(0, -1, 0)), $l->getBlock($center->add(0, -1, -1))];
     } elseif ($face === self::Z) {
         $this->overridenBlocks = [$l->getBlock($center->add(1, 1, 0)), $l->getBlock($center->add(1, 0, 0)), $l->getBlock($center->add(1, -1, 0)), $l->getBlock($center->add(0, 1, 0)), $l->getBlock($center), $l->getBlock($center->add(0, -1, 0)), $l->getBlock($center->add(-1, 1, 0)), $l->getBlock($center->add(-1, 0, 0)), $l->getBlock($center->add(-1, -1, 0))];
     }
     foreach ($this->overridenBlocks as $b) {
         $pk = new UpdateBlockPacket();
         $pk->x = $b->x;
         $pk->y = $b->y;
         $pk->z = $b->z;
         $pk->block = $this->main->getBlockType()->getId();
         $pk->meta = $this->main->getBlockType()->getDamage();
         $this->player->dataPacket($pk);
     }
 }
开发者ID:barnseyminesuk,项目名称:Small-ZC-Plugins,代码行数:28,代码来源:Session.php

示例2: onActivate

 public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
 {
     if ($player === null or $player->isSurvival() !== true) {
         return false;
     }
     if ($target->getId() === Block::STILL_WATER or $target->getId() === Block::WATER) {
         $player->getServer()->getPluginManager()->callEvent($ev = new PlayerGlassBottleEvent($player, $target, $this));
         if ($ev->isCancelled()) {
             return false;
         } else {
             if ($this->count <= 1) {
                 $player->getInventory()->setItemInHand(Item::get(Item::POTION, 0, 1));
                 return true;
             } else {
                 $this->count--;
                 $player->getInventory()->setItemInHand($this);
             }
             if ($player->getInventory()->canAddItem(Item::get(Item::POTION, 0, 1)) === true) {
                 $player->getInventory()->AddItem(Item::get(Item::POTION, 0, 1));
             } else {
                 $motion = $player->getDirectionVector()->multiply(0.4);
                 $position = clone $player->getPosition();
                 $player->getLevel()->dropItem($position->add(0, 0.5, 0), Item::get(Item::POTION, 0, 1), $motion, 40);
             }
             return true;
         }
     }
     return false;
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:29,代码来源:GlassBottle.php

示例3: onShootRun

 public function onShootRun(array $args, Player $player)
 {
     if (!isset($args[0]) or !is_numeric($args[0])) {
         return self::WRONG_USE;
     }
     $length = floatval(array_shift($args));
     $p1 = $player->getPosition()->floor();
     $p2 = $player->add($player->getDirectionVector()->multiply($length))->floor();
     if ($p1->y < 0 or $p1->y > (defined($path = "pemapmodder\\worldeditart\\MAX_WORLD_HEIGHT") ? constant($path) : 127)) {
         return "You must be inside the building height!";
     } elseif ($p2->y < 0 or $p2->y > (defined($path = "pemapmodder\\worldeditart\\MAX_WORLD_HEIGHT") ? constant($path) : 127)) {
         return "The selected area exceeded the world height limit!";
     }
     $player->getLevel()->loadChunk($p2->x >> 4, $p2->z >> 4);
     while (isset($args[0])) {
         $arg = array_shift($args);
         switch ($arg) {
             case "a":
             case "adverse":
                 $cache = [$p1, $p2];
                 $p1 = $cache[1];
                 $p2 = $cache[0];
                 break;
         }
     }
     $level = $player->getLevel();
     $this->getMain()->setSelection($player, $sel = new CuboidSpace($p1 = Position::fromObject($p1, $level), $p2 = Position::fromObject($p2, $level)));
     return "Cuboid selection set: {$sel} (" . count($sel->getPosList()) . " blocks)";
 }
开发者ID:barnseyminesuk,项目名称:Small-ZC-Plugins,代码行数:29,代码来源:Cuboid.php

示例4: launch

 public function launch(Player $player)
 {
     $dir = $player->getDirectionVector();
     $frontPos = $player->add($dir->multiply(1.1));
     $nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $frontPos->x), new Double("", $frontPos->y + $player->getEyeHeight()), new Double("", $frontPos->z)]), "Motion" => new Enum("Motion", [new Double("", $dir->x), new Double("", $dir->y), new Double("", $dir->z)]), "Rotation" => new Enum("Rotation", [new Float("", 0), new Float("", 0)])]);
     $f = $this->f;
     $launched = Entity::createEntity($this->getEntityName(), $player->chunk, $nbt);
     $launched->setMotion($launched->getMotion()->multiply($f));
     if ($launched instanceof Projectile) {
         $player->server->getPluginManager()->callEvent($projectileEv = new ProjectileLaunchEvent($launched));
         if ($projectileEv->isCancelled()) {
             $launched->kill();
         } else {
             $launched->spawnToAll();
             $player->level->addSound(new LaunchSound($player), $player->getViewers());
         }
     } else {
         $launched->spawnToAll();
     }
 }
开发者ID:kiyoshi-kurosaki,项目名称:ClearSky,代码行数:20,代码来源:Launchable.php

示例5: fire

 private function fire(Player $c, $fuse, $speed)
 {
     $pos = $c->getPosition();
     $pos->y += $c->getEyeHeight();
     $dir = $c->getDirectionVector();
     $dir->x = $dir->x * $speed;
     $dir->y = $dir->y * $speed;
     $dir->z = $dir->z * $speed;
     $this->scorchit($pos, $dir, $fuse);
 }
开发者ID:DWWf,项目名称:pocketmine-plugins,代码行数:10,代码来源:Main.php

示例6: addItem

 public function addItem(Item $item, Player $player, Item $result)
 {
     if ($item->getCount() <= 1) {
         $player->getInventory()->setItemInHand($result);
     } else {
         $item->setCount($item->getCount() - 1);
         if ($player->getInventory()->canAddItem($result) === true) {
             $player->getInventory()->addItem($result);
         } else {
             $motion = $player->getDirectionVector()->multiply(0.4);
             $position = clone $player->getPosition();
             $player->getLevel()->dropItem($position->add(0, 0.5, 0), $result, $motion, 40);
         }
     }
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:15,代码来源:Cauldron.php


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