当前位置: 首页>>代码示例>>PHP>>正文


PHP PlayerRespawnEvent::getRespawnPosition方法代码示例

本文整理汇总了PHP中pocketmine\event\player\PlayerRespawnEvent::getRespawnPosition方法的典型用法代码示例。如果您正苦于以下问题:PHP PlayerRespawnEvent::getRespawnPosition方法的具体用法?PHP PlayerRespawnEvent::getRespawnPosition怎么用?PHP PlayerRespawnEvent::getRespawnPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pocketmine\event\player\PlayerRespawnEvent的用法示例。


在下文中一共展示了PlayerRespawnEvent::getRespawnPosition方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onPlayerRespawn

 public function onPlayerRespawn(PlayerRespawnEvent $event)
 {
     $player = $event->getPlayer();
     if ($player instanceof Player) {
         $this->plugin->petOwnerRegister($player, $event->getRespawnPosition()->getLevel()->getName());
     }
 }
开发者ID:flaxues,项目名称:BuddyPets,代码行数:7,代码来源:EventListener.php

示例2: sendNextChunk

 protected function sendNextChunk()
 {
     if ($this->connected === false) {
         return;
     }
     $count = 0;
     foreach ($this->loadQueue as $index => $distance) {
         if ($count >= $this->chunksPerTick) {
             break;
         }
         Level::getXZ($index, $X, $Z);
         if (!$this->level->isChunkPopulated($X, $Z)) {
             $this->level->generateChunk($X, $Z);
             if ($this->spawned) {
                 continue;
             } else {
                 break;
             }
         }
         ++$count;
         unset($this->loadQueue[$index]);
         $this->usedChunks[$index] = true;
         $this->level->useChunk($X, $Z, $this);
         $chunk = $this->level->getChunk($X, $Z);
         if ($chunk instanceof AnvilChunk) {
             $this->kick("Playing on Anvil worlds is not yet implemented");
             //TODO!
             /*$pk = new ChunkDataPacket();
             				$pk->chunkX = $X;
             				$pk->chunkZ = $Z;
             				$pk->groundUp = true;
             				$ids = "";
             				$meta = "";
             				$blockLight = "";
             				$skyLight = "";
             				$biomeIds = $chunk->getBiomeIdArray();
             				$bitmap = 0;
             				for($s = 0; $s < 8; ++$s){
             					$section = $chunk->getSection($s);
             					if(!($section instanceof EmptyChunkSection)){
             						$bitmap |= 1 << $s;
             					}else{
             						continue;
             					}
             					$ids .= $section->getIdArray();
             					$meta .= $section->getDataArray();
             					$blockLight .= $section->getLightArray();
             					$skyLight .= $section->getSkyLightArray();
             				}
             
             				$pk->payload = zlib_encode($ids . $meta . $blockLight . $skyLight . $biomeIds, ZLIB_ENCODING_DEFLATE, Level::$COMPRESSION_LEVEL);
             				$pk->primaryBitmap = $bitmap;
             				$this->putRawPacket($pk);*/
         } elseif ($chunk instanceof McRegionChunk) {
             $task = new McRegionToAnvil($this, $chunk);
             $this->server->getScheduler()->scheduleAsyncTask($task);
         } elseif ($chunk instanceof LevelDBChunk) {
             $task = new LevelDBToAnvil($this, $chunk);
             $this->server->getScheduler()->scheduleAsyncTask($task);
         }
         foreach ($chunk->getEntities() as $entity) {
             if ($entity !== $this) {
                 $entity->spawnTo($this);
             }
         }
         foreach ($chunk->getTiles() as $tile) {
             if ($tile instanceof Spawnable) {
                 $tile->spawnTo($this);
             }
         }
     }
     if (count($this->usedChunks) >= 4 and $this->spawned === false) {
         $this->bigBrother_setTitleBar(TextFormat::YELLOW . TextFormat::BOLD . "This is a beta version of BigBrother.", 0);
         $this->spawned = true;
         $pk = new SetTimePacket();
         $pk->time = $this->level->getTime();
         $pk->started = $this->level->stopTime == false;
         $this->dataPacket($pk);
         $pos = $this->level->getSafeSpawn($this);
         $this->server->getPluginManager()->callEvent($ev = new PlayerRespawnEvent($this, $pos));
         $this->teleport($ev->getRespawnPosition());
         $this->sendSettings();
         $this->inventory->sendContents($this);
         $this->inventory->sendArmorContents($this);
         $this->server->getPluginManager()->callEvent($ev = new PlayerJoinEvent($this, TextFormat::YELLOW . $this->getName() . " joined the game"));
         if (strlen(trim($ev->getJoinMessage())) > 0) {
             $this->server->broadcastMessage($ev->getJoinMessage());
         }
         $this->spawnToAll();
         if ($this->server->getUpdater()->hasUpdate() and $this->hasPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE)) {
             $this->server->getUpdater()->showPlayerUpdate($this);
         }
     }
 }
