本文整理汇总了PHP中pocketmine\entity\Effect::isVisible方法的典型用法代码示例。如果您正苦于以下问题:PHP Effect::isVisible方法的具体用法?PHP Effect::isVisible怎么用?PHP Effect::isVisible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\entity\Effect
的用法示例。
在下文中一共展示了Effect::isVisible方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: switchLevelVanish
/**
* Allow to switch between levels Vanished!
* You need to teleport the player to a different level in order to call this event
*
* @param Player $player
* @param Level $origin
* @param Level $target
*/
public function switchLevelVanish(Player $player, Level $origin, Level $target)
{
if ($origin->getName() !== $target->getName() && $this->isVanished($player)) {
// This will be used if the specified player has "noPacket" enabled.
// A temporal check will be used for "the other players".
$noPacket = $this->hasNoPacket($player);
// Just as prevention if any player has "noPacket" disabled...
$pk = new MobEffectPacket();
$pk->effectId = $this->invisibilityEffect->getId();
$pk->amplifier = $this->invisibilityEffect->getAmplifier();
$pk->particles = $this->invisibilityEffect->isVisible();
$pk->duration = $this->invisibilityEffect->getDuration();
// Show to origin's players
$pk->eventId = MobEffectPacket::EVENT_REMOVE;
foreach ($origin->getPlayers() as $p) {
if ($p !== $player) {
if ($this->isVanished($player)) {
if (!$noPacket) {
$pk->eid = $player->getId();
$p->dataPacket($pk);
} else {
$p->showPlayer($player);
}
}
if ($this->isVanished($p)) {
if (!$this->hasNoPacket($p)) {
$pk->eid = $p->getId();
$player->dataPacket($pk);
} else {
$player->showPlayer($p);
}
}
}
}
// Hide to target's players
$pk->eventId = MobEffectPacket::EVENT_ADD;
foreach ($target->getPlayers() as $p) {
if ($p !== $player) {
if ($this->isVanished($player)) {
if (!$noPacket) {
$pk->eid = $player->getId();
$p->dataPacket($pk);
} else {
$p->hidePlayer($player);
}
}
if ($this->isVanished($p)) {
if (!$this->hasNoPacket($p)) {
$pk->eid = $p->getId();
$player->dataPacket($pk);
} else {
$player->hidePlayer($p);
}
}
}
}
}
}