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


PHP Human::__construct方法代码示例

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


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

示例1: __construct

 /**
  * @param Vector3 $v
  * @param mixed $data
  * @param int $id
  * @param FullChunk $chunk
  */
 public function __construct($v, $data, $id = -2, $chunk = null)
 {
     $this->data = $data;
     if (!$v instanceof Vector3) {
         if ($v instanceof FullChunk) {
             $v->removeEntity($this);
         }
         throw new \RuntimeException("BadConstructCustomHuman");
     }
     $nbt = new Compound();
     $nbt->Pos = new Enum("Motion", [new Double(0, $v->x), new Double(1, $v->y), new Double(2, $v->z)]);
     $nbt->Motion = new Enum("Motion", [new Double(0, 0), new Double(1, 0), new Double(2, 0)]);
     $nbt->Rotation = new Enum("Rotation", [new Float(0, $this->getDefaultYaw()), new Float(1, $this->getDefaultPitch())]);
     $nbt->FallDistance = new Float("FallDistance", 0);
     $nbt->Fire = new Short("Fire", 0);
     $nbt->Air = new Short("Air", 0);
     $nbt->OnGround = new Byte("OnGround", 1);
     $nbt->Invulnerable = new Byte("Invulnerable", 1);
     $nbt->Health = new Short("Health", 20);
     $nbt->NameTag = $this->getDefaultName();
     $nbt->Inventory = new Enum("Inventory", []);
     $nbt->Inventory->setTagType(NBT::TAG_Compound);
     $this->inventory = new PlayerInventory($this);
     $this->setSkin($this->getDefaultSkin());
     parent::__construct($chunk, $nbt);
 }
开发者ID:legoboy0215,项目名称:LegionPE-Theta-Base,代码行数:32,代码来源:CustomHuman.php