开发者ID:vibrocil,项目名称:BigBrother,代码行数:94,代码来源:DesktopPlayer.php

示例3: handleDataPacket


//.........这里部分代码省略.........
                         if ($ev->isCancelled()) {
                             $this->inventory->sendContents($this);
                             break;
                         }
                         $pk = new EntityEventPacket();
                         $pk->eid = $this->getId();
                         $pk->event = EntityEventPacket::USE_ITEM;
                         $this->dataPacket($pk);
                         Server::broadcastPacket($this->getViewers(), $pk);
                         if ($this->isSurvival()) {
                             $slot = $this->inventory->getItemInHand();
                             --$slot->count;
                             $this->inventory->setItemInHand($slot);
                             $this->inventory->addItem(Item::get(Item::BUCKET, 0, 1));
                         }
                         $this->removeAllEffects();
                     } else {
                         $this->inventory->sendContents($this);
                     }
                     break;
                 case PlayerActionPacket::ACTION_STOP_SLEEPING:
                     $this->stopSleep();
                     break;
                 case PlayerActionPacket::ACTION_RESPAWN:
                     if ($this->spawned === false or $this->isAlive() or !$this->isOnline()) {
                         break;
                     }
                     if ($this->server->isHardcore()) {
                         $this->setBanned(true);
                         break;
                     }
                     $this->craftingType = 0;
                     $this->server->getPluginManager()->callEvent($ev = new PlayerRespawnEvent($this, $this->getSpawn()));
                     $this->teleport($ev->getRespawnPosition());
                     $this->setSprinting(false);
                     $this->setSneaking(false);
                     $this->extinguish();
                     $this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, 300);
                     $this->deadTicks = 0;
                     $this->dead = false;
                     $this->noDamageTicks = 60;
                     $this->setHealth($this->getMaxHealth());
                     $this->setFood(20);
                     $this->starvationTick = 0;
                     $this->foodTick = 0;
                     $this->lastSentVitals = 10;
                     $this->foodUsageTime = 0;
                     $this->removeAllEffects();
                     $this->sendData($this);
                     $this->sendSettings();
                     $this->inventory->sendContents($this);
                     $this->inventory->sendArmorContents($this);
                     $this->blocked = false;
                     $this->spawnToAll();
                     $this->scheduleUpdate();
                     break;
                 case PlayerActionPacket::ACTION_START_SPRINT:
                     $ev = new PlayerToggleSprintEvent($this, true);
                     $this->server->getPluginManager()->callEvent($ev);
                     if ($ev->isCancelled()) {
                         $this->sendData($this);
                     } else {
                         $this->setSprinting(true);
                     }
                     break;
                 case PlayerActionPacket::ACTION_STOP_SPRINT:
开发者ID:WonderlandPE,项目名称:Steadfast2,代码行数:67,代码来源:Player.php

示例4: onRespawn

 public function onRespawn(PlayerRespawnEvent $event)
 {
     $player = $event->getPlayer();
     if ($this->isOtu($player->getName()) or $this->isRuna($player->getName())) {
         if ($this->isAutoRespawnInJail()) {
             $respawn = $event->getRespawnPosition();
             if (!(($pos = $this->getRespawnPosition($player->getName())) === false)) {
                 //todo 関数名が紛らわしいので後で変更
                 $respawn = $pos;
             }
             $event->setRespawnPosition($respawn);
         }
     }
 }
