55 public function __construct(
62 public function setUp() :
void{
63 Timings::$playerNetworkSendPreSpawnGameData->startTiming();
65 $location = $this->player->getLocation();
66 $world = $location->getWorld();
68 $typeConverter = $this->session->getTypeConverter();
70 $this->session->getLogger()->debug(
"Preparing StartGamePacket");
72 $levelSettings->seed = -1;
73 $levelSettings->spawnSettings =
new SpawnSettings(SpawnSettings::BIOME_TYPE_DEFAULT,
"", DimensionIds::OVERWORLD);
74 $levelSettings->worldGamemode = $typeConverter->coreGameModeToProtocol($this->
server->getGamemode());
75 $levelSettings->difficulty = $world->getDifficulty();
76 $levelSettings->spawnPosition = BlockPosition::fromVector3($world->getSpawnLocation());
77 $levelSettings->hasAchievementsDisabled =
true;
78 $levelSettings->time = $world->getTime();
79 $levelSettings->eduEditionOffer = 0;
80 $levelSettings->rainLevel = 0;
81 $levelSettings->lightningLevel = 0;
82 $levelSettings->commandsEnabled =
true;
83 $levelSettings->gameRules = [
86 $levelSettings->experiments =
new Experiments([],
false);
89 $this->player->getId(),
90 $this->player->getId(),
91 $typeConverter->coreGameModeToProtocol($this->player->getGamemode()),
92 $this->player->getOffsetPosition($location),
106 sprintf(
"%s %s", VersionInfo::NAME, VersionInfo::VERSION()->getFullVersion(
true)),
107 Uuid::fromString(Uuid::NIL),
113 $typeConverter->getItemTypeDictionary()->getEntries(),
116 $this->session->getLogger()->debug(
"Sending actor identifiers");
117 $this->session->sendDataPacket(StaticPacketCache::getInstance()->getAvailableActorIdentifiers());
119 $this->session->getLogger()->debug(
"Sending biome definitions");
120 $this->session->sendDataPacket(StaticPacketCache::getInstance()->getBiomeDefs());
122 $this->session->getLogger()->debug(
"Sending attributes");
123 $this->session->getEntityEventBroadcaster()->syncAttributes([$this->session], $this->player, $this->player->getAttributeMap()->getAll());
125 $this->session->getLogger()->debug(
"Sending available commands");
126 $this->session->syncAvailableCommands();
128 $this->session->getLogger()->debug(
"Sending abilities");
129 $this->session->syncAbilities($this->player);
130 $this->session->syncAdventureSettings();
132 $this->session->getLogger()->debug(
"Sending effects");
133 foreach($this->player->getEffects()->all() as $effect){
134 $this->session->getEntityEventBroadcaster()->onEntityEffectAdded([$this->session], $this->player, $effect,
false);
137 $this->session->getLogger()->debug(
"Sending actor metadata");
138 $this->player->sendData([$this->player]);
140 $this->session->getLogger()->debug(
"Sending inventory");
141 $this->inventoryManager->syncAll();
142 $this->inventoryManager->syncSelectedHotbarSlot();
144 $this->session->getLogger()->debug(
"Sending creative inventory data");
145 $this->inventoryManager->syncCreative();
147 $this->session->getLogger()->debug(
"Sending crafting data");
148 $this->session->sendDataPacket(CraftingDataCache::getInstance()->getCache($this->
server->getCraftingManager()));
150 $this->session->getLogger()->debug(
"Sending player list");
151 $this->session->syncPlayerList($this->
server->getOnlinePlayers());
153 Timings::$playerNetworkSendPreSpawnGameData->stopTiming();
158 $this->player->setViewDistance($packet->radius);
static create(int $actorUniqueId, int $actorRuntimeId, int $playerGamemode, Vector3 $playerPosition, float $pitch, float $yaw, CacheableNbt $playerActorProperties, LevelSettings $levelSettings, string $levelId, string $worldName, string $premiumWorldTemplateId, bool $isTrial, PlayerMovementSettings $playerMovementSettings, int $currentTick, int $enchantmentSeed, string $multiplayerCorrelationId, bool $enableNewInventorySystem, string $serverSoftwareVersion, UuidInterface $worldTemplateId, bool $enableClientSideChunkGeneration, bool $blockNetworkIdsAreHashes, NetworkPermissions $networkPermissions, array $blockPalette, int $blockPaletteChecksum, array $itemTable,)