示例2: processLogin

 protected function processLogin()
 {
     if (!$this->server->isWhitelisted(strtolower($this->getName()))) {
         $this->close($this->getLeaveMessage(), "Server is white-listed");
         return;
     } elseif ($this->server->getNameBans()->isBanned(strtolower($this->getName())) or $this->server->getIPBans()->isBanned($this->getAddress())) {
         $this->close($this->getLeaveMessage(), "You are banned");
         return;
     }
     if ($this->hasPermission(Server::BROADCAST_CHANNEL_USERS)) {
         $this->server->getPluginManager()->subscribeToPermission(Server::BROADCAST_CHANNEL_USERS, $this);
     }
     if ($this->hasPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE)) {
         $this->server->getPluginManager()->subscribeToPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE, $this);
     }
     foreach ($this->server->getOnlinePlayers() as $p) {
         if ($p !== $this and strtolower($p->getName()) === strtolower($this->getName())) {
             if ($p->kick("logged in from another location") === false) {
                 $this->close($this->getLeaveMessage(), "Logged in from another location");
                 return;
             }
         } elseif ($p->loggedIn and $this->getUniqueId()->equals($p->getUniqueId())) {
             if ($p->kick("logged in from another location") === false) {
                 $this->close($this->getLeaveMessage(), "Logged in from another location");
                 return;
             }
         }
     }
     $nbt = $this->server->getOfflinePlayerData($this->username);
     if (!isset($nbt->NameTag)) {
         $nbt->NameTag = new String("NameTag", $this->username);
     } else {
         $nbt["NameTag"] = $this->username;
     }
     $this->gamemode = $nbt["playerGameType"] & 0x3;
     if ($this->server->getForceGamemode()) {
         $this->gamemode = $this->server->getGamemode();
         $nbt->playerGameType = new Int("playerGameType", $this->gamemode);
     }
     $this->allowFlight = $this->isCreative();
     if (($level = $this->server->getLevelByName($nbt["Level"])) === null) {
         $this->setLevel($this->server->getDefaultLevel());
         $nbt["Level"] = $this->level->getName();
         $nbt["Pos"][0] = $this->level->getSpawnLocation()->x;
         $nbt["Pos"][1] = $this->level->getSpawnLocation()->y;
         $nbt["Pos"][2] = $this->level->getSpawnLocation()->z;
     } else {
         $this->setLevel($level);
     }
     if (!$nbt instanceof Compound) {
         $this->close($this->getLeaveMessage(), "Invalid data");
         return;
     }
     $this->achievements = [];
     /** @var Byte $achievement */
     foreach ($nbt->Achievements as $achievement) {
         $this->achievements[$achievement->getName()] = $achievement->getValue() > 0 ? true : false;
     }
     $nbt->lastPlayed = new Long("lastPlayed", floor(microtime(true) * 1000));
     if ($this->server->getAutoSave()) {
         $this->server->saveOfflinePlayerData($this->username, $nbt, true);
     }
     parent::__construct($this->level->getChunk($nbt["Pos"][0] >> 4, $nbt["Pos"][2] >> 4, true), $nbt);
     $this->loggedIn = true;
     $this->server->addOnlinePlayer($this);
     $this->server->getPluginManager()->callEvent($ev = new PlayerLoginEvent($this, "Plugin reason"));
     if ($ev->isCancelled()) {
         $this->close($this->getLeaveMessage(), $ev->getKickMessage());
         return;
     }
     if ($this->isCreative()) {
         $this->inventory->setHeldItemSlot(0);
     } else {
         $this->inventory->setHeldItemSlot($this->inventory->getHotbarSlotIndex(0));
     }
     $pk = new PlayStatusPacket();
     $pk->status = PlayStatusPacket::LOGIN_SUCCESS;
     $this->dataPacket($pk);
     if ($this->spawnPosition === null and isset($this->namedtag->SpawnLevel) and ($level = $this->server->getLevelByName($this->namedtag["SpawnLevel"])) instanceof Level) {
         $this->spawnPosition = new Position($this->namedtag["SpawnX"], $this->namedtag["SpawnY"], $this->namedtag["SpawnZ"], $level);
     }
     $spawnPosition = $this->getSpawn();
     $pk = new StartGamePacket();
     $pk->seed = -1;
     $pk->dimension = 0;
     $pk->x = $this->x;
     $pk->y = $this->y;
     $pk->z = $this->z;
     $pk->spawnX = (int) $spawnPosition->x;
     $pk->spawnY = (int) $spawnPosition->y;
     $pk->spawnZ = (int) $spawnPosition->z;
     $pk->generator = 1;
     //0 old, 1 infinite, 2 flat
     $pk->gamemode = $this->gamemode & 0x1;
     $pk->eid = 0;
     //Always use EntityID as zero for the actual player
     $this->dataPacket($pk);
     $pk = new SetTimePacket();
     $pk->time = $this->level->getTime();
     $pk->started = $this->level->stopTime == false;
//.........这里部分代码省略.........
开发者ID:NewDelion,项目名称:PocketMine-0.13.x,代码行数:101,代码来源:Player.php

示例3: handleDataPacket