开发者ID:MrDoni98,项目名称:PocketMine-MP-Plugins,代码行数:14,代码来源:MainClass.php

示例5: handleDataPacket


//.........这里部分代码省略.........
                     if ($item->isTool() and $this->isSurvival()) {
                         $this->inventory->sendContents($this);
                     }
                     break;
                 }
                 if ($item->isTool() and $this->isSurvival()) {
                     if ($item->useOn($target) and $item->getDamage() >= $item->getMaxDurability()) {
                         $this->inventory->setItemInHand(Item::get(Item::AIR, 0, 1), $this);
                     } else {
                         $this->inventory->setItemInHand($item, $this);
                     }
                 }
             }
             break;
         case ProtocolInfo::ANIMATE_PACKET:
             if ($this->spawned === false or $this->dead === true) {
                 break;
             }
             $this->server->getPluginManager()->callEvent($ev = new PlayerAnimationEvent($this, $packet->action));
             if ($ev->isCancelled()) {
                 break;
             }
             $pk = new AnimatePacket();
             $pk->eid = $this->getId();
             $pk->action = $ev->getAnimationType();
             Server::broadcastPacket($this->getViewers(), $pk);
             break;
         case ProtocolInfo::RESPAWN_PACKET:
             if ($this->spawned === false or $this->dead === false) {
                 break;
             }
             $this->craftingType = 0;
             $this->server->getPluginManager()->callEvent($ev = new PlayerRespawnEvent($this, $this->getSpawn()));
             $this->teleport($ev->getRespawnPosition());
             $this->fireTicks = 0;
             $this->airTicks = 300;
             $this->deadTicks = 0;
             $this->setHealth(20);
             $this->dead = false;
             $this->sendMetadata($this->getViewers());
             $this->sendMetadata($this);
             $this->sendSettings();
             $this->inventory->sendContents($this);
             $this->inventory->sendArmorContents($this);
             $this->blocked = false;
             $this->spawnToAll();
             $this->scheduleUpdate();
             break;
         case ProtocolInfo::SET_HEALTH_PACKET:
             //Not used
             break;
         case ProtocolInfo::ENTITY_EVENT_PACKET:
             if ($this->spawned === false or $this->blocked === true or $this->dead === true) {
                 break;
             }
             $this->craftingType = 0;
             if ($this->inAction === true) {
                 $this->inAction = false;
                 $this->sendMetadata($this->getViewers());
             }
             switch ($packet->event) {
                 case 9:
                     //Eating
                     $items = [Item::APPLE => 4, Item::MUSHROOM_STEW => 10, Item::BEETROOT_SOUP => 10, Item::BREAD => 5, Item::RAW_PORKCHOP => 3, Item::COOKED_PORKCHOP => 8, Item::RAW_BEEF => 3, Item::STEAK => 8, Item::COOKED_CHICKEN => 6, Item::RAW_CHICKEN => 2, Item::MELON_SLICE => 2, Item::GOLDEN_APPLE => 10, Item::PUMPKIN_PIE => 8, Item::CARROT => 4, Item::POTATO => 1, Item::BAKED_POTATO => 6];
                     $slot = $this->inventory->getItemInHand();
                     if ($this->getHealth() < 20 and isset($items[$slot->getId()])) {
开发者ID:rryy,项目名称:PocketMine-MP,代码行数:67,代码来源:Player.php

示例6: handleDataPacket


//.........这里部分代码省略.........
                         //$pk;
                         $this->dataPacket($pk);
                         Server::broadcastPacket($this->getViewers(), $pk);
                         if ($this->isSurvival()) {
                             $slot = $this->inventory->getItemInHand();
                             --$slot->count;
                             $this->inventory->setItemInHand($slot);
                             $this->inventory->addItem(Item::get(Item::BUCKET, 0, 1));
                         }
                         $this->removeAllEffects();
                     } else {
                         $this->inventory->sendContents($this);
                     }
                     break;
                 case PlayerActionPacket::ACTION_STOP_SLEEPING:
                     $this->stopSleep();
                     break;
                 case PlayerActionPacket::ACTION_SPAWN_SAME_DIMENSION:
                 case PlayerActionPacket::ACTION_SPAWN_OVERWORLD:
                     if ($this->isAlive() or !$this->isOnline()) {
                         break;
                     }
                     if ($this->server->isHardcore()) {
                         $this->setBanned(true);
                         break;
                     }
                     $this->craftingType = self::CRAFTING_SMALL;
                     if ($this->server->netherEnabled) {
                         if ($this->level == $this->server->netherLevel) {
                             $this->teleport($pos = $this->server->getDefaultLevel()->getSafeSpawn());
                         }
                     }
                     $this->server->getPluginManager()->callEvent($ev = new PlayerRespawnEvent($this, $this->getSpawn()));
                     $this->teleport($ev->getRespawnPosition());
                     $this->setSprinting(false);
                     $this->setSneaking(false);
                     $this->extinguish();
                     $this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, 300);
                     $this->deadTicks = 0;
                     $this->noDamageTicks = 60;
                     $this->removeAllEffects();
                     $this->setHealth($this->getMaxHealth());
                     $this->setFood(20);
                     $this->starvationTick = 0;
                     $this->foodTick = 0;
                     $this->foodUsageTime = 0;
                     $this->sendData($this);
                     $this->sendSettings();
                     $this->inventory->sendContents($this);
                     $this->inventory->sendArmorContents($this);
                     $this->blocked = false;
                     $this->spawnToAll();
                     $this->scheduleUpdate();
                     break;
                 case PlayerActionPacket::ACTION_START_SPRINT:
                     $ev = new PlayerToggleSprintEvent($this, true);
                     $this->server->getPluginManager()->callEvent($ev);
                     if ($ev->isCancelled()) {
                         $this->sendData($this);
                     } else {
                         $this->setSprinting(true);
                     }
                     break 2;
                 case PlayerActionPacket::ACTION_STOP_SPRINT:
                     $ev = new PlayerToggleSprintEvent($this, false);
                     $this->server->getPluginManager()->callEvent($ev);
