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


PHP Player::getDirection方法代码示例

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


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

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     $faces = [0 => 4, 1 => 2, 2 => 5, 3 => 3];
     $chest = null;
     $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
     for ($side = 2; $side <= 5; ++$side) {
         if (($this->meta === 4 or $this->meta === 5) and ($side === 4 or $side === 5)) {
             continue;
         } elseif (($this->meta === 3 or $this->meta === 2) and ($side === 2 or $side === 3)) {
             continue;
         }
         $c = $this->getSide($side);
         if ($c instanceof Chest and $c->getDamage() === $this->meta) {
             $tile = $this->getLevel()->getTile($c);
             if ($tile instanceof TileChest and !$tile->isPaired()) {
                 $chest = $tile;
                 break;
             }
         }
     }
     $this->getLevel()->setBlock($block, $this, true, true);
     $nbt = new Compound(false, [new Enum("Items", []), new String("id", Tile::CHEST), new Int("x", $this->x), new Int("y", $this->y), new Int("z", $this->z)]);
     $nbt->Items->setTagType(NBT::TAG_Compound);
     $tile = Tile::createTile("Chest", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
     if ($chest instanceof TileChest and $tile instanceof TileChest) {
         $chest->pairWith($tile);
         $tile->pairWith($chest);
     }
     return true;
 }
开发者ID:rryy,项目名称:PocketMine-MP,代码行数:30,代码来源:Chest.php

示例3: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     $faces = [0 => 0, 1 => 1, 2 => 2, 3 => 3];
     $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
     $this->getLevel()->setBlock($block, $this, true);
     return true;
 }
开发者ID:Creeperface01,项目名称:ImagicalMine,代码行数:7,代码来源:UnlitRedstoneComparator.php

示例4: onActivate

 public function onActivate(Item $item, Player $player = \null)
 {
     $faces = [0 => 3, 1 => 0, 2 => 1, 3 => 2];
     $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0] & 0x3 | ~$this->meta & 0x4;
     $this->getLevel()->setBlock($this, $this, \true);
     return \true;
 }
开发者ID:Edwardthedog2,项目名称:Steadfast2,代码行数:7,代码来源:FenceGate.php

示例5: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     $direction = ($player !== null ? $player->getDirection() : 0) & 0x3;
     $this->meta = $this->meta & 0xc | $direction;
     $this->getLevel()->setBlock($block, $this, true, true);
     $this->getLevel()->addSound(new AnvilFallSound($this));
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:7,代码来源:Anvil.php

示例6: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($player instanceof Player) {
         $pitch = $player->getPitch();
         if (abs($pitch) >= 45) {
             if ($pitch < 0) {
                 $f = 0;
             } else {
                 $f = 1;
             }
         } else {
             $f = $player->getDirection() + 2;
         }
     } else {
         $f = 0;
     }
     $faces = [0 => 0, 1 => 1, 2 => 4, 3 => 2, 4 => 5, 5 => 3];
     $this->meta = $faces[$f];
     $this->getLevel()->setBlock($block, $this, true, true);
     $nbt = new CompoundTag("", [new ListTag("Items", []), new StringTag("id", Tile::DROPPER), new IntTag("x", $this->x), new IntTag("y", $this->y), new IntTag("z", $this->z)]);
     $nbt->Items->setTagType(NBT::TAG_Compound);
     if ($item->hasCustomName()) {
         $nbt->CustomName = new StringTag("CustomName", $item->getCustomName());
     }
     if ($item->hasCustomBlockData()) {
         foreach ($item->getCustomBlockData() as $key => $v) {
             $nbt->{$key} = $v;
         }
     }
     Tile::createTile(Tile::DROPPER, $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
     return true;
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:32,代码来源:Dropper.php

示例7: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = \null)
 {
     $faces = [0 => 0, 1 => 1, 2 => 0, 3 => 1];
     $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
     //for($side = 2; $side <= 5; ++$side){}
     $this->getLevel()->setBlock($block, $this, \true, \true);
     return \true;
 }
开发者ID:kazuemon,项目名称:NIGHTMARE,代码行数:8,代码来源:NetherPortal.php

示例8: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($player instanceof Player) {
         $this->meta = ((int) $player->getDirection() + 5) % 4;
     }
     $this->getLevel()->setBlock($block, $this, true, true);
     return true;
 }
开发者ID:boybook,项目名称:PocketMine-MP,代码行数:8,代码来源:Pumpkin.php

示例9: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($this->id === self::ANVIL) {
         $this->meta = ($player instanceof Player ? $player->getDirection() : 0) + $this->meta;
     }
     $ret = $this->getLevel()->setBlock($this, $this, true, true);
     return $ret;
 }
开发者ID:harukin0731,项目名称:PocketMine-0.13.x,代码行数:8,代码来源:Fallable.php