//.........这里部分代码省略.........
                 }
             }
             $nbt = $this->server->getOfflinePlayerData($this->username);
             if (!isset($nbt->NameTag)) {
                 $nbt->NameTag = new String("NameTag", $this->username);
             } else {
                 $nbt["NameTag"] = $this->username;
             }
             $this->gamemode = $nbt["playerGameType"] & 0x3;
             if ($this->server->getForceGamemode()) {
                 $this->gamemode = $this->server->getGamemode();
                 $nbt->playerGameType = new Int("playerGameType", $this->gamemode);
             }
             $this->allowFlight = $this->isCreative();
             if (($level = $this->server->getLevelByName($nbt["Level"])) === null) {
                 $this->setLevel($this->server->getDefaultLevel(), true);
                 $nbt["Level"] = $this->level->getName();
                 $nbt["Pos"][0] = $this->level->getSpawnLocation()->x;
                 $nbt["Pos"][1] = $this->level->getSpawnLocation()->y;
                 $nbt["Pos"][2] = $this->level->getSpawnLocation()->z;
             } else {
                 $this->setLevel($level, true);
             }
             if (!$nbt instanceof Compound) {
                 $this->close(TextFormat::YELLOW . $this->username . " has left the game", "Corrupt joining data, check your connection.");
                 return;
             }
             $this->achievements = [];
             /** @var Byte $achievement */
             foreach ($nbt->Achievements as $achievement) {
                 $this->achievements[$achievement->getName()] = $achievement->getValue() > 0 ? true : false;
             }
             $nbt->lastPlayed = new Long("lastPlayed", floor(microtime(true) * 1000));
             parent::__construct($this->level->getChunk($nbt["Pos"][0] >> 4, $nbt["Pos"][2] >> 4, true), $nbt);
             $this->loggedIn = true;
             $this->server->addOnlinePlayer($this);
             $this->server->getPluginManager()->callEvent($ev = new PlayerLoginEvent($this, "Plugin reason"));
             if ($ev->isCancelled()) {
                 $this->close(TextFormat::YELLOW . $this->username . " has left the game", $ev->getKickMessage());
                 return;
             }
             if ($this->isCreative()) {
                 $this->inventory->setHeldItemSlot(0);
             } else {
                 $this->inventory->setHeldItemSlot($this->inventory->getHotbarSlotIndex(0));
             }
             $pk = new PlayStatusPacket();
             $pk->status = PlayStatusPacket::LOGIN_SUCCESS;
             $this->dataPacket($pk);
             $this->server->sendFullPlayerListData($this);
             $this->server->sendRecipeList($this);
             $this->uuid = $packet->clientUUID;
             $this->rawUUID = $this->uuid->toBinary();
             $this->clientSecret = $packet->clientSecret;
             if ($this->spawnPosition === null and isset($this->namedtag->SpawnLevel) and ($level = $this->server->getLevelByName($this->namedtag["SpawnLevel"])) instanceof Level) {
                 $this->spawnPosition = new Position($this->namedtag["SpawnX"], $this->namedtag["SpawnY"], $this->namedtag["SpawnZ"], $level);
             }
             $spawnPosition = $this->getSpawn();
             $pk = new StartGamePacket();
             $pk->seed = -1;
             $pk->x = $this->x;
             $pk->y = $this->y;
             $pk->z = $this->z;
             $pk->spawnX = (int) $spawnPosition->x;
             $pk->spawnY = (int) $spawnPosition->y;
             $pk->spawnZ = (int) $spawnPosition->z;
开发者ID:ZenaGamingsky,项目名称:Steadfast2,代码行数:67,代码来源:Player.php