开发者ID:iTXTech,项目名称:Genisys,代码行数:67,代码来源:Player.php

示例7: handleDataPacket


//.........这里部分代码省略.........
                         if ($ev->isCancelled()) {
                             $this->inventory->sendContents($this);
                             break;
                         }
                         $pk = new EntityEventPacket();
                         $pk->eid = $this->getId();
                         $pk->event = EntityEventPacket::USE_ITEM;
                         $this->dataPacket($pk);
                         Server::broadcastPacket($this->getViewers(), $pk);
                         if ($this->isSurvival()) {
                             $slot = $this->inventory->getItemInHand();
                             --$slot->count;
                             $this->inventory->setItemInHand($slot);
                             $this->inventory->addItem(Item::get(Item::BUCKET, 0, 1));
                         }
                         $this->removeAllEffects();
                     } else {
                         $this->inventory->sendContents($this);
                     }
                     break;
                 case PlayerActionPacket::ACTION_STOP_SLEEPING:
                     $this->stopSleep();
                     break;
                 case PlayerActionPacket::ACTION_RESPAWN:
                     if ($this->spawned === false or $this->isAlive() or !$this->isOnline()) {
                         break;
                     }
                     if ($this->server->isHardcore()) {
                         $this->setBanned(true);
                         break;
                     }
                     $this->craftingType = self::CRAFTING_SMALL;
                     $this->server->getPluginManager()->callEvent($ev = new PlayerRespawnEvent($this, $this->getSpawn()));
                     $this->teleport($ev->getRespawnPosition());
                     $this->setSprinting(false);
                     $this->setMovementSpeed(self::DEFAULT_SPEED);
                     //because setSprinting(false) would decrease
                     $this->setSneaking(false);
                     $this->extinguish();
                     $this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, 400, false);
                     $this->deadTicks = 0;
                     $this->noDamageTicks = 60;
                     $this->setHealth($this->getMaxHealth());
                     $this->removeAllEffects();
                     $this->sendData($this);
                     $this->sendSettings();
                     $this->inventory->sendContents($this);
                     $this->inventory->sendArmorContents($this);
                     $this->blocked = false;
                     $this->spawnToAll();
                     $this->scheduleUpdate();
                     break;
                 case PlayerActionPacket::ACTION_START_SPRINT:
                     $ev = new PlayerToggleSprintEvent($this, true);
                     $this->server->getPluginManager()->callEvent($ev);
                     if ($ev->isCancelled()) {
                         $this->sendData($this);
                     } else {
                         $this->setSprinting(true);
                     }
                     break 2;
                 case PlayerActionPacket::ACTION_STOP_SPRINT:
                     $ev = new PlayerToggleSprintEvent($this, false);
                     $this->server->getPluginManager()->callEvent($ev);
                     if ($ev->isCancelled()) {
                         $this->sendData($this);
开发者ID:robske110,项目名称:ClearSky,代码行数:67,代码来源:Player.php

示例8: onPlayerRespawn

 public function onPlayerRespawn(PlayerRespawnEvent $event)
 {
     $this->spawn[strtolower($event->getPlayer()->getName())] = $event->getRespawnPosition();
 }
开发者ID:Skull3x,项目名称:MineBlock,代码行数:4,代码来源:Login.php

示例9: handleDataPacket


//.........这里部分代码省略.........
                         $this->server->getPluginManager()->callEvent($ev = new PlayerItemConsumeEvent($this, $this->inventory->getItemInHand()));
                         if ($ev->isCancelled()) {
                             $this->inventory->sendContents($this);
                             break;
                         }
                         $pk = new EntityEventPacket();
                         $pk->eid = $this->getId();
                         $pk->event = 9;
                         $pk->setChannel(Network::CHANNEL_WORLD_EVENTS);
                         $this->dataPacket($pk);
                         Server::broadcastPacket($this->getViewers(), $pk);
                         if ($this->isSurvival()) {
                             $slot = $this->inventory->getItemInHand();
                             --$slot->count;
                             $this->inventory->setItemInHand($slot, $this);
                             $this->inventory->addItem(Item::get(Item::BUCKET, 0, 1));
                         }
                         $this->removeAllEffects();
                     } else {
                         $this->inventory->sendContents($this);
                     }
                     break;
                 case 6:
                     //get out of the bed
                     $this->stopSleep();
                     break;
                 case 7:
                     //Respawn
                     if ($this->spawned === false or $this->dead === false) {
                         break;
                     }
                     $this->craftingType = 0;
                     $this->server->getPluginManager()->callEvent($ev = new PlayerRespawnEvent($this, $this->getSpawn()));
                     $this->teleport($ev->getRespawnPosition());
                     $this->extinguish();
                     $this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, 300);
                     $this->deadTicks = 0;
                     $this->noDamageTicks = 60;
                     $this->setHealth(20);
                     $this->dead = false;
                     $this->removeAllEffects();
                     $this->sendData($this);
                     $this->sendSettings();
                     $this->inventory->sendContents($this);
                     $this->inventory->sendArmorContents($this);
                     $this->blocked = false;
                     $this->spawnToAll();
                     $this->scheduleUpdate();
                     break;
             }
             $this->startAction = -1;
             $this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION, false);
             break;
         case ProtocolInfo::RESPAWN_PACKET:
             //TODO: Remove
             if ($this->spawned === false or $this->dead === false) {
                 break;
             }
             $this->craftingType = 0;
             $this->server->getPluginManager()->callEvent($ev = new PlayerRespawnEvent($this, $this->getSpawn()));
             $this->teleport($ev->getRespawnPosition());
             $this->extinguish();
             $this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, 300);
             $this->deadTicks = 0;
             $this->noDamageTicks = 60;
             $this->setHealth(20);
