56 public function __construct(
63 public function setUp() :
void{
64 Timings::$playerNetworkSendPreSpawnGameData->startTiming();
66 $location = $this->player->getLocation();
67 $world = $location->getWorld();
69 $typeConverter = $this->session->getTypeConverter();
71 $this->session->getLogger()->debug(
"Preparing StartGamePacket");
73 $levelSettings->seed = -1;
74 $levelSettings->spawnSettings =
new SpawnSettings(SpawnSettings::BIOME_TYPE_DEFAULT,
"", DimensionIds::OVERWORLD);
75 $levelSettings->worldGamemode = $typeConverter->coreGameModeToProtocol($this->
server->getGamemode());
76 $levelSettings->difficulty = $world->getDifficulty();
77 $levelSettings->spawnPosition = BlockPosition::fromVector3($world->getSpawnLocation());
78 $levelSettings->hasAchievementsDisabled =
true;
79 $levelSettings->time = $world->getTime();
80 $levelSettings->eduEditionOffer = 0;
81 $levelSettings->rainLevel = 0;
82 $levelSettings->lightningLevel = 0;
83 $levelSettings->commandsEnabled =
true;
84 $levelSettings->gameRules = [
87 $levelSettings->experiments =
new Experiments([],
false);
90 $this->player->getId(),
91 $this->player->getId(),
92 $typeConverter->coreGameModeToProtocol($this->player->getGamemode()),
93 $this->player->getOffsetPosition($location),
107 sprintf(
"%s %s", VersionInfo::NAME, VersionInfo::VERSION()->getFullVersion(
true)),
108 Uuid::fromString(Uuid::NIL),
116 $this->session->getLogger()->debug(
"Sending items");
119 $this->session->getLogger()->debug(
"Sending actor identifiers");
120 $this->session->sendDataPacket(StaticPacketCache::getInstance()->getAvailableActorIdentifiers());
122 $this->session->getLogger()->debug(
"Sending biome definitions");
123 $this->session->sendDataPacket(StaticPacketCache::getInstance()->getBiomeDefs());
125 $this->session->getLogger()->debug(
"Sending attributes");
126 $this->session->getEntityEventBroadcaster()->syncAttributes([$this->session], $this->player, $this->player->getAttributeMap()->getAll());
128 $this->session->getLogger()->debug(
"Sending available commands");
129 $this->session->syncAvailableCommands();
131 $this->session->getLogger()->debug(
"Sending abilities");
132 $this->session->syncAbilities($this->player);
133 $this->session->syncAdventureSettings();
135 $this->session->getLogger()->debug(
"Sending effects");
136 foreach($this->player->getEffects()->all() as $effect){
137 $this->session->getEntityEventBroadcaster()->onEntityEffectAdded([$this->session], $this->player, $effect,
false);
140 $this->session->getLogger()->debug(
"Sending actor metadata");
141 $this->player->sendData([$this->player]);
143 $this->session->getLogger()->debug(
"Sending inventory");
144 $this->inventoryManager->syncAll();
145 $this->inventoryManager->syncSelectedHotbarSlot();
147 $this->session->getLogger()->debug(
"Sending creative inventory data");
148 $this->inventoryManager->syncCreative();
150 $this->session->getLogger()->debug(
"Sending crafting data");
151 $this->session->sendDataPacket(CraftingDataCache::getInstance()->getCache($this->
server->getCraftingManager()));
153 $this->session->getLogger()->debug(
"Sending player list");
154 $this->session->syncPlayerList($this->
server->getOnlinePlayers());
156 Timings::$playerNetworkSendPreSpawnGameData->stopTiming();
161 $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,)