示例4: __construct

 public function __construct(FullChunk $chunk, CompoundTag $nbt, $targetPlayer = null, $plugin = null)
 {
     // if $targetPlayer is null pocketmine is probably trying to refload a saved
     // version of this entity which we do not want anymore - as it is not cancellable ( I think ? )
     // just let it create and the update function will despawn the entity immediatley when it finds
     // it to have no targetPlayer
     if (is_null($targetPlayer)) {
         parent::__construct($chunk, $nbt);
         $this->close();
         return;
     }
     // if targetPlayer was set we can create chunk and nbt values outselves
     $this->plugin = $plugin;
     $name = "Herobrine";
     // $IsSlim = $targetPlayer->isSkinSlim();
     $playerX = $targetPlayer->getX();
     $playerY = $targetPlayer->getY();
     $playerZ = $targetPlayer->getZ();
     $outX = round($playerX, 1);
     $outY = round($playerY, 1);
     $outZ = round($playerZ, 1);
     // echo "Playerpos $playerX, $playerY, $playerZ" . PHP_EOL;  // DEBUG
     $playerLevel = $targetPlayer->getLevel()->getName();
     $playerYaw = $targetPlayer->getYaw();
     $playerPitch = $targetPlayer->getPitch();
     $humanInv = $targetPlayer->getInventory();
     $pHealth = 99;
     // get a nice place to spawn
     if (rand(1, 2) == 1) {
         $provisional_spawnloc = new Vector3($playerX + rand(15, 20), $playerY, $playerZ + rand(15, 20));
     } else {
         $provisional_spawnloc = new Vector3($playerX - rand(15, 20), $playerY, $playerZ - rand(15, 20));
     }
     $spawnloc = $targetPlayer->getLevel()->getSafeSpawn($provisional_spawnloc);
     $outX = $spawnloc->x;
     $outY = $spawnloc->y;
     // 0,5
     $outZ = $spawnloc->z;
     // echo "Spawnpos $outX, $outY, $outZ" . PHP_EOL; // DEBUG
     $nbt = new CompoundTag();
     $motion = new Vector3(0, 0, 0);
     $nbt->Pos = new ListTag("Pos", [new DoubleTag("", $outX), new DoubleTag("", $outY), new DoubleTag("", $outZ)]);
     $nbt->Motion = new ListTag("Motion", [new DoubleTag("", $motion->x), new DoubleTag("", $motion->y), new DoubleTag("", $motion->z)]);
     $nbt->Rotation = new ListTag("Rotation", [new FloatTag("", $playerYaw), new FloatTag("", $playerPitch)]);
     $nbt->Health = new ShortTag("Health", $pHealth);
     $nbt->Inventory = new ListTag("Inventory", $humanInv);
     $nbt->NameTag = new StringTag("name", " ");
     $nbt->Invulnerable = new ByteTag("Invulnerable", 1);
     $nbt->CustomTestTag = new ByteTag("CustomTestTag", 1);
     $nbt->Skin = new CompoundTag("Skin", ["Data" => new StringTag("Data", file_get_contents($this->plugin->getDataFolder() . "/herobrine.skin")), "Slim" => new ByteTag("Slim", 0)]);
     parent::__construct($targetPlayer->getLevel()->getChunk($playerX >> 4, $playerZ >> 4), $nbt);
     $this->perm = new PermissibleBase($this);
     $this->setNameTagVisible(false);
     $this->setSkin(file_get_contents($this->plugin->getDataFolder() . "/herobrine.skin"), false);
     $this->setTargetPlayer($targetPlayer);
     $this->spawnToAll();
     $this->timespawned = time();
 }
开发者ID:mwvent,项目名称:WattzMCPE,代码行数:58,代码来源:Herobrine.php