开发者ID:TylerGames,项目名称:PocketMine-MP,代码行数:67,代码来源:Player.php

示例10: handleDataPacket


//.........这里部分代码省略.........
                         //$pk;
                         $this->dataPacket($pk);
                         Server::broadcastPacket($this->getViewers(), $pk);
                         if ($this->isSurvival()) {
                             $slot = $this->inventory->getItemInHand();
                             --$slot->count;
                             $this->inventory->setItemInHand($slot);
                             $this->inventory->addItem(Item::get(Item::BUCKET, 0, 1));
                         }
                         $this->removeAllEffects();
                     } else {
                         $this->inventory->sendContents($this);
                     }
                     break;
                 case PlayerActionPacket::ACTION_STOP_SLEEPING:
                     $this->stopSleep();
                     break;
                 case PlayerActionPacket::ACTION_SPAWN_SAME_DIMENSION:
                 case PlayerActionPacket::ACTION_SPAWN_OVERWORLD:
                     if ($this->isAlive() or !$this->isOnline()) {
                         break;
                     }
                     if ($this->server->isHardcore()) {
                         $this->setBanned(true);
                         break;
                     }
                     $this->craftingType = 0;
                     if ($this->server->netherEnabled) {
                         if ($this->level == $this->server->netherLevel) {
                             $this->teleport($pos = $this->server->getDefaultLevel()->getSafeSpawn());
                         }
                     }
                     $this->server->getPluginManager()->callEvent($ev = new PlayerRespawnEvent($this, $this->getSpawn()));
                     $this->teleport($ev->getRespawnPosition());
                     $this->setSprinting(false);
                     $this->setSneaking(false);
                     $this->extinguish();
                     $this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, 300);
                     $this->deadTicks = 0;
                     $this->noDamageTicks = 60;
                     $this->removeAllEffects();
                     $this->setHealth($this->getMaxHealth());
                     $this->setFood(20);
                     if ($this->server->expEnabled) {
                         $this->updateExperience();
                     }
                     $this->starvationTick = 0;
                     $this->foodTick = 0;
                     $this->foodUsageTime = 0;
                     $this->sendData($this);
                     $this->sendSettings();
                     $this->inventory->sendContents($this);
                     $this->inventory->sendArmorContents($this);
                     $this->blocked = false;
                     $this->spawnToAll();
                     $this->scheduleUpdate();
                     break;
                 case PlayerActionPacket::ACTION_START_SPRINT:
                     $ev = new PlayerToggleSprintEvent($this, true);
                     $this->server->getPluginManager()->callEvent($ev);
                     if ($ev->isCancelled()) {
                         $this->sendData($this);
                     } else {
                         $this->setSprinting(true);
                     }
                     break;
