mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-08-30 06:55:11 +00:00
PreSpawnPacketHandler: added dedicated timer for the humongous amount of crap that has to be sent pre-spawn
This commit is contained in:
parent
b2f755720d
commit
61b0ad3e7f
@ -44,6 +44,7 @@ use pocketmine\network\mcpe\protocol\types\PlayerMovementType;
|
|||||||
use pocketmine\network\mcpe\protocol\types\SpawnSettings;
|
use pocketmine\network\mcpe\protocol\types\SpawnSettings;
|
||||||
use pocketmine\player\Player;
|
use pocketmine\player\Player;
|
||||||
use pocketmine\Server;
|
use pocketmine\Server;
|
||||||
|
use pocketmine\timings\Timings;
|
||||||
use pocketmine\VersionInfo;
|
use pocketmine\VersionInfo;
|
||||||
use Ramsey\Uuid\Uuid;
|
use Ramsey\Uuid\Uuid;
|
||||||
use function sprintf;
|
use function sprintf;
|
||||||
@ -60,89 +61,94 @@ class PreSpawnPacketHandler extends PacketHandler{
|
|||||||
){}
|
){}
|
||||||
|
|
||||||
public function setUp() : void{
|
public function setUp() : void{
|
||||||
$location = $this->player->getLocation();
|
Timings::$playerNetworkSendPreSpawnGameData->startTiming();
|
||||||
$world = $location->getWorld();
|
try{
|
||||||
|
$location = $this->player->getLocation();
|
||||||
|
$world = $location->getWorld();
|
||||||
|
|
||||||
$this->session->getLogger()->debug("Preparing StartGamePacket");
|
$this->session->getLogger()->debug("Preparing StartGamePacket");
|
||||||
$levelSettings = new LevelSettings();
|
$levelSettings = new LevelSettings();
|
||||||
$levelSettings->seed = -1;
|
$levelSettings->seed = -1;
|
||||||
$levelSettings->spawnSettings = new SpawnSettings(SpawnSettings::BIOME_TYPE_DEFAULT, "", DimensionIds::OVERWORLD); //TODO: implement this properly
|
$levelSettings->spawnSettings = new SpawnSettings(SpawnSettings::BIOME_TYPE_DEFAULT, "", DimensionIds::OVERWORLD); //TODO: implement this properly
|
||||||
$levelSettings->worldGamemode = TypeConverter::getInstance()->coreGameModeToProtocol($this->server->getGamemode());
|
$levelSettings->worldGamemode = TypeConverter::getInstance()->coreGameModeToProtocol($this->server->getGamemode());
|
||||||
$levelSettings->difficulty = $world->getDifficulty();
|
$levelSettings->difficulty = $world->getDifficulty();
|
||||||
$levelSettings->spawnPosition = BlockPosition::fromVector3($world->getSpawnLocation());
|
$levelSettings->spawnPosition = BlockPosition::fromVector3($world->getSpawnLocation());
|
||||||
$levelSettings->hasAchievementsDisabled = true;
|
$levelSettings->hasAchievementsDisabled = true;
|
||||||
$levelSettings->time = $world->getTime();
|
$levelSettings->time = $world->getTime();
|
||||||
$levelSettings->eduEditionOffer = 0;
|
$levelSettings->eduEditionOffer = 0;
|
||||||
$levelSettings->rainLevel = 0; //TODO: implement these properly
|
$levelSettings->rainLevel = 0; //TODO: implement these properly
|
||||||
$levelSettings->lightningLevel = 0;
|
$levelSettings->lightningLevel = 0;
|
||||||
$levelSettings->commandsEnabled = true;
|
$levelSettings->commandsEnabled = true;
|
||||||
$levelSettings->gameRules = [
|
$levelSettings->gameRules = [
|
||||||
"naturalregeneration" => new BoolGameRule(false, false) //Hack for client side regeneration
|
"naturalregeneration" => new BoolGameRule(false, false) //Hack for client side regeneration
|
||||||
];
|
];
|
||||||
$levelSettings->experiments = new Experiments([], false);
|
$levelSettings->experiments = new Experiments([], false);
|
||||||
|
|
||||||
$this->session->sendDataPacket(StartGamePacket::create(
|
$this->session->sendDataPacket(StartGamePacket::create(
|
||||||
$this->player->getId(),
|
$this->player->getId(),
|
||||||
$this->player->getId(),
|
$this->player->getId(),
|
||||||
TypeConverter::getInstance()->coreGameModeToProtocol($this->player->getGamemode()),
|
TypeConverter::getInstance()->coreGameModeToProtocol($this->player->getGamemode()),
|
||||||
$this->player->getOffsetPosition($location),
|
$this->player->getOffsetPosition($location),
|
||||||
$location->pitch,
|
$location->pitch,
|
||||||
$location->yaw,
|
$location->yaw,
|
||||||
new CacheableNbt(CompoundTag::create()), //TODO: we don't care about this right now
|
new CacheableNbt(CompoundTag::create()), //TODO: we don't care about this right now
|
||||||
$levelSettings,
|
$levelSettings,
|
||||||
"",
|
"",
|
||||||
$this->server->getMotd(),
|
$this->server->getMotd(),
|
||||||
"",
|
"",
|
||||||
false,
|
false,
|
||||||
new PlayerMovementSettings(PlayerMovementType::SERVER_AUTHORITATIVE_V1, 0, false),
|
new PlayerMovementSettings(PlayerMovementType::SERVER_AUTHORITATIVE_V1, 0, false),
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
"",
|
"",
|
||||||
true,
|
true,
|
||||||
sprintf("%s %s", VersionInfo::NAME, VersionInfo::VERSION()->getFullVersion(true)),
|
sprintf("%s %s", VersionInfo::NAME, VersionInfo::VERSION()->getFullVersion(true)),
|
||||||
Uuid::fromString(Uuid::NIL),
|
Uuid::fromString(Uuid::NIL),
|
||||||
false,
|
false,
|
||||||
[],
|
[],
|
||||||
0,
|
0,
|
||||||
GlobalItemTypeDictionary::getInstance()->getDictionary()->getEntries(),
|
GlobalItemTypeDictionary::getInstance()->getDictionary()->getEntries(),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->session->getLogger()->debug("Sending actor identifiers");
|
$this->session->getLogger()->debug("Sending actor identifiers");
|
||||||
$this->session->sendDataPacket(StaticPacketCache::getInstance()->getAvailableActorIdentifiers());
|
$this->session->sendDataPacket(StaticPacketCache::getInstance()->getAvailableActorIdentifiers());
|
||||||
|
|
||||||
$this->session->getLogger()->debug("Sending biome definitions");
|
$this->session->getLogger()->debug("Sending biome definitions");
|
||||||
$this->session->sendDataPacket(StaticPacketCache::getInstance()->getBiomeDefs());
|
$this->session->sendDataPacket(StaticPacketCache::getInstance()->getBiomeDefs());
|
||||||
|
|
||||||
$this->session->getLogger()->debug("Sending attributes");
|
$this->session->getLogger()->debug("Sending attributes");
|
||||||
$this->session->getEntityEventBroadcaster()->syncAttributes([$this->session], $this->player, $this->player->getAttributeMap()->getAll());
|
$this->session->getEntityEventBroadcaster()->syncAttributes([$this->session], $this->player, $this->player->getAttributeMap()->getAll());
|
||||||
|
|
||||||
$this->session->getLogger()->debug("Sending available commands");
|
$this->session->getLogger()->debug("Sending available commands");
|
||||||
$this->session->syncAvailableCommands();
|
$this->session->syncAvailableCommands();
|
||||||
|
|
||||||
$this->session->getLogger()->debug("Sending abilities");
|
$this->session->getLogger()->debug("Sending abilities");
|
||||||
$this->session->syncAbilities($this->player);
|
$this->session->syncAbilities($this->player);
|
||||||
$this->session->syncAdventureSettings();
|
$this->session->syncAdventureSettings();
|
||||||
|
|
||||||
$this->session->getLogger()->debug("Sending effects");
|
$this->session->getLogger()->debug("Sending effects");
|
||||||
foreach($this->player->getEffects()->all() as $effect){
|
foreach($this->player->getEffects()->all() as $effect){
|
||||||
$this->session->getEntityEventBroadcaster()->onEntityEffectAdded([$this->session], $this->player, $effect, false);
|
$this->session->getEntityEventBroadcaster()->onEntityEffectAdded([$this->session], $this->player, $effect, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->session->getLogger()->debug("Sending actor metadata");
|
||||||
|
$this->player->sendData([$this->player]);
|
||||||
|
|
||||||
|
$this->session->getLogger()->debug("Sending inventory");
|
||||||
|
$this->inventoryManager->syncAll();
|
||||||
|
$this->inventoryManager->syncSelectedHotbarSlot();
|
||||||
|
|
||||||
|
$this->session->getLogger()->debug("Sending creative inventory data");
|
||||||
|
$this->inventoryManager->syncCreative();
|
||||||
|
|
||||||
|
$this->session->getLogger()->debug("Sending crafting data");
|
||||||
|
$this->session->sendDataPacket(CraftingDataCache::getInstance()->getCache($this->server->getCraftingManager()));
|
||||||
|
|
||||||
|
$this->session->getLogger()->debug("Sending player list");
|
||||||
|
$this->session->syncPlayerList($this->server->getOnlinePlayers());
|
||||||
|
}finally{
|
||||||
|
Timings::$playerNetworkSendPreSpawnGameData->stopTiming();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->session->getLogger()->debug("Sending actor metadata");
|
|
||||||
$this->player->sendData([$this->player]);
|
|
||||||
|
|
||||||
$this->session->getLogger()->debug("Sending inventory");
|
|
||||||
$this->inventoryManager->syncAll();
|
|
||||||
$this->inventoryManager->syncSelectedHotbarSlot();
|
|
||||||
|
|
||||||
$this->session->getLogger()->debug("Sending creative inventory data");
|
|
||||||
$this->inventoryManager->syncCreative();
|
|
||||||
|
|
||||||
$this->session->getLogger()->debug("Sending crafting data");
|
|
||||||
$this->session->sendDataPacket(CraftingDataCache::getInstance()->getCache($this->server->getCraftingManager()));
|
|
||||||
|
|
||||||
$this->session->getLogger()->debug("Sending player list");
|
|
||||||
$this->session->syncPlayerList($this->server->getOnlinePlayers());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handleRequestChunkRadius(RequestChunkRadiusPacket $packet) : bool{
|
public function handleRequestChunkRadius(RequestChunkRadiusPacket $packet) : bool{
|
||||||
|
@ -68,6 +68,7 @@ abstract class Timings{
|
|||||||
public static $playerNetworkSendEncrypt;
|
public static $playerNetworkSendEncrypt;
|
||||||
|
|
||||||
public static TimingsHandler $playerNetworkSendInventorySync;
|
public static TimingsHandler $playerNetworkSendInventorySync;
|
||||||
|
public static TimingsHandler $playerNetworkSendPreSpawnGameData;
|
||||||
|
|
||||||
/** @var TimingsHandler */
|
/** @var TimingsHandler */
|
||||||
public static $playerNetworkReceive;
|
public static $playerNetworkReceive;
|
||||||
@ -187,6 +188,7 @@ abstract class Timings{
|
|||||||
self::$playerNetworkSendCompressSessionBuffer = new TimingsHandler("Player Network Send - Compression (Session Buffer)", self::$playerNetworkSendCompress, group: self::GROUP_BREAKDOWN);
|
self::$playerNetworkSendCompressSessionBuffer = new TimingsHandler("Player Network Send - Compression (Session Buffer)", self::$playerNetworkSendCompress, group: self::GROUP_BREAKDOWN);
|
||||||
self::$playerNetworkSendEncrypt = new TimingsHandler("Player Network Send - Encryption", self::$playerNetworkSend, group: self::GROUP_BREAKDOWN);
|
self::$playerNetworkSendEncrypt = new TimingsHandler("Player Network Send - Encryption", self::$playerNetworkSend, group: self::GROUP_BREAKDOWN);
|
||||||
self::$playerNetworkSendInventorySync = new TimingsHandler("Player Network Send - Inventory Sync", self::$playerNetworkSend, group: self::GROUP_BREAKDOWN);
|
self::$playerNetworkSendInventorySync = new TimingsHandler("Player Network Send - Inventory Sync", self::$playerNetworkSend, group: self::GROUP_BREAKDOWN);
|
||||||
|
self::$playerNetworkSendPreSpawnGameData = new TimingsHandler("Player Network Send - Pre-Spawn Game Data", self::$playerNetworkSend, group: self::GROUP_BREAKDOWN);
|
||||||
|
|
||||||
self::$playerNetworkReceive = new TimingsHandler("Player Network Receive", self::$connection);
|
self::$playerNetworkReceive = new TimingsHandler("Player Network Receive", self::$connection);
|
||||||
self::$playerNetworkReceiveDecompress = new TimingsHandler("Player Network Receive - Decompression", self::$playerNetworkReceive, group: self::GROUP_BREAKDOWN);
|
self::$playerNetworkReceiveDecompress = new TimingsHandler("Player Network Receive - Decompression", self::$playerNetworkReceive, group: self::GROUP_BREAKDOWN);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user