示例5: __construct

 public function __construct(FullChunk $chunk, CompoundTag $nbt, $targetPlayer = null, $entityToCopyCoords = null, $plugin = null)
 {
     // if $targetPlayer is null pocketmine is probably trying to reload a saved
     // version of this entity which we do not want anymore - as it is not cancellable ( I think ? )
     // just let it create and the update function will despawn the entity immediatley when it finds
     // it to have no targetPlayer
     if (is_null($targetPlayer)) {
         Server::getInstance()->getLogger()->info(Main::PREFIX . " and old Undead NPC was loaded - despawning");
         parent::__construct($chunk, $nbt);
         $this->close();
         return;
     }
     // if targetPlayer was set we can create chunk and nbt values outselves
     $this->plugin = $plugin;
     $this->thisname = "Undead " . $targetPlayer->getName();
     $name = $this->thisname;
     //$IsSlim = $targetPlayer->isSkinSlim();
     $playerX = $entityToCopyCoords->getX();
     $playerY = $entityToCopyCoords->getY();
     $playerZ = $entityToCopyCoords->getZ();
     $outX = round($playerX, 1);
     $outY = round($playerY, 1);
     $outZ = round($playerZ, 1);
     $playerLevel = $entityToCopyCoords->getLevel()->getName();
     $playerYaw = $entityToCopyCoords->getYaw();
     $playerPitch = $entityToCopyCoords->getPitch();
     $humanInv = $targetPlayer->getInventory();
     $pHealth = 1;
     $pHeldItem = $targetPlayer->getInventory()->getItemInHand();
     $nbt = new CompoundTag();
     $motion = new Vector3(0, 0, 0);
     $nbt->Pos = new ListTag("Pos", [new DoubleTag("", $outX), new DoubleTag("", $outY), new DoubleTag("", $outZ)]);
     $nbt->Motion = new ListTag("Motion", [new DoubleTag("", $motion->x), new DoubleTag("", $motion->y), new DoubleTag("", $motion->z)]);
     $nbt->Rotation = new ListTag("Rotation", [new FloatTag("", $playerYaw), new FloatTag("", $playerPitch)]);
     $nbt->Health = new ShortTag("Health", $pHealth);
     $nbt->Inventory = new ListTag("Inventory", $humanInv);
     $nbt->NameTag = new StringTag("name", $this->thisname);
     //$nbt->Invulnerable = new ByteTag("Invulnerable", 0);
     $nbt->CustomTestTag = new ByteTag("CustomTestTag", 1);
     // get skin and make scary
     $skindata = $targetPlayer->getSkinData();
     $skindata = $this->negaskin($skindata);
     $nbt->Skin = new CompoundTag("Skin", ["Data" => new StringTag("Data", $skindata)]);
     parent::__construct($targetPlayer->getLevel()->getChunk($playerX >> 4, $playerZ >> 4), $nbt);
     $this->perm = new PermissibleBase($this);
     $this->setSkin($skindata, false);
     $this->setTargetPlayer($targetPlayer);
     $this->getInventory()->setHeldItemSlot(0);
     $this->getInventory()->setItemInHand(Item::get(267));
     $this->spawnToAll();
     Server::getInstance()->getLogger()->info(Main::PREFIX . $this->thisname . " spawned");
 }
开发者ID:mwvent,项目名称:WattzMCPE,代码行数:52,代码来源:UndeadPlayer.php

示例6: handleDataPacket