开发者ID:yungtechboy1,项目名称:Genisys,代码行数:67,代码来源:Player.php

示例11: onDataPacketReceive

 public function onDataPacketReceive(DataPacketReceiveEvent $event)
 {
     $pk = $event->getPacket();
     $p = $event->getPlayer();
     if ($pk->pid() == ProtocolInfo::ENTITY_EVENT_PACKET && $pk->event == 9) {
         $i = $p->getInventory()->getItemInHand();
         $items = [Item::APPLE => 4, Item::MUSHROOM_STEW => 10, Item::BEETROOT_SOUP => 10, Item::BREAD => 5, Item::RAW_PORKCHOP => 3, Item::COOKED_PORKCHOP => 8, Item::RAW_BEEF => 3, Item::STEAK => 8, Item::COOKED_CHICKEN => 6, Item::RAW_CHICKEN => 2, Item::MELON_SLICE => 2, Item::GOLDEN_APPLE => 10, Item::PUMPKIN_PIE => 8, Item::CARROT => 4, Item::POTATO => 1, Item::BAKED_POTATO => 6];
         if ($p->getHealth() >= 20 && $p->getHealth() < $p->getMaxHealth() && isset($items[$i->getID()])) {
             $this->getServer()->getPluginManager()->callEvent($ev = new PlayerItemConsumeEvent($p, $i));
             if ($ev->isCancelled()) {
                 $p->getInventory()->sendContents($p);
                 break;
             }
             $pk = new EntityEventPacket();
             $pk->eid = 0;
             $pk->event = 9;
             $p->dataPacket($pk);
             $pk->eid = $p->getId();
             $this->getServer()->broadcastPacket($p->getViewers(), $pk);
             $amount = $items[$i->getID()];
             $this->getServer()->getPluginManager()->callEvent($ev = new EntityRegainHealthEvent($p, $amount, EntityRegainHealthEvent::CAUSE_EATING));
             if (!$ev->isCancelled()) {
                 $p->heal($ev->getAmount(), $ev);
             }
             --$i->count;
             $p->getInventory()->setItemInHand($i, $p);
             if ($i->getID() === Item::MUSHROOM_STEW or $i->getID() === Item::BEETROOT_SOUP) {
                 $p->getInventory()->addItem(Item::get(Item::BOWL, 0, 1), $p);
             }
         }
     } elseif ($pk->pid() == ProtocolInfo::RESPAWN_PACKET && $p->spawned && $p->dead) {
         $p->craftingType = 0;
         $this->getServer()->getPluginManager()->callEvent($ev = new PlayerRespawnEvent($p, $p->getSpawn()));
         $p->teleport($ev->getRespawnPosition());
         $p->fireTicks = 0;
         $p->airTicks = 300;
         $p->deadTicks = 0;
         $p->noDamageTicks = 0;
         $p->dead = false;
         $p->setHealth($p->getMaxHealth());
         $p->sendMetadata($p->getViewers());
         $p->sendMetadata($p);
         $p->sendSettings();
         $p->getInventory()->sendContents($p);
         $p->getInventory()->sendArmorContents($p);
         $p->blocked = false;
         $p->spawnToAll();
         $p->scheduleUpdate();
         $event->setCancelled();
     }
 }
