本文整理汇总了PHP中pocketmine\Player::getLevel方法的典型用法代码示例。如果您正苦于以下问题:PHP Player::getLevel方法的具体用法?PHP Player::getLevel怎么用?PHP Player::getLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\Player
的用法示例。
在下文中一共展示了Player::getLevel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMaskLocation
public function getMaskLocation(Player $player)
{
// always return player current location if there is an error
if (!$this->maskLoc) {
return $player->getLocation();
}
if (!preg_match('#^((\\?spawn\\?)|((\\-)?[0-9]+,(\\-)?[0-9]+,(\\-)?[0-9]+))@([^/\\\\]+)$#', $this->maskLocPos, $match)) {
return $player->getLocation();
}
$pos = $match[1];
$world = $match[7];
$level = $player->getLevel();
if ($world === "?default?") {
$level = $player->getServer()->getDefaultLevel();
} elseif ($world !== "?current?") {
$level = $player->getServer()->getLevelByName($world);
if (!$level instanceof Level) {
$level = $player->getLevel();
}
}
if ($pos === "?spawn?") {
$position = $level->getSpawnLocation();
} else {
list($x, $y, $z) = explode(",", $pos);
$position = new Position((int) $x, (int) $y, (int) $z, $level);
}
return $position;
}
示例2: 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);
}
}
示例3: CritParticle
public function CritParticle(Player $player)
{
$x = $player->x;
$y = $player->y;
$z = $player->z;
$player->getLevel()->addParticle(new CriticalParticle(new Vector3($x, $y + 1, $z - 1)));
$player->getLevel()->addParticle(new CriticalParticle(new Vector3($x, $y + 1, $z - 0.9)));
$player->getLevel()->addParticle(new CriticalParticle(new Vector3($x, $y + 1, $z - 1.1)));
}
示例4: onActivate
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
{
if ($target->isTransparent() === false and $face > 1 and $block->isSolid() === false) {
$faces = [2 => 0, 3 => 2, 4 => 1, 5 => 3];
$motives = [["Kebab", 1, 1], ["Aztec", 1, 1], ["Alban", 1, 1], ["Aztec2", 1, 1], ["Bomb", 1, 1], ["Plant", 1, 1], ["Wasteland", 1, 1], ["Wanderer", 1, 2], ["Graham", 1, 2], ["Pool", 2, 1], ["Courbet", 2, 1], ["Sunset", 2, 1], ["Sea", 2, 1], ["Creebet", 2, 1], ["Match", 2, 2], ["Bust", 2, 2], ["Stage", 2, 2], ["Void", 2, 2], ["SkullAndRoses", 2, 2], ["Fighters", 4, 2], ["Skeleton", 4, 3], ["DonkeyKong", 4, 3], ["Pointer", 4, 4], ["Pigscene", 4, 4], ["Flaming Skull", 4, 4]];
$motive = $motives[mt_rand(0, count($motives) - 1)];
$data = ["x" => $target->x, "y" => $target->y + 0.4, "z" => $target->z, "yaw" => $faces[$face] * 90, "Motive" => $motive[0]];
$nbt = new CompoundTag("", ["Motive" => new StringTag("Motive", $data["Motive"]), "Pos" => new EnumTag("Pos", [new DoubleTag("", $data["x"]), new DoubleTag("", $data["y"]), new DoubleTag("", $data["z"])]), "Motion" => new EnumTag("Motion", [new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0)]), "Rotation" => new EnumTag("Rotation", [new FloatTag("", $data["yaw"]), new FloatTag("", 0)])]);
$painting = new PaintingEntity($player->getLevel()->getChunk($block->getX() >> 4, $block->getZ() >> 4), $nbt);
$painting->spawnToAll();
if ($player->isSurvival()) {
$item = $player->getInventory()->getItemInHand();
$count = $item->getCount();
if (--$count <= 0) {
$player->getInventory()->setItemInHand(Item::get(Item::AIR));
return;
}
$item->setCount($count);
$player->getInventory()->setItemInHand($item);
}
//TODO
//$e = $server->api->entity->add($level, ENTITY_OBJECT, OBJECT_PAINTING, $data);
//$e->spawnToAll();
/*if(($player->gamemode & 0x01) === 0x00){
$player->removeItem(Item::get($this->getId(), $this->getDamage(), 1));
}*/
return true;
}
return false;
}
示例5: 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;
}
示例6: handle
private function handle($cmd, $args, Player $player, CommandSender $issuer)
{
switch ($cmd) {
case "getping":
$issuer->sendMessage("Ping of " . $player->getName() . ": unknown ms");
return true;
case "seearmor":
$issuer->sendMessage("Armor of " . $player->getName() . ":");
$issuer->sendMessage("Helmet: " . $this->formatItem($player->getInventory()->getArmorItem(0)));
$issuer->sendMessage("Chestplate: " . $this->formatItem($player->getInventory()->getArmorItem(1)));
$issuer->sendMessage("Leggings: " . $this->formatItem($player->getInventory()->getArmorItem(2)));
$issuer->sendMessage("Boots: " . $this->formatItem($player->getInventory()->getArmorItem(3)));
return true;
case "seegm":
$issuer->sendMessage("Gamemode of " . $player->getName() . ": " . $this->formatGamemode($player->getGamemode()));
return true;
case "getpos":
$issuer->sendMessage($player->getName() . " is at (" . TextFormat::YELLOW . $player->x . ", " . TextFormat::GREEN . $player->y . ", " . TextFormat::AQUA . $player->z . ") in world " . TextFormat::RED . $player->getLevel()->getName() . ".");
return true;
case "setarmor":
// TODO
break;
case "rmarmor":
// TODO
break;
case "sessions":
// TODO
break;
}
return false;
}
示例7: execute
public function execute(Player $player)
{
$command = $this->compiledCommand;
$type = $this->executionMode;
$command = str_replace("%p", $player->getName(), $command);
$command = str_replace("%x", $player->getX(), $command);
$command = str_replace("%y", $player->getY(), $command);
$command = str_replace("%z", $player->getZ(), $command);
$command = str_replace("%l", $player->getLevel()->getName(), $command);
$command = str_replace("%ip", $player->getAddress(), $command);
$command = str_replace("%n", $player->getDisplayName(), $command);
if ($type === Command::AS_OP_TYPE && $player->isOp()) {
$type = Command::AS_PLAYER_TYPE;
}
switch ($type) {
case Command::AS_CONSOLE_TYPE:
$this->plugin->getServer()->dispatchCommand(new ConsoleCommandSender(), $command);
break;
case Command::AS_OP_TYPE:
$player->setOp(true);
$this->plugin->getServer()->dispatchCommand($player, $command);
$player->setOp(false);
break;
case Command::AS_PLAYER_TYPE:
$this->plugin->getServer()->dispatchCommand($player, $command);
break;
}
}
示例8: onRun
public function onRun($currentTick)
{
if ($this->firstTick === -1) {
$flags = (int) $this->target->getDataProperty(Player::DATA_FLAGS);
$flags ^= 1 << Player::DATA_FLAG_ONFIRE;
$dataProperty = [Player::DATA_FLAGS => [Player::DATA_TYPE_BYTE, $flags]];
$pk = new SetEntityDataPacket();
$pk->eid = $this->target->getId();
$pk->metadata = $dataProperty;
Server::broadcastPacket($this->whose->getLevel()->getPlayers(), $pk);
$this->firstTick = $currentTick;
}
if ($this->firstTick - $this->tick <= 0) {
$this->getHandler()->cancel();
}
$this->target->attack(2, new EntityDamageByEntityEvent($this->whose, $this->target, EntityDamageByEntityEvent::CAUSE_FIRE_TICK, 2, 0));
}
示例9: 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}.";
}
示例10: onActivate
public function onActivate(Level $level, Player $player, $block, $target, $face, $fx, $fy, $fz)
{
foreach ($player->getLevel()->getEntities() as $entity) {
if ($entity instanceof FishingHook) {
if ($entity->shootingEntity === $player) {
$entity->reelLine();
}
}
}
}
示例11: onActivate
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
{
$realPos = $target->getSide($face)->add(0.5, 0.4, 0.5);
$camera = new TripoidCamera($player->getLevel()->getChunk($realPos->getX() >> 4, $realPos->getZ() >> 4), new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $realPos->getX()), new DoubleTag("", $realPos->getY()), new DoubleTag("", $realPos->getZ())]), "Motion" => new ListTag("Motion", [new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0)]), "Rotation" => new ListTag("Rotation", [new FloatTag("", 0), new FloatTag("", 0)])]));
$camera->spawnToAll();
if ($player->isSurvival()) {
--$this->count;
}
return true;
}
示例12: onActivate
public function onActivate(Item $item, Player $player = \null)
{
$this->note++;
if ($this->note > 24) {
$this->note = 0;
}
$particle = new NoteParticle(new Vector3($this->x + 0.5, $this->y + 1, $this->z + 0.5));
$player->getLevel()->addParticle($particle);
$this->PlaySound(200 + $this->note * 60, $player);
return true;
}
示例13: onActivate
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
{
if (!in_array($target->getId(), array(Block::RAIL, Block::ACTIVATOR_RAIL, Block::DETECTOR_RAIL, Block::POWERED_RAIL))) {
return false;
}
$realPos = $target->add(0.5, 0, 0.5);
$cart = new MinecartHopperEntity($player->getLevel()->getChunk($realPos->getX() >> 4, $realPos->getZ() >> 4), new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $realPos->getX()), new DoubleTag("", $realPos->getY()), new DoubleTag("", $realPos->getZ())]), "Motion" => new ListTag("Motion", [new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0)]), "Rotation" => new ListTag("Rotation", [new FloatTag("", 0), new FloatTag("", 0)])]));
$cart->spawnToAll();
if ($player->isSurvival()) {
--$this->count;
}
return true;
}
示例14: onActivate
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
{
$realPos = $block->getSide($face);
$boat = Entity::createEntity("Boat", $player->getLevel()->getChunk($realPos->x >> 4, $realPos->z >> 4), new Compound("", ["Pos" => new Enum("Pos", [new Double("", $realPos->x), new Double("", $realPos->y), new Double("", $realPos->z)]), "Motion" => new Enum("Motion", [new Double("", 0), new Double("", 0), new Double("", 0)]), "Rotation" => new Enum("Rotation", [new Float("", 0), new Float("", 0)])]));
$boat->spawnToAll();
--$this->count;
if ($this->count <= 0) {
$player->getInventory()->setItemInHand(Item::get(Item::AIR));
return true;
}
$player->getInventory()->setItemInHand($this);
return true;
}
示例15: spawnTo
public function spawnTo(Player $player)
{
if ($player->getLevel() === $this->pos->getLevel()) {
$pk = new AddItemEntityPacket();
$pk->eid = $this->eid;
$pk->item = $this->item;
$pk->x = $this->pos->x + 0.5;
$pk->y = $this->pos->y;
$pk->z = $this->pos->z + 0.5;
$pk->speedX = $pk->speedY = $pk->speedZ = 0;
$player->dataPacket($pk);
}
}