本文整理汇总了PHP中pocketmine\command\CommandSender::getPitch方法的典型用法代码示例。如果您正苦于以下问题:PHP CommandSender::getPitch方法的具体用法?PHP CommandSender::getPitch怎么用?PHP CommandSender::getPitch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\command\CommandSender
的用法示例。
在下文中一共展示了CommandSender::getPitch方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $sub)
{
$mm = "[TeleportView] ";
if ($sender->getName() == "CONSOLE") {
$sender->sendMessage($mm . ($this->isKorean() ? "게임내에서만 사용가능합니다." : "Please run this command in-game"));
return true;
}
$yaw = $sender->getYaw();
$pitch = $sender->getPitch();
$yawS = -sin($yaw / 180 * M_PI);
$yawC = cos($yaw / 180 * M_PI);
$pitchS = -sin($pitch / 180 * M_PI);
$pitchC = cos($pitch / 180 * M_PI);
$x = $sender->x;
$y = $sender->y + $sender->getEyeHeight();
$z = $sender->z;
$l = $sender->getLevel();
$ps = $this->getServer()->getOnlinePlayers();
for ($f = 0; $f < 50; ++$f) {
$x += $yawS * $pitchC;
$y += $pitchS;
$z += $yawC * $pitchC;
$b = $l->getBlock(new Position($x, $y, $z, $l));
if ($b->isSolid()) {
break;
}
if ($f >= 50) {
$sender->sendMessage($mm . ($this->isKorean() ? "타겟 블럭이 너무 멉니다." : "TargetBlock is too far"));
return true;
}
}
$sender->teleport(new Position($x, $y, $z, $sender->getLevel()));
return true;
}
示例2: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $sub)
{
$mm = "[TeleportView] ";
if ($sender->getName() == "CONSOLE") {
$sender->sendMessage($mm . ($this->isKorean() ? "게임내에서만 사용가능합니다." : "Please run this command in-game"));
return true;
}
$yaw = $sender->getYaw();
$ptch = $sender->getPitch();
$yawS = -sin($yaw / 180 * M_PI);
$yawC = cos($yaw / 180 * M_PI);
$ptchS = -sin($ptch / 180 * M_PI);
$ptchC = cos($ptch / 180 * M_PI);
$x = $sender->getX();
$y = $sender->getY() + $sender->getEyeHeight();
$z = $sender->getZ();
$l = $sender->getLevel();
for ($f = 0; $f < 50; ++$f) {
$x += $yawS * $ptchC;
$y += $ptchS;
$z += $yawC * $ptchC;
$b = $l->getBlock(new Position($x, $y, $z, $l));
if ($b->isSolid) {
$sender->teleport(new Position($x - $yawS * $ptchC, $y - $ptchS + 0.1, $z - $yawC * $ptchC, $l));
$f = true;
}
}
if (!isset($f)) {
$sender->sendMessage($mm . ($this->isKorean() ? "타겟 블럭이 너무 멉니다." : "TargetBlock is too far"));
}
return true;
}
示例3: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
$this->getLogger()->info("test");
if ($command->getName() == "pk") {
if ($args[0] == "join") {
if (isset($args[1])) {
if (isset($this->arenas[strtolower($args[1])]) and substr(strtolower($args[1]), -5) != "_race") {
if (!isset($this->activeplayers[$sender->getName()])) {
$this->activeplayers[$sender->getName()] = array("current-map" => strtolower($args[1]), "last-set" => 0, "micro-seconds" => 0, "active" => false, "current-checkpoint" => 0);
$sender->teleport($this->arenas[strtolower($args[1])]->getStartPosition());
$sender->setRotation($this->arenas[strtolower($args[1])]->getStartYaw(), $sender->getPitch());
$sender->sendMessage("§cYou have started the map '§b" . $this->arenas[strtolower($args[1])]->getMapName() . "§c'.");
} else {
$sender->sendMessage("§cYou are currently still playing a different map\n§cUse §b/pk leave§c to leave this map.");
}
} else {
$sender->sendMessage("§cThe map '§b" . strtolower($args[1]) . "§c' doesn't exist.");
}
} else {
$sender->sendMessage("§cUsage: §b/pk join [map name]");
}
} else {
if ($args[0] == "leave") {
if (isset($this->activeplayers[$sender->getName()])) {
unset($this->activeplayers[$sender->getName()]);
$sender->sendMessage("§cYou have left your current map.");
} else {
$sender->sendMessage("§cYou aren't currently playing any maps.");
}
} else {
if ($args[0] == "info") {
if (isset($args[1])) {
if (isset($this->arenas[strtolower($args[1])])) {
$map = $this->arenas[strtolower($args[1])];
$currentlyplaying = array();
foreach ($this->activeplayers as $player => $name) {
if ($name['current-map'] == strtolower($args[1])) {
array_push($currentlyplaying, $player);
}
}
$sender->sendMessage("§cMap info:\n§cMap name: §b" . $map->getMapName() . "\n§cMap maker: §b" . $map->getMapMaker() . "\n§cDate of creation: §b" . $map->getDateOfCreation() . "\n§cMap world name: §b" . $map->getMapLevel()->getName() . "\n§cYour current highscore: §b" . ($map->getTime($sender) === null ? "none" : $map->getTime($sender)) . "\n§cCurrently playing: §b" . implode(", ", $currentlyplaying) . "\n§cFor leaderboards, please type §b/pk topten " . strtolower($args[1]));
} else {
$sender->sendMessage("§cThis map doesn't exist.");
}
} else {
$sender->sendMessage("§cUsage: §b/pk info [map name]");
}
} else {
if ($args[0] == "topten") {
if (isset($args[1])) {
if (isset($this->arenas[strtolower($args[1])])) {
$sender->sendMessage("§cTop ten laps of the map §b" . $this->arenas[strtolower($args[1])]->getMapName() . "§c:");
$count = 0;
foreach ($this->arenas[strtolower($args[1])]->getTopTen() as $player) {
$count++;
$sender->sendMessage("§c" . $count . ") §b" . $player['username'] . "§c with §b" . $player['highscore']);
}
} else {
$sender->sendMessage("§cThis map doesn't exist.");
}
} else {
$sender->sendMessage("§cUsage: §b/pk topten [map name]");
}
}
}
}
}
if ($args[0] == "create") {
if (isset($args[1])) {
$this->arenaconf->set($args[1], array("date-of-creation" => date("d/m/Y"), "map-maker" => $sender->getName(), "level" => $sender->getLevel()->getName(), "floor-y" => 0, "start-position" => array("x" => 0, "y" => 0, "z" => 0, "yaw" => 360), "timer-block" => array("x" => 0, "y" => 0, "z" => 0), "end-block" => array("x" => 0, "y" => 0, "z" => 0)));
$sender->sendMessage("§cNew map '§b" . $args[1] . "§c' has been created.\n§cPlease use the follwing command to set the start position:\n§b/pk setstart " . strtolower($args[1]));
} else {
$sender->sendMessage("§cUsage: §b/pk create [map name]");
}
} else {
if ($args[0] == "setstart") {
if (isset($args[1])) {
if ($this->arenaconf->exists($args[1])) {
$newmap = $this->arenaconf->get($args[1]);
$newmap['start-position'] = array("x" => $sender->getFloorX(), "y" => $sender->getFloorY(), "z" => $sender->getFloorZ(), $sender->getYaw());
$this->arenaconf->set($args[1], $newmap);
$sender->sendMessage("§cAwesome! Now use the follwing command to set the floor that will reset you once you fall below/on it.\n§b/pk setfloor " . strtolower($args[1]));
} else {
$sender->sendMessage("§cThis map doesn't exist.");
}
} else {
$sender->sendMessage("§cUsage: §b/pk setfloor [map name]");
}
} else {
if ($args[0] == "setfloor") {
if (isset($args[1])) {
if ($this->arenaconf->exists($args[1])) {
$newmap = $this->arenaconf->get($args[1]);
$newmap['floor-y'] = $sender->getFloorY();
$this->arenaconf->set($args[1], $newmap);
$sender->sendMessage("§cGreat! Now use the follwing command to set the timer start position.\n§b/pk settimer " . strtolower($args[1]));
} else {
$sender->sendMessage("§cThis map doesn't exist.");
}
} else {
//.........这里部分代码省略.........
示例4: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
switch ($command->getName()) {
case 'nothing':
return true;
break;
case 'rca':
if (count($args) < 2) {
$sender->sendMessage("Please enter a player and a command.");
return false;
}
$player = $this->getServer()->getPlayer($tuv = array_shift($args));
if (!($player == null)) {
$commandForSudo = trim(implode(" ", $args));
$this->getServer()->dispatchCommand($player, $commandForSudo);
return true;
break;
}
$sender->sendMessage(TextFormat::RED . "Player not found.");
return true;
break;
case "slapper":
if ($sender instanceof Player) {
$name = trim(implode(" ", $args));
$defaultName = $sender->getDisplayName();
if ($name == null) {
$name = $defaultName;
}
$senderSkin = $sender->getSkinData();
$IsSlim = $sender->isSkinSlim();
$playerX = $sender->getX();
$playerY = $sender->getY();
$playerZ = $sender->getZ();
$outX = round($playerX, 1);
$outY = round($playerY, 1);
$outZ = round($playerZ, 1);
$playerLevel = $sender->getLevel()->getName();
$playerYaw = $sender->getYaw();
$playerPitch = $sender->getPitch();
$humanInv = $sender->getInventory();
$pHealth = $sender->getHealth();
$nbt = new Compound();
$motion = new Vector3(0, 0, 0);
$nbt->Pos = new Enum("Pos", [new Double("", $playerX), new Double("", $playerY), new Double("", $playerZ)]);
$nbt->Motion = new Enum("Motion", [new Double("", $motion->x), new Double("", $motion->y), new Double("", $motion->z)]);
$nbt->Rotation = new Enum("Rotation", [new Float("", $playerYaw), new Float("", $playerPitch)]);
$nbt->Health = new Short("Health", $pHealth);
$nbt->Inventory = new Enum("Inventory", $humanInv);
$nbt->NameTag = new String("name", $name);
$nbt->Invulnerable = new Byte("Invulnerable", 1);
$nbt->CustomTestTag = new Byte("CustomTestTag", 1);
$nbt->Skin = new Compound("Skin", ["Data" => new String("Data", $senderSkin), "Slim" => new Byte("Slim", $IsSlim)]);
$clonedHuman = Entity::createEntity("Human", $sender->getLevel()->getChunk($playerX >> 4, $playerZ >> 4), $nbt);
$Inv = $clonedHuman->getInventory();
$sender->sendMessage(TextFormat::GREEN . "[" . TextFormat::YELLOW . "Slapper" . TextFormat::GREEN . "] " . "Human entity spawned with name " . TextFormat::WHITE . "\"" . TextFormat::BLUE . $name . TextFormat::WHITE . "\"");
$pHelm = $humanInv->getHelmet();
$pChes = $humanInv->getChestplate();
$pLegg = $humanInv->getLeggings();
$pBoot = $humanInv->getBoots();
$Inv->setHelmet($pHelm);
$Inv->setChestplate($pChes);
$Inv->setLeggings($pLegg);
$Inv->setBoots($pBoot);
$clonedHuman->getInventory()->setHeldItemSlot($sender->getInventory()->getHeldItemSlot());
$clonedHuman->getInventory()->setItemInHand($sender->getInventory()->getItemInHand());
$clonedHuman->spawnToAll();
return true;
} else {
$sender->sendMessage("This command only works in game.");
return true;
}
}
}
示例5: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
switch (strtolower($command->getName())) {
case 'nothing':
return true;
break;
case 'rca':
if (count($args) < 2) {
$sender->sendMessage("Please enter a player and a command.");
return true;
}
$player = $this->getServer()->getPlayer(array_shift($args));
if (!($player === null)) {
$this->getServer()->dispatchCommand($player, trim(implode(" ", $args)));
return true;
break;
}
$sender->sendMessage(TextFormat::RED . "Player not found.");
return true;
break;
case "slapper":
if ($sender instanceof Player) {
$type = array_shift($args);
$name = str_replace("{color}", "§", str_replace("{line}", "\n", trim(implode(" ", $args))));
if ($type === null || $type === "" || $type === " ") {
return false;
}
$defaultName = $sender->getDisplayName();
if ($name == null) {
$name = $defaultName;
}
$senderSkin = $sender->getSkinData();
$isSlim = $sender->isSkinSlim();
$playerX = $sender->getX();
$playerY = $sender->getY();
$playerZ = $sender->getZ();
$playerYaw = $sender->getYaw();
$playerPitch = $sender->getPitch();
$humanInv = $sender->getInventory();
$theOne = "Blank";
$nameToSay = "Human";
$didMatch = "No";
foreach (["Chicken", "ZombiePigman", "Pig", "Sheep", "Cow", "Mooshroom", "MushroomCow", "Wolf", "Enderman", "Spider", "Skeleton", "PigZombie", "Creeper", "Slime", "Silverfish", "Villager", "Zombie", "Human", "Player", "Squid", "Bat", "CaveSpider", "LavaSlime"] as $entityType) {
if (strtolower($type) === strtolower($entityType)) {
$didMatch = "Yes";
$theOne = $entityType;
}
}
$typeToUse = "Nothing";
if ($theOne === "Human") {
$typeToUse = "SlapperHuman";
}
if ($theOne === "Player") {
$typeToUse = "SlapperHuman";
}
if ($theOne === "Pig") {
$typeToUse = "SlapperPig";
}
if ($theOne === "Bat") {
$typeToUse = "SlapperBat";
}
if ($theOne === "Cow") {
$typeToUse = "SlapperCow";
}
if ($theOne === "Sheep") {
$typeToUse = "SlapperSheep";
}
if ($theOne === "MushroomCow") {
$typeToUse = "SlapperMushroomCow";
}
if ($theOne === "Mooshroom") {
$typeToUse = "SlapperMushroomCow";
}
if ($theOne === "LavaSlime") {
$typeToUse = "SlapperLavaSlime";
}
if ($theOne === "Enderman") {
$typeToUse = "SlapperEnderman";
}
if ($theOne === "Zombie") {
$typeToUse = "SlapperZombie";
}
if ($theOne === "Creeper") {
$typeToUse = "SlapperCreeper";
}
if ($theOne === "Skeleton") {
$typeToUse = "SlapperSkeleton";
}
if ($theOne === "Silverfish") {
$typeToUse = "SlapperSilverfish";
}
if ($theOne === "Chicken") {
$typeToUse = "SlapperChicken";
}
if ($theOne === "Villager") {
$typeToUse = "SlapperVillager";
}
if ($theOne === "CaveSpider") {
$typeToUse = "SlapperCaveSpider";
}
//.........这里部分代码省略.........