//.........这里部分代码省略.........
                 }
             }
             $nbt = $this->server->getOfflinePlayerData($this->username);
             if (!isset($nbt->NameTag)) {
                 $nbt->NameTag = new String("NameTag", $this->username);
             } else {
                 $nbt["NameTag"] = $this->username;
             }
             $this->gamemode = $nbt["playerGameType"] & 0x3;
             if ($this->server->getForceGamemode()) {
                 $this->gamemode = $this->server->getGamemode();
                 $nbt->playerGameType = new Int("playerGameType", $this->gamemode);
             }
             if (($level = $this->server->getLevelByName($nbt["Level"])) === null) {
                 $this->setLevel($this->server->getDefaultLevel(), true);
                 $nbt["Level"] = $this->level->getName();
                 $nbt["Pos"][0] = $this->level->getSpawnLocation()->x;
                 $nbt["Pos"][1] = $this->level->getSpawnLocation()->y;
                 $nbt["Pos"][2] = $this->level->getSpawnLocation()->z;
             } else {
                 $this->setLevel($level, true);
             }
             if (!$nbt instanceof Compound) {
                 $this->close(TextFormat::YELLOW . $this->username . " has left the game", "Invalid data");
                 return;
             }
             $this->achievements = [];
             /** @var Byte $achievement */
             foreach ($nbt->Achievements as $achievement) {
                 $this->achievements[$achievement->getName()] = $achievement->getValue() > 0 ? true : false;
             }
             $nbt["lastPlayed"] = floor(microtime(true) * 1000);
             $this->server->saveOfflinePlayerData($this->username, $nbt);
             parent::__construct($this->level->getChunk($nbt["Pos"][0] >> 4, $nbt["Pos"][2] >> 4, true), $nbt);
             $this->loggedIn = true;
             $this->server->getPluginManager()->callEvent($ev = new PlayerLoginEvent($this, "Plugin reason"));
             if ($ev->isCancelled()) {
                 $this->close(TextFormat::YELLOW . $this->username . " has left the game", $ev->getKickMessage());
                 return;
             }
             if ($this->isCreative()) {
                 $this->inventory->setHeldItemSlot(0);
             } else {
                 $this->inventory->setHeldItemSlot(0);
             }
             $pk = new LoginStatusPacket();
             $pk->status = 0;
             $this->dataPacket($pk);
             if ($this->spawnPosition === null and isset($this->namedtag->SpawnLevel) and ($level = $this->server->getLevelByName($this->namedtag["SpawnLevel"])) instanceof Level) {
                 $this->spawnPosition = new Position($this->namedtag["SpawnX"], $this->namedtag["SpawnY"], $this->namedtag["SpawnZ"], $level);
             }
             $spawnPosition = $this->getSpawn();
             $this->dead = false;
             $pk = new StartGamePacket();
             $pk->seed = $this->level->getSeed();
             $pk->x = $this->x;
             $pk->y = $this->y;
             $pk->z = $this->z;
             $pk->spawnX = (int) $spawnPosition->x;
             $pk->spawnY = (int) $spawnPosition->y;
             $pk->spawnZ = (int) $spawnPosition->z;
             $pk->generator = 1;
             //0 old, 1 infinite, 2 flat
             $pk->gamemode = $this->gamemode & 0x1;
             $pk->eid = 0;
             //Always use EntityID as zero for the actual player
开发者ID:rryy,项目名称:PocketMine-MP,代码行数:67,代码来源:Player.php

