37 enum class LoadMode :
int {
45 ::ll::TypedStorage<4, 4, int> mChunkSide;
46 ::ll::TypedStorage<8, 8, ::Level*> mLevel;
47 ::ll::TypedStorage<8, 8, ::Dimension*> mDimension;
48 ::ll::TypedStorage<8, 8, ::ChunkSource*> mParent;
49 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ChunkSource>> mOwnedParent;
50 ::ll::TypedStorage<8, 8, ::LevelChunkBuilderData*> mLevelChunkBuilderData;
51 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mShuttingDown;
52 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mOnSaveSubscription;
53 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mOnLevelStorageAppSuspendSubscription;
67 virtual void shutdown();
70 virtual bool isShutdownDone();
73 virtual ::std::shared_ptr<::LevelChunk> getExistingChunk(
::ChunkPos const&);
76 virtual ::std::shared_ptr<::LevelChunk> getRandomChunk(
::Random& random);
79 virtual bool isChunkKnown(
::ChunkPos const& chunkPos);
82 virtual bool isChunkSaved(
::ChunkPos const& chunkPos);
85 virtual ::std::shared_ptr<::LevelChunk>
86 createNewChunk(
::ChunkPos const& cp, ::ChunkSource::LoadMode lm,
bool readOnly);
89 virtual ::std::shared_ptr<::LevelChunk>
90 getOrLoadChunk(
::ChunkPos const& cp, ::ChunkSource::LoadMode lm,
bool readOnly);
99 virtual void loadChunk(
::LevelChunk& lc,
bool forceImmediateReplacementDataLoad);
102 virtual void postProcessMobsAt(
::BlockSource& region,
int chunkWestBlock,
int chunkNorthBlock,
::Random& random);
111 virtual void writeEntityChunkTransfer(
::LevelChunk& levelChunk);
114 virtual void writeEntityChunkTransfersToUnloadedChunk(
116 ::std::vector<::ActorUnloadedChunkTransferEntry>
const& transfers
120 virtual void deserializeActorStorageToLevelChunk(
::LevelChunk& levelChunk);
123 virtual void hintDiscardBatchBegin();
126 virtual void hintDiscardBatchEnd();
129 virtual void acquireDiscarded(::std::unique_ptr<::LevelChunk, ::LevelChunkFinalDeleter> ptr);
132 virtual void compact();
135 virtual void flushPendingDiscardedChunkWrites();
138 virtual void flushThreadBatch();
141 virtual bool isWithinWorldLimit(
::ChunkPos const& cp)
const;
144 virtual ::std::unordered_map<::ChunkPos, ::std::weak_ptr<::LevelChunk>>
const* getChunkMap();
147 virtual ::std::unordered_map<::ChunkPos, ::std::weak_ptr<::LevelChunk>>
const& getStorage()
const;
150 virtual void clearDeletedEntities();
153 virtual bool canCreateViews()
const;
156 virtual ::std::unique_ptr<::BlendingDataProvider> tryGetBlendingDataProvider();
159 virtual ::std::shared_ptr<::LevelChunkMetaDataDictionary> loadLevelChunkMetaDataDictionary();
162 virtual void setLevelChunk(::std::shared_ptr<::LevelChunk>);
165 virtual bool canLaunchTasks()
const;
168 virtual bool chunkPosNeedsBlending(
::ChunkPos const& cp);
174 MCAPI
explicit ChunkSource(::std::unique_ptr<::ChunkSource> parent);
176 MCAPI
bool _checkAndDispatchTaskForLevelChunk(
177 ::std::pair<::ChunkPos, ::ChunkState>
const& chunkPosAndExpectedState,
183 MCAPI
void _checkForUnblockingChunks(
::LevelChunk const& lc);
185 MCAPI
void _checkLevelChunkForNextStage(
188 ::ChunkState stateToCheck
191 MCAPI
void _checkLevelChunkForPostProcessing(
196 MCAPI
bool _chunkAtStage(::std::weak_ptr<::LevelChunk> lcwp, ::ChunkState stateToCheck);
198 MCAPI
void _createOrReplaceGridAreaMap(::std::shared_ptr<::LevelChunk> lc,
bool createNeighbourGridsIfMissing);
200 MCAPI
void _freeChunkGenerationGridMap(
::ChunkPos const& cp,
bool isLevelChunkDeletion);
202 MCAPI
void _launchGenerationTask(::std::shared_ptr<::LevelChunk>
const& lc,
bool areInTask);
204 MCAPI
void _launchLightingTask(
205 ::std::shared_ptr<::LevelChunk>
const& lc,
206 ::std::shared_ptr<::ChunkViewSource>
const& chunks,
210 MCAPI
void _launchPostProcessingTask(
211 ::std::shared_ptr<::LevelChunk>
const& lc,
212 ::std::shared_ptr<::ChunkViewSource>
const& chunks,
216 MCAPI
void _launchReplacementDataTask(
217 ::std::shared_ptr<::LevelChunk>
const& lc,
218 ::std::shared_ptr<::ChunkViewSource>
const& chunks,
222 MCAPI
void _lightingTask(::std::shared_ptr<::LevelChunk>
const& lc,
::ChunkViewSource& chunks);
230 MCAPI
void _spawnChunkGenerationTasks(
int numTasks,
bool calledFromTask);
232 MCAPI
void checkAndLaunchChunkGenerationTasks(
bool calledFromTask);
234 MCAPI ::GridArea<::std::shared_ptr<::LevelChunk>> createEmptyView(
235 ::ChunkSource::LoadMode lm,
238 ::ChunkSourceViewGenerateMode chunkViewGenerateMode,
239 float const* serverBuildRatio
242 MCAPI ::std::shared_ptr<::LevelChunk> getAvailableChunk(
::ChunkPos const& cp);
247 MCAPI
bool shouldServerGeneratePos(
::ChunkPos const& chunkPos,
float serverBuildRatio,
int viewRadius);
253 MCAPI
static bool& gPerfIsClientSide();
259 MCAPI
void* $ctor(::std::unique_ptr<::ChunkSource> parent);
271 MCAPI
void $shutdown();
273 MCAPI
bool $isShutdownDone();
275 MCFOLD ::std::shared_ptr<::LevelChunk> $getExistingChunk(
::ChunkPos const&);
277 MCFOLD ::std::shared_ptr<::LevelChunk> $getRandomChunk(
::Random& random);
279 MCAPI
bool $isChunkKnown(
::ChunkPos const& chunkPos);
281 MCAPI
bool $isChunkSaved(
::ChunkPos const& chunkPos);
283 MCAPI ::std::shared_ptr<::LevelChunk>
284 $createNewChunk(
::ChunkPos const& cp, ::ChunkSource::LoadMode lm,
bool readOnly);
286 MCAPI ::std::shared_ptr<::LevelChunk>
287 $getOrLoadChunk(
::ChunkPos const& cp, ::ChunkSource::LoadMode lm,
bool readOnly);
293 MCAPI
void $loadChunk(
::LevelChunk& lc,
bool forceImmediateReplacementDataLoad);
295 MCAPI
void $postProcessMobsAt(
::BlockSource& region,
int chunkWestBlock,
int chunkNorthBlock,
::Random& random);
301 MCAPI
void $writeEntityChunkTransfer(
::LevelChunk& levelChunk);
303 MCAPI
void $writeEntityChunkTransfersToUnloadedChunk(
305 ::std::vector<::ActorUnloadedChunkTransferEntry>
const& transfers
308 MCAPI
void $deserializeActorStorageToLevelChunk(
::LevelChunk& levelChunk);
310 MCAPI
void $hintDiscardBatchBegin();
312 MCAPI
void $hintDiscardBatchEnd();
314 MCAPI
void $acquireDiscarded(::std::unique_ptr<::LevelChunk, ::LevelChunkFinalDeleter> ptr);
316 MCAPI
void $compact();
318 MCAPI
void $flushPendingDiscardedChunkWrites();
320 MCAPI
void $flushThreadBatch();
322 MCFOLD
bool $isWithinWorldLimit(
::ChunkPos const& cp)
const;
324 MCFOLD ::std::unordered_map<::ChunkPos, ::std::weak_ptr<::LevelChunk>>
const* $getChunkMap();
326 MCAPI ::std::unordered_map<::ChunkPos, ::std::weak_ptr<::LevelChunk>>
const& $getStorage()
const;
328 MCFOLD
void $clearDeletedEntities();
330 MCFOLD
bool $canCreateViews()
const;
332 MCAPI ::std::unique_ptr<::BlendingDataProvider> $tryGetBlendingDataProvider();
334 MCAPI ::std::shared_ptr<::LevelChunkMetaDataDictionary> $loadLevelChunkMetaDataDictionary();
336 MCFOLD
void $setLevelChunk(::std::shared_ptr<::LevelChunk>);
338 MCAPI
bool $canLaunchTasks()
const;
340 MCAPI
bool $chunkPosNeedsBlending(
::ChunkPos const& cp);