39 enum class LoadMode :
int {
47 ::ll::TypedStorage<4, 4, int> mChunkSide;
48 ::ll::TypedStorage<8, 8, ::Level*> mLevel;
49 ::ll::TypedStorage<8, 8, ::Dimension*> mDimension;
50 ::ll::TypedStorage<8, 8, ::ChunkSource*> mParent;
51 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ChunkSource>> mOwnedParent;
52 ::ll::TypedStorage<8, 8, ::LevelChunkBuilderData*> mLevelChunkBuilderData;
53 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mShuttingDown;
54 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mOnSaveSubscription;
55 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mOnLevelStorageAppSuspendSubscription;
69 virtual void shutdown();
72 virtual bool isShutdownDone();
75 virtual ::std::shared_ptr<::LevelChunk> getExistingChunk(
::ChunkPos const&);
78 virtual ::std::shared_ptr<::LevelChunk> getRandomChunk(
::Random& random);
81 virtual bool isChunkKnown(
::ChunkPos const& chunkPos);
84 virtual bool isChunkSaved(
::ChunkPos const& chunkPos);
87 virtual ::std::shared_ptr<::LevelChunk>
88 createNewChunk(
::ChunkPos const& cp, ::ChunkSource::LoadMode lm,
bool readOnly);
91 virtual ::std::shared_ptr<::LevelChunk>
92 getOrLoadChunk(
::ChunkPos const& cp, ::ChunkSource::LoadMode lm,
bool readOnly);
104 virtual bool verifyChunkNeedsNeighborAwareUpgrade(
::LevelChunk&);
110 virtual void loadChunk(
::LevelChunk& lc,
bool forceImmediateReplacementDataLoad);
113 virtual void postProcessMobsAt(
::BlockSource& region,
int chunkWestBlock,
int chunkNorthBlock,
::Random& random);
122 virtual void writeEntityChunkTransfer(
::LevelChunk& levelChunk);
125 virtual void writeEntityChunkTransfersToUnloadedChunk(
127 ::std::vector<::ActorUnloadedChunkTransferEntry>
const& transfers
131 virtual void deserializeActorStorageToLevelChunk(
::LevelChunk& levelChunk);
134 virtual void hintDiscardBatchBegin();
137 virtual void hintDiscardBatchEnd();
140 virtual void acquireDiscarded(::std::unique_ptr<::LevelChunk, ::LevelChunkFinalDeleter> ptr);
143 virtual void compact();
146 virtual void flushPendingDiscardedChunkWrites();
149 virtual void flushThreadBatch();
152 virtual bool isWithinWorldLimit(
::ChunkPos const& cp)
const;
155 virtual ::std::unordered_map<::ChunkPos, ::std::weak_ptr<::LevelChunk>>
const* getChunkMap();
158 virtual ::std::unordered_map<::ChunkPos, ::std::weak_ptr<::LevelChunk>>
const& getStorage()
const;
161 virtual void clearDeletedEntities();
164 virtual bool canCreateViews()
const;
167 virtual ::std::unique_ptr<::BlendingDataProvider> tryGetBlendingDataProvider();
170 virtual ::std::shared_ptr<::LevelChunkMetaDataDictionary> loadLevelChunkMetaDataDictionary();
173 virtual void setLevelChunk(::std::shared_ptr<::LevelChunk>);
176 virtual bool canLaunchTasks()
const;
179 virtual bool chunkPosNeedsBlending(
::ChunkPos const& cp);
185 MCAPI
explicit ChunkSource(::std::unique_ptr<::ChunkSource> parent);
187 MCAPI
bool _checkAndDispatchTaskForLevelChunk(
188 ::std::pair<::ChunkPos, ::ChunkState>
const& chunkPosAndExpectedState,
194 MCAPI
void _checkForUnblockingChunks(
::LevelChunk const& lc);
196 MCAPI
void _checkLevelChunkForNextStage(
199 ::ChunkState stateToCheck
202 MCAPI
void _checkSpecificLevelChunkForUnblocking(
207 MCAPI
bool _chunkAtStage(::std::weak_ptr<::LevelChunk> lcwp, ::ChunkState stateToCheck);
209 MCAPI
void _createOrReplaceGridAreaMap(::std::shared_ptr<::LevelChunk> lc,
bool createNeighbourGridsIfMissing);
213 MCAPI
void _dispatchTaskForLevelChunk(
214 ::std::shared_ptr<::LevelChunk>
const& lc,
215 ::std::shared_ptr<::ChunkViewSource>
const& chunks,
219 MCAPI
void _freeChunkGenerationGridMap(
::ChunkPos const& cp,
bool isLevelChunkDeletion);
221 MCAPI
void _handleTaskFailure(
::LevelChunk& levelChunk, ::ChunkState currentState, ::ChunkState previousState);
223 MCAPI
void _launchChunkTask(
224 ::std::string_view taskName,
230 MCAPI
void _launchDecorationPostProcessingTask(
231 ::std::shared_ptr<::LevelChunk>
const& lc,
232 ::std::shared_ptr<::ChunkViewSource>
const& chunks,
236 MCAPI
void _launchLightingTask(
237 ::std::shared_ptr<::LevelChunk>
const& lc,
238 ::std::shared_ptr<::ChunkViewSource>
const& chunks,
242 MCAPI
void _launchNeighborAwareUpgradeTask(
243 ::std::shared_ptr<::LevelChunk>
const& lc,
244 ::std::shared_ptr<::ChunkViewSource>
const& chunks,
248 MCAPI
void _launchReplacementDataTask(
249 ::std::shared_ptr<::LevelChunk>
const& lc,
250 ::std::shared_ptr<::ChunkViewSource>
const& chunks,
254 MCAPI
void _launchStructurePostProcessingTask(
255 ::std::shared_ptr<::LevelChunk>
const& lc,
256 ::std::shared_ptr<::ChunkViewSource>
const& chunks,
260 MCAPI
void _lightingTask(::std::shared_ptr<::LevelChunk>
const& lc,
::ChunkViewSource& chunks);
268 MCAPI
void _spawnChunkGenerationTasks(
int numTasks,
bool calledFromTask);
270 MCAPI
void checkAndLaunchChunkGenerationTasks(
bool calledFromTask);
272 MCAPI ::GridArea<::std::shared_ptr<::LevelChunk>> createEmptyView(
273 ::ChunkSource::LoadMode lm,
276 ::ChunkSourceViewGenerateMode chunkViewGenerateMode,
277 float const* serverBuildRatio
280 MCAPI ::std::shared_ptr<::LevelChunk> getAvailableChunk(
::ChunkPos const& cp);
285 MCAPI
bool shouldServerGeneratePos(
::ChunkPos const& chunkPos,
float serverBuildRatio,
int viewRadius);
291 MCAPI
static bool& gPerfIsClientSide();
297 MCAPI
void* $ctor(::std::unique_ptr<::ChunkSource> parent);
309 MCAPI
void $shutdown();
311 MCAPI
bool $isShutdownDone();
313 MCFOLD ::std::shared_ptr<::LevelChunk> $getExistingChunk(
::ChunkPos const&);
315 MCFOLD ::std::shared_ptr<::LevelChunk> $getRandomChunk(
::Random& random);
317 MCAPI
bool $isChunkKnown(
::ChunkPos const& chunkPos);
319 MCAPI
bool $isChunkSaved(
::ChunkPos const& chunkPos);
321 MCAPI ::std::shared_ptr<::LevelChunk>
322 $createNewChunk(
::ChunkPos const& cp, ::ChunkSource::LoadMode lm,
bool readOnly);
324 MCAPI ::std::shared_ptr<::LevelChunk>
325 $getOrLoadChunk(
::ChunkPos const& cp, ::ChunkSource::LoadMode lm,
bool readOnly);
333 MCFOLD
bool $verifyChunkNeedsNeighborAwareUpgrade(
::LevelChunk&);
337 MCAPI
void $loadChunk(
::LevelChunk& lc,
bool forceImmediateReplacementDataLoad);
339 MCAPI
void $postProcessMobsAt(
::BlockSource& region,
int chunkWestBlock,
int chunkNorthBlock,
::Random& random);
345 MCAPI
void $writeEntityChunkTransfer(
::LevelChunk& levelChunk);
347 MCAPI
void $writeEntityChunkTransfersToUnloadedChunk(
349 ::std::vector<::ActorUnloadedChunkTransferEntry>
const& transfers
352 MCAPI
void $deserializeActorStorageToLevelChunk(
::LevelChunk& levelChunk);
354 MCAPI
void $hintDiscardBatchBegin();
356 MCAPI
void $hintDiscardBatchEnd();
358 MCAPI
void $acquireDiscarded(::std::unique_ptr<::LevelChunk, ::LevelChunkFinalDeleter> ptr);
360 MCAPI
void $compact();
362 MCAPI
void $flushPendingDiscardedChunkWrites();
364 MCAPI
void $flushThreadBatch();
366 MCFOLD
bool $isWithinWorldLimit(
::ChunkPos const& cp)
const;
368 MCFOLD ::std::unordered_map<::ChunkPos, ::std::weak_ptr<::LevelChunk>>
const* $getChunkMap();
370 MCAPI ::std::unordered_map<::ChunkPos, ::std::weak_ptr<::LevelChunk>>
const& $getStorage()
const;
372 MCFOLD
void $clearDeletedEntities();
374 MCFOLD
bool $canCreateViews()
const;
376 MCAPI ::std::unique_ptr<::BlendingDataProvider> $tryGetBlendingDataProvider();
378 MCAPI ::std::shared_ptr<::LevelChunkMetaDataDictionary> $loadLevelChunkMetaDataDictionary();
380 MCFOLD
void $setLevelChunk(::std::shared_ptr<::LevelChunk>);
382 MCAPI
bool $canLaunchTasks()
const;
384 MCAPI
bool $chunkPosNeedsBlending(
::ChunkPos const& cp);