本文整理汇总了PHP中pocketmine\Player::getEyeHeight方法的典型用法代码示例。如果您正苦于以下问题:PHP Player::getEyeHeight方法的具体用法?PHP Player::getEyeHeight怎么用?PHP Player::getEyeHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\Player
的用法示例。
在下文中一共展示了Player::getEyeHeight方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: burstArrow
public function burstArrow(Player $player)
{
if ($player->getInventory()->getItemInHand()->getId() === Item::BOW) {
$bow = $player->getInventory()->getItemInHand();
$nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $player->x), new Double("", $player->y + $player->getEyeHeight()), new Double("", $player->z)]), "Motion" => new Enum("Motion", [new Double("", -\sin($player->yaw / 180 * M_PI) * \cos($player->pitch / 180 * M_PI)), new Double("", -\sin($player->pitch / 180 * M_PI)), new Double("", \cos($player->yaw / 180 * M_PI) * \cos($player->pitch / 180 * M_PI))]), "Rotation" => new Enum("Rotation", [new Float("", $player->yaw), new Float("", $player->pitch)])]);
$ev = new EntityShootBowEvent($player, $bow, Entity::createEntity("Arrow", $player->chunk, $nbt, $player), 1.5);
$this->getServer()->getPluginManager()->callEvent($ev);
if ($ev->isCancelled()) {
$ev->getProjectile()->kill();
} else {
$ev->getProjectile()->setMotion($ev->getProjectile()->getMotion()->multiply($ev->getForce()));
if ($ev->getProjectile() instanceof Projectile) {
$this->getServer()->getPluginManager()->callEvent($projectileEv = new ProjectileLaunchEvent($ev->getProjectile()));
if ($projectileEv->isCancelled()) {
$ev->getProjectile()->kill();
} else {
$this->object_hash[spl_object_hash($ev->getProjectile())] = 1;
$ev->getProjectile()->spawnToAll();
}
} else {
$this->object_hash[spl_object_hash($ev->getProjectile())] = 1;
$ev->getProjectile()->spawnToAll();
}
}
}
}
示例2: launch
public function launch(Player $player)
{
$nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $player->x), new Double("", $player->y + $player->getEyeHeight()), new Double("", $player->z)]), "Motion" => new Enum("Motion", [new Double("", -sin($player->yaw / 180 * M_PI) * cos($player->pitch / 180 * M_PI)), new Double("", -sin($player->pitch / 180 * M_PI)), new Double("", cos($player->yaw / 180 * M_PI) * cos($player->pitch / 180 * M_PI))]), "Rotation" => new Enum("Rotation", [new Float("", $player->yaw), new Float("", $player->pitch)]), "Data" => new Byte("Data", $this->getDamage())]);
$f = $this->f;
$launched = Entity::createEntity($this->getEntityName(), $player->chunk, $nbt, $player);
$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();
}
return true;
}
示例3: 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();
}
}
示例4: 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);
}
示例5: shootArrow
/**
*
* @param Player $player
* @param Position $fromPos
*/
public static function shootArrow(Player $player, Position $fromPos)
{
$nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $fromPos->x), new Double("", $fromPos->y + $player->getEyeHeight()), new Double("", $fromPos->z)]), "Motion" => new Enum("Motion", [new Double("", -\sin($player->yaw / 180 * M_PI) * \cos($player->pitch / 180 * M_PI)), new Double("", -\sin($player->pitch / 180 * M_PI)), new Double("", \cos($player->yaw / 180 * M_PI) * \cos($player->pitch / 180 * M_PI))]), "Rotation" => new Enum("Rotation", [new Float("", $player->yaw), new Float("", $player->pitch)])]);
$diff = 3;
$p = $diff / 20;
$f = \min(($p * 2 + $p * 2) / 3, 1) * 2;
$ev = new EntityShootBowEvent($player, Item::get(Item::BOW), Entity::createEntity("Arrow", $player->chunk, $nbt, $player, $f == 2 ? \true : \false), $f);
$ev->getProjectile()->spawnToAll();
$player->level->addSound(new LaunchSound($player), $player->getViewers());
}
示例6: isInsidePortal
public function isInsidePortal(Player $player)
{
$block = $player->getLevel()->getBlock($player->temporalVector->setComponents(Math::floorFloat($player->x), Math::floorFloat($y = $player->y + $player->getEyeHeight()), Math::floorFloat($player->z)));
return $block->getId() == 90;
}
示例7: touch
public function touch(Player $damager, Player $entity)
{
$damagerGameId = $this->players[$damager->getName()];
$entityGameId = $this->players[$entity->getName()];
if ($damagerGameId === $entityGameId && $damagerGameId !== "NONE") {
$returnVal = $this->games[$damagerGameId]->touch($damager->getName(), $entity->getName());
switch ($returnVal) {
case GameManager::RETURNTYPE_TOUCH_ALREADY_TOUCED_FAILED:
$damager->sendMessage(TextFormat::RED . $this->getTranslation("TOUCH_ALREADY_TOUCHED"));
break;
case GameManager::RETURNTYPE_TOUCH_IN_PREPARATION_OR_REST_FAILED:
$damager->sendMessage(TextFormat::RED . $this->getTranslation("PREPARATION_OR_REST"));
break;
case GameManager::RETURNTYPE_TOUCH_SUCCEED:
$this->notifyTipForPlayers($damagerGameId, TextFormat::DARK_PURPLE . $this->getTranslation("TOUCH_MESSAGE", $damager->getName(), $entity->getName()));
$this->notifyForPlayers($damagerGameId, TextFormat::DARK_PURPLE . $this->getTranslation("TOUCH_MESSAGE", $damager->getName(), $entity->getName()));
$this->createTouchEffect($entity->getLocation(), $entity->getEyeHeight(), $damager->getLocation(), $damager->getEyeHeight());
break;
}
return $returnVal;
}
return false;
}
示例8: __construct
public function __construct(Player $player, Item $item)
{
parent::__construct($player->getLevel()->getChunk($player->x >> 4, $player->z >> 4), new Compound("", ["Pos" => new Enum("Pos", [new Double("", $player->x), new Double("", $player->y + $player->getEyeHeight()), new Double("", $player->z)]), "Motion" => new Enum("Motion", [new Double("", 0), new Double("", 0), new Double("", 0)]), "Rotation" => new Enum("Rotation", [new Float("", 0), new Float("", 0)])]));
$this->item = $item->getID() == 0 ? Item::get(1000, 0, 0) : $item;
$this->player = $player;
$this->yaw = $player->getYaw();
$this->pitch = $player->getPitch();
parent::spawnToAll();
}