本文整理汇总了PHP中pocketmine\Player::isSurvival方法的典型用法代码示例。如果您正苦于以下问题:PHP Player::isSurvival方法的具体用法?PHP Player::isSurvival怎么用?PHP Player::isSurvival使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\Player
的用法示例。
在下文中一共展示了Player::isSurvival方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onActivate
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
{
$entity = null;
$chunk = $level->getChunk($block->getX() >> 4, $block->getZ() >> 4);
if (!$chunk instanceof FullChunk) {
return false;
}
$nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $block->getX() + 0.5), new Double("", $block->getY()), new Double("", $block->getZ() + 0.5)]), "Motion" => new Enum("Motion", [new Double("", 0), new Double("", 0), new Double("", 0)]), "Rotation" => new Enum("Rotation", [new Float("", lcg_value() * 360), new Float("", 0)])]);
$entity = Entity::createEntity($this->meta, $chunk, $nbt);
if ($entity instanceof Entity) {
if ($player->isSurvival()) {
--$this->count;
}
$entity->spawnToAll();
return true;
}
return false;
}
示例2: onActivate
public function onActivate(Item $item, Player $player = null)
{
$tile = $this->getLevel()->getTile($this);
if ($this->meta == 0) {
switch ($item->getId()) {
case Item::BUCKET:
if ($item->getDamage() === 8) {
$this->meta = 6;
$this->getLevel()->setBlock($this, $this, true, false);
if ($player->isSurvival()) {
$item->setDamage(0);
$player->getInventory()->setItemInHand($item(), $player);
}
}
return true;
break;
}
}
return false;
}
示例3: onActivate
public function onActivate(Item $item, Player $player = null)
{
if ($this->meta < 0x7 && $item->getID() === Item::DYE && $item->getDamage() === 0xf) {
//Bonemeal
$block = clone $this;
$block->meta += mt_rand(2, 5);
if ($block->meta > 0x7) {
$block->meta = 0x7;
}
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($this, $block));
if (!$ev->isCancelled()) {
$this->getLevel()->setBlock($this, $ev->getNewState(), true, true);
if ($player->isSurvival()) {
$item->count--;
}
return true;
}
}
return false;
}
示例4: checkInVIP
private function checkInVIP(Player $player)
{
//if ($player->getLevel ()->getName () === $this->plugin->vipLevelName) {
if (isset($this->vips[$player->getName()])) {
$this->plugin->log("[HG] VIPPlayerListener->VIPCheck-IN: " . $player->getName());
return true;
} else {
$vip = $this->plugin->profileManager->isPlayerVIP($player->getName());
if (!$vip) {
return false;
}
if (!$player->isOp()) {
if (!$player->isSurvival()) {
$player->setGamemode(Player::SURVIVAL);
}
}
$this->vips[$player->getName()] = $player->getName();
$this->plugin->log("[HG] VIPPlayerListener->VIPCheck-IN: " . $player->getName());
return true;
}
//}
return false;
}
示例5: targetOption
public function targetOption(Player $player, $distance)
{
return $player->spawned && $player->isAlive() && !$player->closed && $player->isSurvival() && $distance <= 81;
}
示例6: 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;
}
示例7: onActivate
public function onActivate(Item $item, Player $player = null)
{
$tile = $this->getLevel()->getTile($this);
if (!$tile instanceof ItemFrameTile) {
$nbt = new CompoundTag("", [new StringTag("id", Tile::ITEM_FRAME), new IntTag("x", $this->x), new IntTag("y", $this->y), new IntTag("z", $this->z), new ByteTag("ItemRotation", 0), new FloatTag("ItemDropChance", 1.0)]);
Tile::createTile(Tile::ITEM_FRAME, $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
}
$tile = $this->getLevel()->getTile($this);
if (!$tile instanceof ItemFrameTile) {
return false;
}
if ($tile->getItem()->getId() === 0) {
$tile->setItem(Item::get($item->getId(), $item->getDamage(), 1));
if ($player instanceof Player) {
if ($player->isSurvival()) {
$count = $item->getCount();
if (--$count <= 0) {
$player->getInventory()->setItemInHand(Item::get(Item::AIR));
return true;
}
$item->setCount($count);
$player->getInventory()->setItemInHand($item);
}
}
} else {
$itemRot = $tile->getItemRotation();
if ($itemRot === 7) {
$itemRot = 0;
} else {
$itemRot++;
}
$tile->setItemRotation($itemRot);
}
return true;
}
示例8: onActivate
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
{
if ($target->getId() == Block::MONSTER_SPAWNER) {
return true;
} else {
$entity = null;
$chunk = $level->getChunk($block->getX() >> 4, $block->getZ() >> 4);
if (!$chunk instanceof FullChunk) {
return false;
}
$nbt = new CompoundTag("", ["Pos" => new EnumTag("Pos", [new DoubleTag("", $block->getX() + 0.5), new DoubleTag("", $block->getY()), new DoubleTag("", $block->getZ() + 0.5)]), "Motion" => new EnumTag("Motion", [new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0)]), "Rotation" => new EnumTag("Rotation", [new FloatTag("", lcg_value() * 360), new FloatTag("", 0)])]);
if ($this->hasCustomName()) {
$nbt->CustomName = new StringTag("CustomName", $this->getCustomName());
}
$entity = Entity::createEntity($this->meta, $chunk, $nbt);
if ($entity instanceof Entity) {
if ($player->isSurvival()) {
--$this->count;
}
$entity->spawnToAll();
return true;
}
}
return false;
}
示例9: onActivate
public function onActivate(Item $item, Player $player = null)
{
if ($item->getId() === Item::DYE and $item->getDamage() === Dye::BONEMEAL) {
$grow = false;
if ($this->getSide(0)->getId() !== self::SUGARCANE_BLOCK && $this->getSide(0, 2)->getId() !== self::SUGARCANE_BLOCK) {
for ($y = 1; $y < 2; $y++) {
$b = $this->getSide(1, $y);
if ($b->getId() === self::AIR) {
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($b, new Sugarcane()));
if (!$ev->isCancelled()) {
$this->getLevel()->setBlock($b, $ev->getNewState(), true);
$grow = true;
}
break;
} else {
break;
}
}
$this->meta = 0;
$this->getLevel()->setBlock($this, $this, true);
}
if ($grow && $player->isSurvival()) {
$item->count--;
}
return true;
}
return false;
}
示例10: onActivate
public function onActivate(Item $item, Player $player = null)
{
$tile = $this->getLevel()->getTile($this);
if ($tile instanceof FlowerPotTile) {
if ($tile->getFlowerPotItem() === Item::AIR) {
switch ($item->getId()) {
case Item::TALL_GRASS:
if ($item->getDamage() === 1) {
break;
}
case Item::SAPLING:
case Item::DEAD_BUSH:
case Item::DANDELION:
case Item::RED_FLOWER:
case Item::BROWN_MUSHROOM:
case Item::RED_MUSHROOM:
case Item::CACTUS:
$tile->setFlowerPotData($item->getId(), $item->getDamage());
$this->setDamage($item->getId());
$this->getLevel()->setBlock($this, $this, true, false);
if ($player->isSurvival()) {
$item->count--;
}
return true;
break;
}
}
}
return false;
}
示例11: 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;
}
示例12: 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;
}
示例13: __construct
public function __construct(Player $player, Block $block, Item $item, $instaBreak = \false)
{
$this->block = $block;
$this->item = $item;
$this->player = $player;
$this->instaBreak = (bool) $instaBreak;
$drops = $player->isSurvival() ? $block->getDrops($item) : [];
foreach ($drops as $i) {
$this->blockDrops[] = Item::get($i[0], $i[1], $i[2]);
}
}
示例14: 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;
}
示例15: __construct
public function __construct(Player $player, Block $block, Item $item, int $xpAmount = 0, bool $instaBreak = false, bool $speed = false)
{
$this->block = $block;
$this->item = $item;
$this->player = $player;
$this->instaBreak = (bool) $instaBreak;
$this->xpAmount = (int) $xpAmount;
$this->blocked = (bool) $speed;
$drops = $player->isSurvival() ? $block->getDrops($item) : [];
foreach ($drops as $i) {
$this->blockDrops[] = Item::get($i[0], $i[1], $i[2]);
}
}