开发者ID:Skull3x,项目名称:MineBlock,代码行数:51,代码来源:MaxHealth.php

示例12: handleDataPacket


//.........这里部分代码省略.........
                         if ($ev->isCancelled()) {
                             $this->inventory->sendContents($this);
                             break;
                         }
                         $pk = new EntityEventPacket();
                         $pk->eid = $this->getId();
                         $pk->event = EntityEventPacket::USE_ITEM;
                         $this->dataPacket($pk);
                         Server::broadcastPacket($this->getViewers(), $pk);
                         if ($this->isSurvival()) {
                             $slot = $this->inventory->getItemInHand();
                             --$slot->count;
                             $this->inventory->setItemInHand($slot);
                             $this->inventory->addItem(Item::get(Item::BUCKET, 0, 1));
                         }
                         $this->removeAllEffects();
                     } else {
                         $this->inventory->sendContents($this);
                     }
                     break;
                 case PlayerActionPacket::ACTION_STOP_SLEEPING:
                     $this->stopSleep();
                     break;
                 case PlayerActionPacket::ACTION_RESPAWN:
                     if ($this->spawned === false or $this->isAlive() or !$this->isOnline()) {
                         break;
                     }
                     if ($this->server->isHardcore()) {
                         $this->setBanned(true);
                         break;
                     }
                     $this->craftingType = 0;
                     $this->server->getPluginManager()->callEvent($ev = new PlayerRespawnEvent($this, $this->getSpawn()));
                     $this->teleport($ev->getRespawnPosition());
                     $this->setSprinting(false);
                     $this->setSneaking(false);
                     $this->extinguish();
                     $this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, 300);
                     $this->deadTicks = 0;
                     $this->noDamageTicks = 60;
                     $this->setHealth($this->getMaxHealth());
                     $this->removeAllEffects();
                     $this->sendData($this);
                     $this->sendSettings();
                     $this->inventory->sendContents($this);
                     $this->inventory->sendArmorContents($this);
                     $this->blocked = false;
                     $this->spawnToAll();
                     $this->scheduleUpdate();
                     break;
                 case PlayerActionPacket::ACTION_START_SPRINT:
                     $ev = new PlayerToggleSprintEvent($this, true);
                     $this->server->getPluginManager()->callEvent($ev);
                     if ($ev->isCancelled()) {
                         $this->sendData($this);
                     } else {
                         $this->setSprinting(true);
                     }
                     break;
                 case PlayerActionPacket::ACTION_STOP_SPRINT:
                     $ev = new PlayerToggleSprintEvent($this, false);
                     $this->server->getPluginManager()->callEvent($ev);
                     if ($ev->isCancelled()) {
                         $this->sendData($this);
                     } else {
                         $this->setSprinting(false);
开发者ID:NewDelion,项目名称:PocketMine-0.13.x,代码行数:67,代码来源:Player.php


注:本文中的pocketmine\event\player\PlayerRespawnEvent::getRespawnPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。