本文整理汇总了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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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));
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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}.";
}
示例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;
}
示例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;
}
示例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;
}