41 enum class LoadMode :
int {
49 ::ll::TypedStorage<4, 4, int> mChunkSide;
50 ::ll::TypedStorage<8, 8, ::Level*> mLevel;
51 ::ll::TypedStorage<8, 8, ::Dimension*> mDimension;
52 ::ll::TypedStorage<8, 8, ::ChunkSource*> mParent;
53 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ChunkSource>> mOwnedParent;
54 ::ll::TypedStorage<8, 8, ::LevelChunkBuilderData*> mLevelChunkBuilderData;
55 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mShuttingDown;
56 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mOnSaveSubscription;
57 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mOnLevelStorageAppSuspendSubscription;
67 virtual ~ChunkSource() ;
69 virtual void shutdown();
71 virtual bool isShutdownDone();
73 virtual ::std::shared_ptr<::LevelChunk> getExistingChunk(
::ChunkPos const& pos);
75 virtual ::std::shared_ptr<::LevelChunk> getRandomChunk(
::Random& random);
77 virtual bool isChunkKnown(
::ChunkPos const& chunkPos);
79 virtual bool isChunkSaved(
::ChunkPos const& chunkPos);
81 virtual ::std::shared_ptr<::LevelChunk>
82 createNewChunk(
::ChunkPos const& cp, ::ChunkSource::LoadMode lm,
bool readOnly);
84 virtual ::std::shared_ptr<::LevelChunk>
85 getOrLoadChunk(
::ChunkPos const& cp, ::ChunkSource::LoadMode lm,
bool readOnly);
93 virtual bool verifyChunkNeedsNeighborAwareUpgrade(
::LevelChunk& lc);
97 virtual void loadChunk(
::LevelChunk& lc,
bool forceImmediateReplacementDataLoad);
99 virtual void postProcessMobsAt(
::BlockSource& region,
int chunkWestBlock,
int chunkNorthBlock,
::Random& random);
103 virtual void deleteAllChunkData(
104 ::std::unordered_set<::ChunkPos> chunksToDelete,
105 ::std::function<
void()> completionCallback,
106 ::std::shared_ptr<::ChunkDeletionMetadata> metadata
109 virtual void deleteStoredChunkData(
110 ::std::unordered_set<::ChunkPos> chunksToDelete,
111 ::std::function<
void()> completionCallback,
112 ::std::shared_ptr<::ChunkDeletionMetadata> metadata
117 virtual void writeEntityChunkTransfer(
::LevelChunk& levelChunk);
119 virtual void writeEntityChunkTransfersToUnloadedChunk(
121 ::std::vector<::ActorUnloadedChunkTransferEntry>
const& transfers
124 virtual void deserializeActorStorageToLevelChunk(
::LevelChunk& levelChunk);
126 virtual void hintDiscardBatchBegin();
128 virtual void hintDiscardBatchEnd();
130 virtual void acquireDiscarded(::std::unique_ptr<::LevelChunk, ::LevelChunkFinalDeleter> ptr);
132 virtual void compact();
134 virtual void flushPendingDiscardedChunkWrites();
136 virtual void flushThreadBatch();
138 virtual bool isWithinWorldLimit(
::ChunkPos const& cp)
const;
140 virtual ::std::unordered_map<::ChunkPos, ::std::weak_ptr<::LevelChunk>>
const* getChunkMap();
142 virtual ::std::unordered_map<::ChunkPos, ::std::weak_ptr<::LevelChunk>>
const& getStorage()
const;
144 virtual void clearDeletedEntities();
146 virtual bool canCreateViews()
const;
148 virtual ::std::unique_ptr<::BlendingDataProvider> tryGetBlendingDataProvider();
150 virtual ::std::shared_ptr<::LevelChunkMetaDataDictionary> loadLevelChunkMetaDataDictionary();
152 virtual void setLevelChunk(::std::shared_ptr<::LevelChunk> lc);
154 virtual bool canLaunchTasks()
const;
156 virtual bool chunkPosNeedsBlending(
::ChunkPos const& cp);
158 virtual void _clearBlendingCache();
164 MCAPI
explicit ChunkSource(::std::unique_ptr<::ChunkSource> parent);
166 MCAPI
bool _checkAndDispatchTaskForLevelChunk(
167 ::std::pair<::ChunkPos, ::ChunkState>
const& chunkPosAndExpectedState,
173 MCAPI
void _checkForUnblockingChunks(
::LevelChunk const& lc);
175 MCAPI
void _checkLevelChunkForNextStage(
178 ::ChunkState stateToCheck
181 MCAPI
void _checkSpecificLevelChunkForUnblocking(
186 MCAPI
bool _chunkAtStage(::std::weak_ptr<::LevelChunk> lcwp, ::ChunkState stateToCheck);
188 MCAPI
void _createOrReplaceGridAreaMap(::std::shared_ptr<::LevelChunk> lc,
bool createNeighbourGridsIfMissing);
192 MCAPI
void _dispatchTaskForLevelChunk(
193 ::std::shared_ptr<::LevelChunk>
const& lc,
194 ::std::shared_ptr<::ChunkViewSource>
const& chunks,
198 MCAPI
void _freeChunkGenerationGridMap(
::ChunkPos const& cp,
bool isLevelChunkDeletion);
200 MCAPI
void _handleTaskFailure(
::LevelChunk& levelChunk, ::ChunkState currentState, ::ChunkState previousState);
202 MCAPI
void _launchChunkTask(
203 ::std::string_view taskName,
209 MCAPI
void _launchDecorationPostProcessingTask(
210 ::std::shared_ptr<::LevelChunk>
const& lc,
211 ::std::shared_ptr<::ChunkViewSource>
const& chunks,
215 MCAPI
void _launchLightingTask(
216 ::std::shared_ptr<::LevelChunk>
const& lc,
217 ::std::shared_ptr<::ChunkViewSource>
const& chunks,
221 MCAPI
void _launchNeighborAwareUpgradeTask(
222 ::std::shared_ptr<::LevelChunk>
const& lc,
223 ::std::shared_ptr<::ChunkViewSource>
const& chunks,
227 MCAPI
void _launchReplacementDataTask(
228 ::std::shared_ptr<::LevelChunk>
const& lc,
229 ::std::shared_ptr<::ChunkViewSource>
const& chunks,
233 MCAPI
void _launchStructurePostProcessingTask(
234 ::std::shared_ptr<::LevelChunk>
const& lc,
235 ::std::shared_ptr<::ChunkViewSource>
const& chunks,
239 MCAPI
void _lightingTask(::std::shared_ptr<::LevelChunk>
const& lc,
::ChunkViewSource& chunks);
247 MCAPI
void _spawnChunkGenerationTasks(
int numTasks,
bool calledFromTask);
252 MCAPI
void addEmptyChunkPosForProcessingNeighbours(::std::shared_ptr<::LevelChunk> lc);
255 MCAPI
void checkAndLaunchChunkGenerationTasks(
bool calledFromTask);
257 MCAPI ::GridArea<::std::shared_ptr<::LevelChunk>> createEmptyView(
258 ::ChunkSource::LoadMode lm,
261 ::ChunkSourceViewGenerateMode chunkViewGenerateMode,
262 float const* serverBuildRatio
265 MCAPI ::std::shared_ptr<::LevelChunk> getAvailableChunk(
::ChunkPos const& cp);
268 MCAPI ::std::shared_ptr<::LevelChunk> getAvailableChunkAt(
::BlockPos const& pos);
274 MCAPI
bool shouldServerGeneratePos(
::ChunkPos const& chunkPos,
float serverBuildRatio,
int viewRadius);
280 MCAPI
static bool& gPerfIsClientSide();
286 MCAPI
void* $ctor(::std::unique_ptr<::ChunkSource> parent);
298 MCAPI
void $shutdown();
300 MCAPI
bool $isShutdownDone();
302 MCFOLD ::std::shared_ptr<::LevelChunk> $getExistingChunk(
::ChunkPos const& pos);
304 MCFOLD ::std::shared_ptr<::LevelChunk> $getRandomChunk(
::Random& random);
306 MCAPI
bool $isChunkKnown(
::ChunkPos const& chunkPos);
308 MCAPI
bool $isChunkSaved(
::ChunkPos const& chunkPos);
310 MCAPI ::std::shared_ptr<::LevelChunk>
311 $createNewChunk(
::ChunkPos const& cp, ::ChunkSource::LoadMode lm,
bool readOnly);
313 MCAPI ::std::shared_ptr<::LevelChunk>
314 $getOrLoadChunk(
::ChunkPos const& cp, ::ChunkSource::LoadMode lm,
bool readOnly);
322 MCFOLD
bool $verifyChunkNeedsNeighborAwareUpgrade(
::LevelChunk& lc);
326 MCAPI
void $loadChunk(
::LevelChunk& lc,
bool forceImmediateReplacementDataLoad);
328 MCAPI
void $postProcessMobsAt(
::BlockSource& region,
int chunkWestBlock,
int chunkNorthBlock,
::Random& random);
332 MCAPI
void $deleteAllChunkData(
333 ::std::unordered_set<::ChunkPos> chunksToDelete,
334 ::std::function<
void()> completionCallback,
335 ::std::shared_ptr<::ChunkDeletionMetadata> metadata
338 MCAPI
void $deleteStoredChunkData(
339 ::std::unordered_set<::ChunkPos> chunksToDelete,
340 ::std::function<
void()> completionCallback,
341 ::std::shared_ptr<::ChunkDeletionMetadata> metadata
346 MCAPI
void $writeEntityChunkTransfer(
::LevelChunk& levelChunk);
348 MCAPI
void $writeEntityChunkTransfersToUnloadedChunk(
350 ::std::vector<::ActorUnloadedChunkTransferEntry>
const& transfers
353 MCAPI
void $deserializeActorStorageToLevelChunk(
::LevelChunk& levelChunk);
355 MCAPI
void $hintDiscardBatchBegin();
357 MCAPI
void $hintDiscardBatchEnd();
359 MCAPI
void $acquireDiscarded(::std::unique_ptr<::LevelChunk, ::LevelChunkFinalDeleter> ptr);
361 MCAPI
void $compact();
363 MCAPI
void $flushPendingDiscardedChunkWrites();
365 MCAPI
void $flushThreadBatch();
367 MCFOLD
bool $isWithinWorldLimit(
::ChunkPos const& cp)
const;
369 MCFOLD ::std::unordered_map<::ChunkPos, ::std::weak_ptr<::LevelChunk>>
const* $getChunkMap();
371 MCAPI ::std::unordered_map<::ChunkPos, ::std::weak_ptr<::LevelChunk>>
const& $getStorage()
const;
373 MCFOLD
void $clearDeletedEntities();
375 MCFOLD
bool $canCreateViews()
const;
377 MCAPI ::std::unique_ptr<::BlendingDataProvider> $tryGetBlendingDataProvider();
379 MCAPI ::std::shared_ptr<::LevelChunkMetaDataDictionary> $loadLevelChunkMetaDataDictionary();
381 MCFOLD
void $setLevelChunk(::std::shared_ptr<::LevelChunk> lc);
383 MCAPI
bool $canLaunchTasks()
const;
385 MCAPI
bool $chunkPosNeedsBlending(
::ChunkPos const& cp);
387 MCAPI
void $_clearBlendingCache();