示例7: processLogin

 protected function processLogin()
 {
     if (!$this->server->isWhitelisted(strtolower($this->getName()))) {
         $this->close($this->getLeaveMessage(), "Server is white-listed");
         return;
     } elseif ($this->server->getNameBans()->isBanned(strtolower($this->getName())) or $this->server->getIPBans()->isBanned($this->getAddress())) {
         $this->close($this->getLeaveMessage(), "You are banned");
         return;
     }
     if ($this->hasPermission(Server::BROADCAST_CHANNEL_USERS)) {
         $this->server->getPluginManager()->subscribeToPermission(Server::BROADCAST_CHANNEL_USERS, $this);
     }
     if ($this->hasPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE)) {
         $this->server->getPluginManager()->subscribeToPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE, $this);
     }
     foreach ($this->server->getOnlinePlayers() as $p) {
         if ($p !== $this and strtolower($p->getName()) === strtolower($this->getName())) {
             if ($p->kick("logged in from another location") === false) {
                 $this->close($this->getLeaveMessage(), "Logged in from another location");
                 return;
             }
         } elseif ($p->loggedIn and $this->getUniqueId()->equals($p->getUniqueId())) {
             if ($p->kick("logged in from another location") === false) {
                 $this->close($this->getLeaveMessage(), "Logged in from another location");
                 return;
             }
         }
     }
     $nbt = $this->server->getOfflinePlayerData($this->username);
     $this->playedBefore = $nbt["lastPlayed"] - $nbt["firstPlayed"] > 1;
     // microtime(true) - microtime(true) may have less than one millisecond difference
     if (!isset($nbt->NameTag)) {
         $nbt->NameTag = new StringTag("NameTag", $this->username);
     } else {
         $nbt["NameTag"] = $this->username;
     }
     $this->gamemode = $nbt["playerGameType"] & 0x3;
     if ($this->server->getForceGamemode()) {
         $this->gamemode = $this->server->getGamemode();
         $nbt->playerGameType = new IntTag("playerGameType", $this->gamemode);
     }
     $this->allowFlight = (bool) ($this->gamemode & 0x1);
     if (($level = $this->server->getLevelByName($nbt["Level"])) === null) {
         $this->setLevel($this->server->getDefaultLevel());
         $nbt["Level"] = $this->level->getName();
         $nbt["Pos"][0] = $this->level->getSpawnLocation()->x;
         $nbt["Pos"][1] = $this->level->getSpawnLocation()->y;
         $nbt["Pos"][2] = $this->level->getSpawnLocation()->z;
     } else {
         $this->setLevel($level);
     }
     if (!$nbt instanceof CompoundTag) {
         $this->close($this->getLeaveMessage(), "Invalid data");
         return;
     }
     $this->achievements = [];
     /** @var ByteTag $achievement */
     foreach ($nbt->Achievements as $achievement) {
         $this->achievements[$achievement->getName()] = $achievement->getValue() > 0 ? true : false;
     }
     $nbt->lastPlayed = new LongTag("lastPlayed", floor(microtime(true) * 1000));
     if ($this->server->getAutoSave()) {
         $this->server->saveOfflinePlayerData($this->username, $nbt, true);
     }
     parent::__construct($this->level->getChunk($nbt["Pos"][0] >> 4, $nbt["Pos"][2] >> 4, true), $nbt);
     $this->loggedIn = true;
     $this->server->addOnlinePlayer($this);
     $this->server->getPluginManager()->callEvent($ev = new PlayerLoginEvent($this, "Plugin reason"));
     if ($ev->isCancelled()) {
         $this->close($this->getLeaveMessage(), $ev->getKickMessage());
         return;
     }
     if ($this->isCreative()) {
         $this->inventory->setHeldItemSlot(0);
     } else {
         $this->inventory->setHeldItemSlot($this->inventory->getHotbarSlotIndex(0));
     }
     $this->dataPacket(new ResourcePacksInfoPacket());
     if (!$this->hasValidSpawnPosition() and isset($this->namedtag->SpawnLevel) and ($level = $this->server->getLevelByName($this->namedtag["SpawnLevel"])) instanceof Level) {
         $this->spawnPosition = new WeakPosition($this->namedtag["SpawnX"], $this->namedtag["SpawnY"], $this->namedtag["SpawnZ"], $level);
     }
     $spawnPosition = $this->getSpawn();
     $pk = new StartGamePacket();
     $pk->entityUniqueId = 0;
     $pk->entityRuntimeId = 0;
     $pk->x = $this->x;
     $pk->y = $this->y;
     $pk->z = $this->z;
     $pk->seed = -1;
     $pk->dimension = 0;
     //TODO: implement this properly
     $pk->gamemode = $this->gamemode & 0x1;
     $pk->difficulty = $this->server->getDifficulty();
     $pk->spawnX = $spawnPosition->getFloorX();
     $pk->spawnY = $spawnPosition->getFloorY();
     $pk->spawnZ = $spawnPosition->getFloorZ();
     $pk->hasBeenLoadedInCreative = 1;
     $pk->dayCycleStopTime = -1;
     //TODO: implement this properly
     $pk->eduMode = 0;
//.........这里部分代码省略.........
开发者ID:xxFlare,项目名称:PocketMine-MP,代码行数:101,代码来源:Player.php

示例8: __construct

 public function __construct($player)
 {
     parent::__construct($player->getLevel()->getChunk($player->x >> 4, $player->z >> 4), new Compound("", ["Pos" => new Enum("Pos", [new Double("", 0), new Double("", 0), new Double("", 0)]), "Motion" => new Enum("Motion", [new Double("", 0), new Double("", 0), new Double("", 0)]), "Rotation" => new Enum("Rotation", [new Float("", 0), new Float("", 0)])]));
     $this->player = $player;
     $this->inventory = new PlayerInventory($this);
 }
开发者ID:Skull3x,项目名称:MineBlock,代码行数:6,代码来源:HealBed.php


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