示例10: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($target->isTransparent() === false) {
         $faces = [3 => 3, 2 => 4, 4 => 2, 5 => 1];
         if ($face === 0) {
             $to = $player instanceof Player ? $player->getDirection() : 0;
             $this->meta = $to ^ 0x1 === 0x1 ? 0 : 7;
         } elseif ($face === 1) {
             $to = $player instanceof Player ? $player->getDirection() : 0;
             $this->meta = $to ^ 0x1 === 0x1 ? 6 : 5;
         } else {
             $this->meta = $faces[$face];
         }
         $this->getLevel()->setBlock($block, $this, true, true);
         return true;
     }
     return false;
 }
开发者ID:funnycars,项目名称:ImagicalMine,代码行数:18,代码来源:Lever.php

示例11: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($target->isTransparent() === false) {
         $faces = [0 => 0, 1 => 1, 2 => 2, 3 => 3];
         $damage = $this->getDamage();
         $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0] & 0x4;
         if ($damage >= 0 && $damage <= 3) {
             $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
         } elseif ($damage >= 4 && $damage <= 7) {
             $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0] | 0x4;
         } elseif ($damage >= 8 && $damage <= 11) {
             $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0] | 0x8;
         }
         $this->getLevel()->setBlock($block, $this, true);
         return true;
     }
     return false;
 }
开发者ID:orlando092,项目名称:ImagicalMine,代码行数:18,代码来源:AnvilBlock.php

示例12: onRun

 public function onRun(array $args, Player $player)
 {
     if (!isset($args[0])) {
         return self::WRONG_USE;
     }
     $center = $player->floor();
     $level = $player->getLevel();
     $radius = floatval(array_shift($args));
     $height = (int) array_shift($args);
     $axis = WorldEditArt::directionNumber2Array($player->getDirection());
     while (count($args) > 0) {
         $arg = array_shift($args);
         switch ($arg) {
             case "a":
             case "anchor":
                 $anchor = $this->getMain()->getAnchor($player);
                 if (!$anchor instanceof Position) {
                     return self::NO_ANCHOR;
                 }
                 $center = $anchor->floor();
                 break;
             case "d":
                 $d = array_shift($args);
                 switch (strtolower($d)) {
                     case "m":
                     case "me":
                         break;
                     case "u":
                     case "up":
                         $axis = [CylinderSpace::Y, CylinderSpace::PLUS];
                         break;
                     case "d":
                     case "down":
                         $axis = [CylinderSpace::Y, CylinderSpace::MINUS];
                         break;
                     case "l":
                     case "left":
                         $axis = WorldEditArt::directionNumber2Array(WorldEditArt::rotateDirectionNumberClockwise($player->getDirection(), 3));
                         break;
                     case "r":
                     case "right":
                         $axis = WorldEditArt::directionNumber2Array(WorldEditArt::rotateDirectionNumberClockwise($player->getDirection(), 1));
                         break;
                     case "b":
                     case "back":
                         $axis = WorldEditArt::directionNumber2Array(WorldEditArt::rotateDirectionNumberClockwise($player->getDirection(), 2));
                         break;
                 }
                 break;
         }
     }
     $center = Position::fromObject($center, $level);
     $space = new CylinderSpace($axis[0], $radius, $center, $height * $axis[1]);
     $this->getMain()->setSelection($player, $space);
     return "Your selection is now {$space}.";
 }
开发者ID:barnseyminesuk,项目名称:Small-ZC-Plugins,代码行数:56,代码来源:Cylinder.php

示例13: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($target->isTransparent() === false) {
         $faces = [2 => 3, 3 => 0, 0 => 1, 1 => 2];
         $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
         $this->getLevel()->setBlock($block, $this, true, true);
         return true;
     }
     return false;
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:10,代码来源:RedstoneComparator.php

示例14: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     $faces = [0 => 4, 1 => 2, 2 => 5, 3 => 3];
     $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
     $this->getLevel()->setBlock($block, $this, true, true);
     $nbt = new Compound("", [new Enum("Items", []), new String("id", Tile::FURNACE), new Int("x", $this->x), new Int("y", $this->y), new Int("z", $this->z)]);
     $nbt->Items->setTagType(NBT::TAG_Compound);
     Tile::createTile("Furnace", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
     return true;
 }
开发者ID:JungHyun3459,项目名称:PocketMine-MP,代码行数:10,代码来源:BurningFurnace.php

示例15: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     $down = $block->getSide(0);
     if ($down->getId() === self::AIR) {
         return false;
     }
     $faces = [0 => 3, 1 => 0, 2 => 1, 3 => 2];
     $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0] & 0x3;
     $this->getLevel()->setBlock($block, $this, true, true);
     return true;
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:11,代码来源:FenceGate.php


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