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


PHP event\Timings类代码示例

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


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

示例1: __construct

 /**
  * @param string $timingName
  * @param Task   $task
  * @param int    $taskId
  * @param int    $delay
  * @param int    $period
  */
 public function __construct($timingName, Task $task, $taskId, $delay = -1, $period = -1)
 {
     $this->task = $task;
     $this->taskId = $taskId;
     $this->delay = $delay;
     $this->period = $period;
     $this->timingName = $timingName === null ? "Unknown" : $timingName;
     $this->timings = Timings::getPluginTaskTimings($this, $period);
 }
开发者ID:NewDelion,项目名称:PocketMine-0.13.x,代码行数:16,代码来源:TaskHandler.php

示例2: __construct

 public function __construct(FullChunk $chunk, Compound $nbt)
 {
     if ($chunk === null or $chunk->getProvider() === null) {
         throw new \Exception("Invalid garbage Chunk given to Tile");
     }
     $this->server = $chunk->getProvider()->getLevel()->getServer();
     $this->chunk = $chunk;
     $this->setLevel($chunk->getProvider()->getLevel());
     $this->namedtag = $nbt;
     $this->closed = false;
     $this->name = "";
     $this->lastUpdate = microtime(true);
     $this->id = Tile::$tileCount++;
     $this->x = (int) $this->namedtag["x"];
     $this->y = (int) $this->namedtag["y"];
     $this->z = (int) $this->namedtag["z"];
     $this->chunk->addTile($this);
     $this->getLevel()->addTile($this);
     $this->tickTimer = Timings::getTileEntityTimings($this);
 }
开发者ID:boybook,项目名称:PocketMine-MP,代码行数:20,代码来源:Tile.php

示例3: __construct

 public function __construct(FullChunk $chunk, Compound $nbt)
 {
     if ($chunk === null or $chunk->getProvider() === null) {
         throw new ChunkException("Invalid garbage Chunk given to Entity");
     }
     $this->timings = Timings::getEntityTimings($this);
     if ($this->eyeHeight === null) {
         $this->eyeHeight = $this->height / 2 + 0.1;
     }
     $this->id = Entity::$entityCount++;
     $this->justCreated = true;
     $this->namedtag = $nbt;
     $this->chunk = $chunk;
     $this->setLevel($chunk->getProvider()->getLevel());
     $this->server = $chunk->getProvider()->getLevel()->getServer();
     $this->boundingBox = new AxisAlignedBB(0, 0, 0, 0, 0, 0);
     $this->setPositionAndRotation(new Vector3($this->namedtag["Pos"][0], $this->namedtag["Pos"][1], $this->namedtag["Pos"][2]), $this->namedtag->Rotation[0], $this->namedtag->Rotation[1], true);
     $this->setMotion(new Vector3($this->namedtag["Motion"][0], $this->namedtag["Motion"][1], $this->namedtag["Motion"][2]));
     if (!isset($this->namedtag->FallDistance)) {
         $this->namedtag->FallDistance = new Float("FallDistance", 0);
     }
     $this->fallDistance = $this->namedtag["FallDistance"];
     if (!isset($this->namedtag->Fire)) {
         $this->namedtag->Fire = new Short("Fire", 0);
     }
     $this->fireTicks = $this->namedtag["Fire"];
     if (!isset($this->namedtag->Air)) {
         $this->namedtag->Air = new Short("Air", 300);
     }
     $this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, $this->namedtag["Air"]);
     if (!isset($this->namedtag->OnGround)) {
         $this->namedtag->OnGround = new Byte("OnGround", 0);
     }
     $this->onGround = $this->namedtag["OnGround"] > 0 ? true : false;
     if (!isset($this->namedtag->Invulnerable)) {
         $this->namedtag->Invulnerable = new Byte("Invulnerable", 0);
     }
     $this->invulnerable = $this->namedtag["Invulnerable"] > 0 ? true : false;
     $this->chunk->addEntity($this);
     $this->level->addEntity($this);
     $this->initEntity();
     $this->lastUpdate = $this->server->getTick();
     $this->server->getPluginManager()->callEvent(new EntitySpawnEvent($this));
     $this->checkBlockCollisionTicks = (int) $this->server->getAdvancedProperty("main.check-block-collision", 1);
     $this->scheduleUpdate();
 }
开发者ID:RedstoneAlmeida,项目名称:Steadfast2,代码行数:46,代码来源:Entity.php

示例4: __construct


//.........这里部分代码省略.........
     $this->levelMetadata = new LevelMetadataStore();
     $this->operators = new Config($this->dataPath . "ops.txt", Config::ENUM);
     $this->whitelist = new Config($this->dataPath . "white-list.txt", Config::ENUM);
     if (file_exists($this->dataPath . "banned.txt") and !file_exists($this->dataPath . "banned-players.txt")) {
         @rename($this->dataPath . "banned.txt", $this->dataPath . "banned-players.txt");
     }
     @touch($this->dataPath . "banned-players.txt");
     $this->banByName = new BanList($this->dataPath . "banned-players.txt");
     $this->banByName->load();
     @touch($this->dataPath . "banned-ips.txt");
     $this->banByIP = new BanList($this->dataPath . "banned-ips.txt");
     $this->banByIP->load();
     $this->maxPlayers = $this->getConfigInt("max-players", 20);
     $this->setAutoSave($this->getConfigBoolean("auto-save", true));
     if ($this->getConfigBoolean("hardcore", false) === true and $this->getDifficulty() < 3) {
         $this->setConfigInt("difficulty", 3);
     }
     define("pocketmine\\DEBUG", (int) $this->getProperty("debug.level", 1));
     if ($this->logger instanceof MainLogger) {
         $this->logger->setLogDebug(\pocketmine\DEBUG > 1);
     }
     if (\pocketmine\DEBUG >= 0) {
         @cli_set_process_title($this->getName() . " " . $this->getPocketMineVersion());
     }
     $this->logger->info($this->getLanguage()->translateString("pocketmine.server.networkStart", [$this->getIp() === "" ? "*" : $this->getIp(), $this->getPort()]));
     define("BOOTUP_RANDOM", @Utils::getRandomBytes(16));
     $this->serverID = Utils::getMachineUniqueId($this->getIp() . $this->getPort());
     $this->getLogger()->debug("Server unique id: " . $this->getServerUniqueId());
     $this->getLogger()->debug("Machine unique id: " . Utils::getMachineUniqueId());
     $this->network = new Network($this);
     $this->network->setName($this->getMotd());
     $this->logger->info($this->getLanguage()->translateString("pocketmine.server.info", [$this->getName(), ($version->isDev() ? TextFormat::YELLOW : "") . $version->get(true) . TextFormat::WHITE, $this->getCodename(), $this->getApiVersion()]));
     $this->logger->info($this->getLanguage()->translateString("pocketmine.server.license", [$this->getName()]));
     Timings::init();
     $this->consoleSender = new ConsoleCommandSender();
     $this->commandMap = new SimpleCommandMap($this);
     $this->registerEntities();
     $this->registerTiles();
     InventoryType::init();
     Block::init();
     Item::init();
     Biome::init();
     Effect::init();
     Enchantment::init();
     Attribute::init();
     /** TODO: @deprecated */
     TextWrapper::init();
     $this->craftingManager = new CraftingManager();
     $this->pluginManager = new PluginManager($this, $this->commandMap);
     $this->pluginManager->subscribeToPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE, $this->consoleSender);
     $this->pluginManager->setUseTimings($this->getProperty("settings.enable-profiling", false));
     $this->profilingTickRate = (double) $this->getProperty("settings.profile-report-trigger", 20);
     $this->pluginManager->registerInterface(PharPluginLoader::class);
     $this->pluginManager->registerInterface(ScriptPluginLoader::class);
     set_exception_handler([$this, "exceptionHandler"]);
     register_shutdown_function([$this, "crashDump"]);
     $this->queryRegenerateTask = new QueryRegenerateEvent($this, 5);
     $this->network->registerInterface(new RakLibInterface($this));
     $this->pluginManager->loadPlugins($this->pluginPath);
     $this->updater = new AutoUpdater($this, $this->getProperty("auto-updater.host", "www.pocketmine.net"));
     $this->enablePlugins(PluginLoadOrder::STARTUP);
     LevelProviderManager::addProvider($this, Anvil::class);
     LevelProviderManager::addProvider($this, McRegion::class);
     if (extension_loaded("leveldb")) {
         $this->logger->debug($this->getLanguage()->translateString("pocketmine.debug.enable"));
         LevelProviderManager::addProvider($this, LevelDB::class);
开发者ID:ZenaGamingsky,项目名称:PocketBox,代码行数:67,代码来源:Server.php

示例5: __construct

 public function __construct(FullChunk $chunk, CompoundTag $nbt)
 {
     assert($chunk !== null and $chunk->getProvider() !== null);
     $this->timings = Timings::getTileEntityTimings($this);
     $this->server = $chunk->getProvider()->getLevel()->getServer();
     $this->chunk = $chunk;
     $this->setLevel($chunk->getProvider()->getLevel());
     $this->namedtag = $nbt;
     $this->name = "";
     $this->lastUpdate = microtime(true);
     $this->id = Tile::$tileCount++;
     $this->x = (int) $this->namedtag["x"];
     $this->y = (int) $this->namedtag["y"];
     $this->z = (int) $this->namedtag["z"];
     $this->chunk->addTile($this);
     $this->getLevel()->addTile($this);
     $this->tickTimer = Timings::getTileEntityTimings($this);
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:18,代码来源:Tile.php

示例6: __construct


//.........这里部分代码省略.........
     $this->setAutoSave($this->getConfigBoolean("auto-save", true));
     if (($memory = str_replace("B", "", strtoupper($this->getConfigString("memory-limit", "256M")))) !== false) {
         $value = ["M" => 1, "G" => 1024];
         $real = (int) substr($memory, 0, -1) * $value[substr($memory, -1)];
         if ($real < 128) {
             $this->logger->warning($this->getName() . " may not work right with less than 128MB of RAM", true, true, 0);
         }
         @ini_set("memory_limit", $memory);
     } else {
         $this->setConfigString("memory-limit", "256M");
     }
     $this->network = new Network($this);
     if ($this->getConfigBoolean("hardcore", false) === true and $this->getDifficulty() < 3) {
         $this->setConfigInt("difficulty", 3);
     }
     define("pocketmine\\DEBUG", (int) $this->getProperty("debug.level", 1));
     if ($this->logger instanceof MainLogger) {
         $this->logger->setLogDebug(\pocketmine\DEBUG > 1);
     }
     define("ADVANCED_CACHE", $this->getProperty("settings.advanced-cache", false));
     if (ADVANCED_CACHE == true) {
         $this->logger->info("Advanced cache enabled");
     }
     Level::$COMPRESSION_LEVEL = $this->getProperty("chunk-sending.compression-level", 8);
     if (defined("pocketmine\\DEBUG") and \pocketmine\DEBUG >= 0) {
         @\cli_set_process_title($this->getName() . " " . $this->getPocketMineVersion());
     }
     $this->logger->info("Starting Minecraft PE server on " . ($this->getIp() === "" ? "*" : $this->getIp()) . ":" . $this->getPort());
     define("BOOTUP_RANDOM", @Utils::getRandomBytes(16));
     $this->serverID = Utils::getMachineUniqueId($this->getIp() . $this->getPort());
     $this->addInterface($this->mainInterface = new RakLibInterface($this));
     $this->logger->info("This server is running " . $this->getName() . " version " . ($version->isDev() ? TextFormat::YELLOW : "") . $version->get(true) . TextFormat::WHITE . " \"" . $this->getCodename() . "\" (API " . $this->getApiVersion() . ")");
     $this->logger->info($this->getName() . " is distributed under the LGPL License");
     PluginManager::$pluginParentTimer = new TimingsHandler("** Plugins");
     Timings::init();
     $this->consoleSender = new ConsoleCommandSender();
     $this->commandMap = new SimpleCommandMap($this);
     $this->registerEntities();
     $this->registerTiles();
     InventoryType::init();
     Block::init();
     Item::init();
     TextWrapper::init();
     $this->craftingManager = new CraftingManager();
     $this->pluginManager = new PluginManager($this, $this->commandMap);
     $this->pluginManager->subscribeToPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE, $this->consoleSender);
     $this->pluginManager->setUseTimings($this->getProperty("settings.enable-profiling", false));
     $this->pluginManager->registerInterface(PharPluginLoader::class);
     \set_exception_handler([$this, "exceptionHandler"]);
     register_shutdown_function([$this, "crashDump"]);
     $plugins = $this->pluginManager->loadPlugins($this->pluginPath);
     $configPlugins = $this->getAdvancedProperty("plugins", []);
     if (count($configPlugins) > 0) {
         $this->getLogger()->info("Checking extra plugins");
         $loadNew = false;
         foreach ($configPlugins as $plugin => $download) {
             if (!isset($plugins[$plugin])) {
                 $path = $this->pluginPath . "/" . $plugin . ".phar";
                 if (substr($download, 0, 4) === "http") {
                     $this->getLogger()->info("Downloading " . $plugin);
                     file_put_contents($path, Utils::getURL($download));
                 } else {
                     file_put_contents($path, file_get_contents($download));
                 }
                 $loadNew = true;
             }
开发者ID:ZenaGamingsky,项目名称:Steadfast2,代码行数:67,代码来源:Server.php

示例7: __construct

 public function __construct(FullChunk $chunk, CompoundTag $nbt)
 {
     assert($chunk !== null and $chunk->getProvider() !== null);
     $this->timings = Timings::getEntityTimings($this);
     $this->isPlayer = $this instanceof Player;
     $this->temporalVector = new Vector3();
     if ($this->eyeHeight === null) {
         $this->eyeHeight = $this->height / 2 + 0.1;
     }
     $this->id = Entity::$entityCount++;
     $this->justCreated = true;
     $this->namedtag = $nbt;
     $this->chunk = $chunk;
     $this->setLevel($chunk->getProvider()->getLevel());
     $this->server = $chunk->getProvider()->getLevel()->getServer();
     $this->boundingBox = new AxisAlignedBB(0, 0, 0, 0, 0, 0);
     $this->setPositionAndRotation($this->temporalVector->setComponents($this->namedtag["Pos"][0], $this->namedtag["Pos"][1], $this->namedtag["Pos"][2]), $this->namedtag->Rotation[0], $this->namedtag->Rotation[1]);
     $this->setMotion($this->temporalVector->setComponents($this->namedtag["Motion"][0], $this->namedtag["Motion"][1], $this->namedtag["Motion"][2]));
     assert(!is_nan($this->x) and !is_infinite($this->x) and !is_nan($this->y) and !is_infinite($this->y) and !is_nan($this->z) and !is_infinite($this->z));
     if (!isset($this->namedtag->FallDistance)) {
         $this->namedtag->FallDistance = new FloatTag("FallDistance", 0);
     }
     $this->fallDistance = $this->namedtag["FallDistance"];
     if (!isset($this->namedtag->Fire) || $this->namedtag["Fire"] > 32767) {
         $this->namedtag->Fire = new ShortTag("Fire", 0);
     }
     $this->fireTicks = $this->namedtag["Fire"];
     if (!isset($this->namedtag->Air)) {
         $this->namedtag->Air = new ShortTag("Air", 300);
     }
     $this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, $this->namedtag["Air"], false);
     if (!isset($this->namedtag->OnGround)) {
         $this->namedtag->OnGround = new ByteTag("OnGround", 0);
     }
     $this->onGround = $this->namedtag["OnGround"] > 0 ? true : false;
     if (!isset($this->namedtag->Invulnerable)) {
         $this->namedtag->Invulnerable = new ByteTag("Invulnerable", 0);
     }
     $this->invulnerable = $this->namedtag["Invulnerable"] > 0 ? true : false;
     $this->attributeMap = new AttributeMap();
     $this->chunk->addEntity($this);
     $this->level->addEntity($this);
     $this->initEntity();
     $this->lastUpdate = $this->server->getTick();
     $this->server->getPluginManager()->callEvent(new EntitySpawnEvent($this));
     $this->scheduleUpdate();
 }
开发者ID:robske110,项目名称:ClearSky,代码行数:47,代码来源:Entity.php

示例8: handleDataPacket

 /**
  * Handles a Minecraft packet
  * TODO: Separate all of this in handlers
  *
  * WARNING: Do not use this, it's only for internal use.
  * Changes to this function won't be recorded on the version.
  *
  * @param DataPacket $packet
  */
 public function handleDataPacket(DataPacket $packet)
 {
     if ($this->connected === false) {
         return;
     }
     if ($packet::NETWORK_ID === ProtocolInfo::BATCH_PACKET) {
         /** @var BatchPacket $packet */
         $this->server->getNetwork()->processBatch($packet, $this);
         return;
     }
     $timings = Timings::getReceiveDataPacketTimings($packet);
     $timings->startTiming();
     $this->server->getPluginManager()->callEvent($ev = new DataPacketReceiveEvent($this, $packet));
     if ($ev->isCancelled()) {
         $timings->stopTiming();
         return;
     }
     switch ($packet::NETWORK_ID) {
         case ProtocolInfo::ITEM_FRAME_DROP_ITEM_PACKET:
             $tile = $this->level->getTile($this->temporalVector->setComponents($packet->x, $packet->y, $packet->z));
             if ($tile instanceof ItemFrame) {
                 $block = $this->level->getBlock($tile);
                 $this->server->getPluginManager()->callEvent($ev = new BlockBreakEvent($this, $block, $this->getInventory()->getItemInHand(), true));
                 if (!$ev->isCancelled()) {
                     $item = $tile->getItem();
                     $this->server->getPluginManager()->callEvent($ev = new ItemFrameDropItemEvent($this, $block, $tile, $item));
                     if (!$ev->isCancelled()) {
                         if ($item->getId() !== Item::AIR) {
                             if (mt_rand(0, 10) / 10 < $tile->getItemDropChance()) {
                                 $this->level->dropItem($tile, $item);
                             }
                             $tile->setItem(Item::get(Item::AIR));
                             $tile->setItemRotation(0);
                         }
                     } else {
                         $tile->spawnTo($this);
                     }
                 } else {
                     $tile->spawnTo($this);
                 }
             }
             break;
         case ProtocolInfo::REQUEST_CHUNK_RADIUS_PACKET:
             /*if($this->spawned){
             			$this->viewDistance = $packet->radius ** 2;
             		}*/
             $pk = new ChunkRadiusUpdatedPacket();
             $pk->radius = $this->server->chunkRadius != -1 ? $this->server->chunkRadius : $packet->radius;
             $this->dataPacket($pk);
             break;
         case ProtocolInfo::PLAYER_INPUT_PACKET:
             break;
         case ProtocolInfo::LOGIN_PACKET:
             if ($this->loggedIn) {
                 break;
             }
             $pk = new PlayStatusPacket();
             $pk->status = PlayStatusPacket::LOGIN_SUCCESS;
             $this->dataPacket($pk);
             $this->username = TextFormat::clean($packet->username);
             $this->displayName = $this->username;
             $this->setNameTag($this->username);
             $this->iusername = strtolower($this->username);
             $this->protocol = $packet->protocol;
             if ($this->server->getConfigBoolean("online-mode", false) && $packet->identityPublicKey === null) {
                 $this->kick("disconnectionScreen.notAuthenticated", false);
                 break;
             }
             if (count($this->server->getOnlinePlayers()) >= $this->server->getMaxPlayers() and $this->kick("disconnectionScreen.serverFull", false)) {
                 break;
             }
             if (!in_array($packet->protocol, ProtocolInfo::ACCEPTED_PROTOCOLS)) {
                 if ($packet->protocol < ProtocolInfo::CURRENT_PROTOCOL) {
                     $message = "disconnectionScreen.outdatedClient";
                     $pk = new PlayStatusPacket();
                     $pk->status = PlayStatusPacket::LOGIN_FAILED_CLIENT;
                     $this->directDataPacket($pk);
                 } else {
                     $message = "disconnectionScreen.outdatedServer";
                     $pk = new PlayStatusPacket();
                     $pk->status = PlayStatusPacket::LOGIN_FAILED_SERVER;
                     $this->directDataPacket($pk);
                 }
                 $this->close("", $message, false);
                 break;
             }
             $this->randomClientId = $packet->clientId;
             $this->uuid = UUID::fromString($packet->clientUUID);
             $this->rawUUID = $this->uuid->toBinary();
             $valid = true;
             $len = strlen($packet->username);
//.........这里部分代码省略.........
开发者ID:iTXTech,项目名称:Genisys,代码行数:101,代码来源:Player.php

示例9: __construct


//.........这里部分代码省略.........
         if (file_exists($this->dataPath . "banned.txt") and !file_exists($this->dataPath . "banned-players.txt")) {
             @rename($this->dataPath . "banned.txt", $this->dataPath . "banned-players.txt");
         }
         @touch($this->dataPath . "banned-players.txt");
         $this->banByName = new BanList($this->dataPath . "banned-players.txt");
         $this->banByName->load();
         @touch($this->dataPath . "banned-ips.txt");
         $this->banByIP = new BanList($this->dataPath . "banned-ips.txt");
         $this->banByIP->load();
         @touch($this->dataPath . "banned-cids.txt");
         $this->banByCID = new BanList($this->dataPath . "banned-cids.txt");
         $this->banByCID->load();
         $this->maxPlayers = $this->getConfigInt("max-players", 20);
         $this->setAutoSave($this->getConfigBoolean("auto-save", true));
         if ($this->getConfigBoolean("hardcore", false) === true and $this->getDifficulty() < 3) {
             $this->setConfigInt("difficulty", 3);
         }
         define("pocketmine\\DEBUG", (int) $this->getProperty("debug.level", 1));
         if ($this->logger instanceof MainLogger) {
             $this->logger->setLogDebug(\pocketmine\DEBUG > 1);
         }
         if (\pocketmine\DEBUG >= 0) {
             @cli_set_process_title($this->getName() . " " . $this->getPocketMineVersion());
         }
         $this->logger->info($this->getLanguage()->translateString("pocketmine.server.networkStart", [$this->getIp() === "" ? "*" : $this->getIp(), $this->getPort()]));
         define("BOOTUP_RANDOM", @Utils::getRandomBytes(16));
         $this->serverID = Utils::getMachineUniqueId($this->getIp() . $this->getPort());
         $this->getLogger()->debug("Server unique id: " . $this->getServerUniqueId());
         $this->getLogger()->debug("Machine unique id: " . Utils::getMachineUniqueId());
         $this->network = new Network($this);
         $this->network->setName($this->getMotd());
         $this->logger->info($this->getLanguage()->translateString("pocketmine.server.info", [$this->getName(), $this->getPocketMineVersion(), $this->getCodename(), $this->getApiVersion()]));
         $this->logger->info($this->getLanguage()->translateString("pocketmine.server.license", [$this->getName()]));
         Timings::init();
         $this->consoleSender = new ConsoleCommandSender();
         $this->commandMap = new SimpleCommandMap($this);
         $this->registerEntities();
         $this->registerTiles();
         InventoryType::init(min(32, $this->inventoryNum));
         //Bigger than 32 with cause problems
         Block::init();
         Item::init();
         Biome::init();
         Effect::init();
         Enchantment::init();
         Attribute::init();
         /** TODO: @deprecated */
         //TextWrapper::init();
         $this->craftingManager = new CraftingManager($this->readRecipesFromJson);
         $this->pluginManager = new PluginManager($this, $this->commandMap);
         $this->pluginManager->subscribeToPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE, $this->consoleSender);
         $this->pluginManager->setUseTimings($this->getProperty("settings.enable-profiling", false));
         $this->profilingTickRate = (double) $this->getProperty("settings.profile-report-trigger", 20);
         $this->pluginManager->registerInterface(PharPluginLoader::class);
         $this->pluginManager->registerInterface(FolderPluginLoader::class);
         $this->pluginManager->registerInterface(ScriptPluginLoader::class);
         //set_exception_handler([$this, "exceptionHandler"]);
         register_shutdown_function([$this, "crashDump"]);
         $this->queryRegenerateTask = new QueryRegenerateEvent($this, 5);
         $this->network->registerInterface(new RakLibInterface($this));
         $this->pluginManager->loadPlugins($this->pluginPath);
         //$this->updater = new AutoUpdater($this, $this->getProperty("auto-updater.host", "www.pocketmine.net"));
         $this->enablePlugins(PluginLoadOrder::STARTUP);
         LevelProviderManager::addProvider($this, Anvil::class);
         LevelProviderManager::addProvider($this, McRegion::class);
         if (extension_loaded("leveldb")) {
开发者ID:xuxugzs,项目名称:Genisys,代码行数:67,代码来源:Server.php

示例10: handleDataPacket

 /**
  * Handles a Minecraft packet
  * TODO: Separate all of this in handlers
  *
  * WARNING: Do not use this, it's only for internal use.
  * Changes to this function won't be recorded on the version.
  *
  * @param DataPacket $packet
  */
 public function handleDataPacket(DataPacket $packet)
 {
     if ($this->connected === false) {
         return;
     }
     if ($packet::NETWORK_ID === ProtocolInfo::BATCH_PACKET) {
         /** @var BatchPacket $packet */
         $this->server->getNetwork()->processBatch($packet, $this);
         return;
     }
     $timings = Timings::getReceiveDataPacketTimings($packet);
     $timings->startTiming();
     $this->server->getPluginManager()->callEvent($ev = new DataPacketReceiveEvent($this, $packet));
     if ($ev->isCancelled()) {
         $timings->stopTiming();
         return;
     }
     switch ($packet::NETWORK_ID) {
         case ProtocolInfo::ITEM_FRAME_DROP_ITEM_PACKET:
             $tile = $this->level->getTile($this->temporalVector->setComponents($packet->x, $packet->y, $packet->z));
             if ($tile instanceof ItemFrame) {
                 if ($tile->getItem()->getId() !== Item::AIR) {
                     $this->getServer()->getPluginManager()->callEvent($ev = new ItemFrameDropItemEvent($this->getLevel()->getBlock($tile), $this, $tile->getItem(), $tile->getItemDropChance()));
                     if (!$ev->isCancelled()) {
                         if (mt_rand(0, 10) / 10 <= $tile->getItemDropChance()) {
                             $this->level->dropItem($tile, $tile->getItem());
                         }
                         $tile->setItem(Item::get(Item::AIR));
                         $tile->setItemRotation(0);
                     }
                 }
             }
             break;
         case ProtocolInfo::PLAYER_INPUT_PACKET:
             break;
         case ProtocolInfo::LOGIN_PACKET:
             if ($this->loggedIn) {
                 break;
             }
             $this->username = TextFormat::clean($packet->username);
             $this->displayName = $this->username;
             $this->iusername = strtolower($this->username);
             #$this->setDataProperty(self::DATA_NAMETAG, self::DATA_TYPE_STRING, $this->username, false);
             if ($this->server->getMaxPlayers() !== -1) {
                 if (count($this->server->getOnlinePlayers()) >= $this->server->getMaxPlayers() and $this->kick("disconnectionScreen.serverFull", false)) {
                     break;
                 }
             }
             if (!in_array($packet->protocol, ProtocolInfo::ACCEPT_PROTOCOL)) {
                 if ($packet->protocol < ProtocolInfo::CURRENT_PROTOCOL) {
                     $message = "disconnectionScreen.outdatedClient";
                     $pk = new PlayStatusPacket();
                     $pk->status = PlayStatusPacket::LOGIN_FAILED_CLIENT;
                     $this->directDataPacket($pk);
                 } else {
                     $message = "disconnectionScreen.outdatedServer";
                     $pk = new PlayStatusPacket();
                     $pk->status = PlayStatusPacket::LOGIN_FAILED_SERVER;
                     $this->directDataPacket($pk);
                 }
                 $this->close("", $message, false);
                 break;
             }
             $this->randomClientId = $packet->clientId;
             $this->uuid = UUID::fromString($packet->clientUUID);
             $this->rawUUID = $this->uuid->toBinary();
             $this->identityPublicKey = $packet->identityPublicKey;
             $this->chainData = $packet->chainData;
             $valid = true;
             $len = strlen($packet->username);
             if ($len > 16 or $len < 3) {
                 $valid = false;
             }
             for ($i = 0; $i < $len and $valid; ++$i) {
                 $c = ord($packet->username[$i]);
                 if ($c >= ord("a") and $c <= ord("z") or $c >= ord("A") and $c <= ord("Z") or $c >= ord("0") and $c <= ord("9") or $c === ord("_")) {
                     continue;
                 }
                 $valid = false;
                 break;
             }
             if (!$valid or $this->iusername === "rcon" or $this->iusername === "console") {
                 $this->close("", "disconnectionScreen.invalidName");
                 break;
             }
             if (strlen($packet->skin) !== 64 * 32 * 4 and strlen($packet->skin) !== 64 * 64 * 4) {
                 $this->close("", "disconnectionScreen.invalidSkin");
                 break;
             }
             $this->setSkin($packet->skin, $packet->skinId);
             $this->server->getPluginManager()->callEvent($ev = new PlayerPreLoginEvent($this, "Plugin reason"));
//.........这里部分代码省略.........
开发者ID:robske110,项目名称:ClearSky,代码行数:101,代码来源:Player.php

示例11: __construct


//.........这里部分代码省略.........
         $this->operators = new Config($this->dataPath . "ops.txt", Config::ENUM);
         $this->whitelist = new Config($this->dataPath . "white-list.txt", Config::ENUM);
         if (file_exists($this->dataPath . "banned.txt") and !file_exists($this->dataPath . "banned-players.txt")) {
             @rename($this->dataPath . "banned.txt", $this->dataPath . "banned-players.txt");
         }
         @touch($this->dataPath . "banned-players.txt");
         $this->banByName = new BanList($this->dataPath . "banned-players.txt");
         $this->banByName->load();
         @touch($this->dataPath . "banned-ips.txt");
         $this->banByIP = new BanList($this->dataPath . "banned-ips.txt");
         $this->banByIP->load();
         $this->maxPlayers = $this->getConfigInt("max-players", 20);
         $this->setAutoSave($this->getConfigBoolean("auto-save", true));
         if ($this->getConfigBoolean("hardcore", false) === true and $this->getDifficulty() < 3) {
             $this->setConfigInt("difficulty", 3);
         }
         define('pocketmine\\DEBUG', (int) $this->getProperty("debug.level", 1));
         ini_set('assert.exception', 1);
         if ($this->logger instanceof MainLogger) {
             $this->logger->setLogDebug(\pocketmine\DEBUG > 1);
         }
         if (\pocketmine\DEBUG >= 0) {
             @cli_set_process_title($this->getName() . " " . $this->getPocketMineVersion());
         }
         $this->logger->info($this->getLanguage()->translateString("pocketmine.server.networkStart", [$this->getIp() === "" ? "*" : $this->getIp(), $this->getPort()]));
         define("BOOTUP_RANDOM", random_bytes(16));
         $this->serverID = Utils::getMachineUniqueId($this->getIp() . $this->getPort());
         $this->getLogger()->debug("Server unique id: " . $this->getServerUniqueId());
         $this->getLogger()->debug("Machine unique id: " . Utils::getMachineUniqueId());
         $this->network = new Network($this);
         $this->network->setName($this->getMotd());
         $this->logger->info($this->getLanguage()->translateString("pocketmine.server.info", [$this->getName(), $this->getPocketMineVersion(), $this->getCodename(), $this->getApiVersion(), $this->getPocketMineBuild()]));
         $this->logger->info($this->getLanguage()->translateString("pocketmine.server.license", [$this->getName()]));
         Timings::init();
         $this->consoleSender = new ConsoleCommandSender();
         $this->commandMap = new SimpleCommandMap($this);
         $this->registerEntities();
         $this->registerTiles();
         InventoryType::init();
         Block::init();
         Item::init();
         Biome::init();
         Effect::init();
         Enchantment::init();
         Attribute::init();
         EnchantmentLevelTable::init();
         Color::init();
         $this->craftingManager = new CraftingManager();
         $this->pluginManager = new PluginManager($this, $this->commandMap);
         $this->pluginManager->subscribeToPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE, $this->consoleSender);
         $this->pluginManager->setUseTimings($this->getProperty("settings.enable-profiling", false));
         $this->profilingTickRate = (double) $this->getProperty("settings.profile-report-trigger", 20);
         $this->pluginManager->registerInterface(PharPluginLoader::class);
         $this->pluginManager->registerInterface(ScriptPluginLoader::class);
         register_shutdown_function([$this, "crashDump"]);
         $this->queryRegenerateTask = new QueryRegenerateEvent($this, 5);
         $this->network->registerInterface(new RakLibInterface($this));
         $this->pluginManager->loadPlugins($this->pluginPath);
         $this->updater = new AutoUpdater($this, $this->getProperty("auto-updater.host", "jenkins.clearskyteam.org"));
         $this->enablePlugins(PluginLoadOrder::STARTUP);
         LevelProviderManager::addProvider($this, Anvil::class);
         LevelProviderManager::addProvider($this, McRegion::class);
         if (extension_loaded("leveldb")) {
             $this->logger->debug($this->getLanguage()->translateString("pocketmine.debug.enable"));
             LevelProviderManager::addProvider($this, LevelDB::class);
         }
开发者ID:robske110,项目名称:ClearSky,代码行数:67,代码来源:Server.php

示例12: handleDataPacket

 /**
  * Handles a Minecraft packet
  * TODO: Separate all of this in handlers
  *
  * WARNING: Do not use this, it's only for internal use.
  * Changes to this function won't be recorded on the version.
  *
  * @param DataPacket $packet
  */
 public function handleDataPacket(DataPacket $packet)
 {
     if ($this->connected === false) {
         return;
     }
     if ($packet::NETWORK_ID === ProtocolInfo::BATCH_PACKET) {
         /** @var BatchPacket $packet */
         $this->server->getNetwork()->processBatch($packet, $this);
         return;
     }
     $timings = Timings::getReceiveDataPacketTimings($packet);
     $timings->startTiming();
     $this->server->getPluginManager()->callEvent($ev = new DataPacketReceiveEvent($this, $packet));
     if ($ev->isCancelled()) {
         $timings->stopTiming();
         return;
     }
     switch ($packet::NETWORK_ID) {
         case ProtocolInfo::ITEM_FRAME_DROP_ITEM_PACKET:
             $tile = $this->level->getTile($this->temporalVector->setComponents($packet->x, $packet->y, $packet->z));
             if ($tile instanceof ItemFrame) {
                 $block = $this->level->getBlock($tile);
                 $this->server->getPluginManager()->callEvent($ev = new BlockBreakEvent($this, $block, $this->getInventory()->getItemInHand(), true));
                 if (!$ev->isCancelled()) {
                     $item = $tile->getItem();
                     $this->server->getPluginManager()->callEvent($ev = new ItemFrameDropItemEvent($this, $block, $tile, $item));
                     if (!$ev->isCancelled()) {
                         if ($item->getId() !== Item::AIR) {
                             if (mt_rand(0, 10) / 10 < $tile->getItemDropChance()) {
                                 $this->level->dropItem($tile, $item);
                             }
                             $tile->setItem(Item::get(Item::AIR));
                             $tile->setItemRotation(0);
                         }
                     } else {
                         $tile->spawnTo($this);
                     }
                 } else {
                     $tile->spawnTo($this);
                 }
             }
             break;
         case ProtocolInfo::REQUEST_CHUNK_RADIUS_PACKET:
             /*if($this->spawned){
             			$this->viewDistance = $packet->radius ** 2;
             		}*/
             $pk = new ChunkRadiusUpdatedPacket();
             $pk->radius = $this->server->chunkRadius != -1 ? $this->server->chunkRadius : $packet->radius;
             $this->dataPacket($pk);
             break;
         case ProtocolInfo::PLAYER_INPUT_PACKET:
             break;
         case ProtocolInfo::LOGIN_PACKET:
             if ($this->loggedIn) {
                 break;
             }
             $pk = new PlayStatusPacket();
             $pk->status = PlayStatusPacket::LOGIN_SUCCESS;
             $this->dataPacket($pk);
             $this->username = TextFormat::clean($packet->username);
             $this->displayName = $this->username;
             $this->setNameTag($this->username);
             $this->iusername = strtolower($this->username);
             $this->protocol = $packet->protocol;
             if (count($this->server->getOnlinePlayers()) >= $this->server->getMaxPlayers() and $this->kick("disconnectionScreen.serverFull", false)) {
                 break;
             }
             if (!in_array($packet->protocol, ProtocolInfo::ACCEPTED_PROTOCOLS)) {
                 if ($packet->protocol < ProtocolInfo::CURRENT_PROTOCOL) {
                     $message = "disconnectionScreen.outdatedClient";
                     $pk = new PlayStatusPacket();
                     $pk->status = PlayStatusPacket::LOGIN_FAILED_CLIENT;
                     $this->directDataPacket($pk);
                 } else {
                     $message = "disconnectionScreen.outdatedServer";
                     $pk = new PlayStatusPacket();
                     $pk->status = PlayStatusPacket::LOGIN_FAILED_SERVER;
                     $this->directDataPacket($pk);
                 }
                 $this->close("", $message, false);
                 break;
             }
             $this->randomClientId = $packet->clientId;
             $this->loginData = ["clientId" => $packet->clientId, "loginData" => null];
             $this->uuid = UUID::fromString($packet->clientUUID);
             $this->rawUUID = $this->uuid->toBinary();
             $valid = true;
             $len = strlen($packet->username);
             if ($len > 16 or $len < 3) {
                 $valid = false;
             }
//.........这里部分代码省略.........
开发者ID:yungtechboy1,项目名称:Genisys,代码行数:101,代码来源:Player.php

示例13: entityConstruct

 private function entityConstruct(Player $player, FullChunk $chunk, CompoundTag $nbt)
 {
     assert($chunk !== null and $chunk->getProvider() !== null);
     $this->setPrivateVariableData($player, 'timings', Timings::getEntityTimings($player));
     $this->setPrivateVariableData($player, 'isPlayer', $player instanceof Player);
     $player->temporalVector = new Vector3();
     if ($player->eyeHeight === null) {
         $player->eyeHeight = $player->height / 2 + 0.1;
     }
     $this->setPrivateVariableData($player, 'id', Entity::$entityCount++);
     $this->setPrivateVariableData($player, 'justCreated', true);
     $player->namedtag = $nbt;
     $player->chunk = $chunk;
     $player->setLevel($chunk->getProvider()->getLevel());
     $this->setPrivateVariableData($player, 'server', $chunk->getProvider()->getLevel()->getServer());
     $player->boundingBox = new AxisAlignedBB(0, 0, 0, 0, 0, 0);
     $player->setPositionAndRotation($player->temporalVector->setComponents($player->namedtag["Pos"][0], $player->namedtag["Pos"][1], $player->namedtag["Pos"][2]), $player->namedtag->Rotation[0], $player->namedtag->Rotation[1]);
     $player->setMotion($player->temporalVector->setComponents($player->namedtag["Motion"][0], $player->namedtag["Motion"][1], $player->namedtag["Motion"][2]));
     assert(!is_nan($player->x) and !is_infinite($player->x) and !is_nan($player->y) and !is_infinite($player->y) and !is_nan($player->z) and !is_infinite($player->z));
     if (!isset($player->namedtag->FallDistance)) {
         $player->namedtag->FallDistance = new FloatTag("FallDistance", 0);
     }
     $player->fallDistance = $player->namedtag["FallDistance"];
     if (!isset($player->namedtag->Fire)) {
         $player->namedtag->Fire = new ShortTag("Fire", 0);
     }
     $player->fireTicks = $player->namedtag["Fire"];
     if (!isset($player->namedtag->Air)) {
         $player->namedtag->Air = new ShortTag("Air", 300);
     }
     $player->setDataProperty($player::DATA_AIR, $player::DATA_TYPE_SHORT, $player->namedtag["Air"]);
     if (!isset($player->namedtag->OnGround)) {
         $player->namedtag->OnGround = new ByteTag("OnGround", 0);
     }
     $player->onGround = $player->namedtag["OnGround"] > 0 ? true : false;
     if (!isset($player->namedtag->Invulnerable)) {
         $player->namedtag->Invulnerable = new ByteTag("Invulnerable", 0);
     }
     $player->invulnerable = $player->namedtag["Invulnerable"] > 0 ? true : false;
     $player->chunk->addEntity($player);
     $player->level->addEntity($player);
     $this->initialHuman($player);
     $player->lastUpdate = $this->server->getTick();
     $this->server->getPluginManager()->callEvent(new EntitySpawnEvent($player));
     $player->scheduleUpdate();
 }
开发者ID:organization,项目名称:SpawningPool,代码行数:46,代码来源:AuthenticateCallback.php

示例14: doInit

 public function doInit()
 {
     $nbt = $this->server->getOfflinePlayerData($this->name);
     if (!isset($nbt->NameTag)) {
         $nbt->NameTag = new StringTag("NameTag", $this->name);
     } else {
         $nbt["NameTag"] = $this->name;
     }
     $this->gamemode = $nbt["playerGameType"] & 0x3;
     if ($this->server->getForceGamemode()) {
         $this->gamemode = $this->server->getGamemode();
         $nbt->playerGameType = new IntTag("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 CompoundTag) {
         $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 LongTag("lastPlayed", floor(microtime(true) * 1000));
     if ($this->server->getAutoSave()) {
         $this->server->saveOfflinePlayerData($this->name, $nbt, true);
     }
     $chunk = $this->level->getChunk($nbt["Pos"][0] >> 4, $nbt["Pos"][2] >> 4, true);
     assert($chunk !== null and $chunk->getProvider() !== null);
     $this->timings = Timings::getEntityTimings($this);
     $this->isPlayer = $this instanceof Player;
     $this->temporalVector = new Vector3();
     if ($this->eyeHeight === null) {
         $this->eyeHeight = $this->height / 2 + 0.1;
     }
     $this->id = Entity::$entityCount++;
     $this->justCreated = true;
     $this->namedtag = $nbt;
     $this->chunk = $chunk;
     $this->setLevel($chunk->getProvider()->getLevel());
     $this->server = $chunk->getProvider()->getLevel()->getServer();
     $this->boundingBox = new AxisAlignedBB(0, 0, 0, 0, 0, 0);
     $this->setPositionAndRotation($this->temporalVector->setComponents($this->namedtag["Pos"][0], $this->namedtag["Pos"][1], $this->namedtag["Pos"][2]), $this->namedtag->Rotation[0], $this->namedtag->Rotation[1]);
     $this->setMotion($this->temporalVector->setComponents($this->namedtag["Motion"][0], $this->namedtag["Motion"][1], $this->namedtag["Motion"][2]));
     assert(!is_nan($this->x) and !is_infinite($this->x) and !is_nan($this->y) and !is_infinite($this->y) and !is_nan($this->z) and !is_infinite($this->z));
     if (!isset($this->namedtag->FallDistance)) {
         $this->namedtag->FallDistance = new FloatTag("FallDistance", 0);
     }
     $this->fallDistance = $this->namedtag["FallDistance"];
     if (!isset($this->namedtag->Fire)) {
         $this->namedtag->Fire = new ShortTag("Fire", 0);
     }
     $this->fireTicks = $this->namedtag["Fire"];
     if (!isset($this->namedtag->Air)) {
         $this->namedtag->Air = new ShortTag("Air", 300);
     }
     $this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, $this->namedtag["Air"]);
     if (!isset($this->namedtag->OnGround)) {
         $this->namedtag->OnGround = new ByteTag("OnGround", 0);
     }
     $this->onGround = $this->namedtag["OnGround"] > 0 ? true : false;
     if (!isset($this->namedtag->Invulnerable)) {
         $this->namedtag->Invulnerable = new ByteTag("Invulnerable", 0);
     }
     $this->invulnerable = $this->namedtag["Invulnerable"] > 0 ? true : false;
     $this->chunk->addEntity($this);
     $this->level->addEntity($this);
     $this->initEntity();
     $this->lastUpdate = $this->server->getTick();
     $this->server->getPluginManager()->callEvent(new EntitySpawnEvent($this));
     $this->scheduleUpdate();
 }
开发者ID:organization,项目名称:DummyPlayer,代码行数:81,代码来源:DummyReceiver.php

示例15: handleDataPacket

 /**
  * Handles a Minecraft packet
  * TODO: Separate all of this in handlers
  *
  * WARNING: Do not use this, it's only for internal use.
  * Changes to this function won't be recorded on the version.
  *
  * @param DataPacket $packet
  */
 public function handleDataPacket(DataPacket $packet)
 {
     if ($this->connected === false) {
         return;
     }
     if ($packet::NETWORK_ID === ProtocolInfo::BATCH_PACKET) {
         /** @var BatchPacket $packet */
         $this->server->getNetwork()->processBatch($packet, $this);
         return;
     }
     $timings = Timings::getReceiveDataPacketTimings($packet);
     $timings->startTiming();
     $this->server->getPluginManager()->callEvent($ev = new DataPacketReceiveEvent($this, $packet));
     if ($ev->isCancelled()) {
         $timings->stopTiming();
         return;
     }
     switch ($packet::NETWORK_ID) {
         case ProtocolInfo::LOGIN_PACKET:
             if ($this->loggedIn) {
                 break;
             }
             $this->username = TextFormat::clean($packet->username);
             $this->displayName = $this->username;
             $this->setNameTag($this->username);
             $this->iusername = strtolower($this->username);
             if (count($this->server->getOnlinePlayers()) >= $this->server->getMaxPlayers() and $this->kick("disconnectionScreen.serverFull", false)) {
                 break;
             }
             if ($packet->protocol1 !== ProtocolInfo::CURRENT_PROTOCOL) {
                 if ($packet->protocol1 < ProtocolInfo::CURRENT_PROTOCOL) {
                     $message = "disconnectionScreen.outdatedClient";
                     $pk = new PlayStatusPacket();
                     $pk->status = PlayStatusPacket::LOGIN_FAILED_CLIENT;
                     $this->directDataPacket($pk);
                 } else {
                     $message = "disconnectionScreen.outdatedServer";
                     $pk = new PlayStatusPacket();
                     $pk->status = PlayStatusPacket::LOGIN_FAILED_SERVER;
                     $this->directDataPacket($pk);
                 }
                 $this->close("", $message, false);
                 break;
             }
             $this->randomClientId = $packet->clientId;
             $this->loginData = ["clientId" => $packet->clientId, "loginData" => null];
             $this->uuid = $packet->clientUUID;
             $this->rawUUID = $this->uuid->toBinary();
             $this->clientSecret = $packet->clientSecret;
             $valid = true;
             $len = strlen($packet->username);
             if ($len > 16 or $len < 3) {
                 $valid = false;
             }
             for ($i = 0; $i < $len and $valid; ++$i) {
                 $c = ord($packet->username[$i]);
                 if ($c >= ord("a") and $c <= ord("z") or $c >= ord("A") and $c <= ord("Z") or $c >= ord("0") and $c <= ord("9") or $c === ord("_")) {
                     continue;
                 }
                 $valid = false;
                 break;
             }
             if (!$valid or $this->iusername === "rcon" or $this->iusername === "console") {
                 $this->close("", "disconnectionScreen.invalidName");
                 break;
             }
             if (strlen($packet->skin) !== 64 * 32 * 4 and strlen($packet->skin) !== 64 * 64 * 4) {
                 $this->close("", "disconnectionScreen.invalidSkin");
                 break;
             }
             $this->setSkin($packet->skin, $packet->skinname, $packet->oldclient, $packet->slim, $packet->transparent);
             $this->server->getPluginManager()->callEvent($ev = new PlayerPreLoginEvent($this, "Plugin reason"));
             if ($ev->isCancelled()) {
                 $this->close("", $ev->getKickMessage());
                 break;
             }
             $this->onPlayerPreLogin();
             break;
         case ProtocolInfo::MOVE_PLAYER_PACKET:
             $newPos = new Vector3($packet->x, $packet->y - $this->getEyeHeight(), $packet->z);
             $revert = false;
             if (!$this->isAlive() or $this->spawned !== true) {
                 $revert = true;
                 $this->forceMovement = new Vector3($this->x, $this->y, $this->z);
             }
             if ($this->teleportPosition !== null or $this->forceMovement instanceof Vector3 and (($dist = $newPos->distanceSquared($this->forceMovement)) > 0.1 or $revert)) {
                 $this->sendPosition($this->forceMovement, $packet->yaw, $packet->pitch);
             } else {
                 $packet->yaw %= 360;
                 $packet->pitch %= 360;
                 if ($packet->yaw < 0) {
//.........这里部分代码省略.........
开发者ID:NewDelion,项目名称:PocketMine-0.13.x,代码行数:101,代码来源:Player.php


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