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();
160 virtual ::std::shared_ptr<::br::worldgen::StructureInstance>
167 MCAPI
explicit ChunkSource(::std::unique_ptr<::ChunkSource> parent);
170 MCAPI
void _checkForUnblockingChunks(
::LevelChunk const& lc);
174 MCAPI
void _checkForUnblockingChunks(
::LevelChunk const& lc);
177 MCAPI
void _checkLevelChunkForNextStage(
180 ::ChunkState stateToCheck
184 MCAPI
void _createOrReplaceGridAreaMap(::std::shared_ptr<::LevelChunk> lc,
bool createNeighbourGridsIfMissing);
187 MCAPI
void _freeChunkGenerationGridMap(
::ChunkPos const& cp,
bool isLevelChunkDeletion);
189 MCAPI
void _launchChunkTask(
190 ::std::string_view taskName,
196 MCAPI
void _launchLightingTask(
197 ::std::shared_ptr<::LevelChunk>
const& lc,
198 ::std::shared_ptr<::ChunkViewSource>
const& chunks,
204 MCAPI
void _spawnChunkGenerationTasks(
int numTasks,
bool calledFromTask);
207 MCAPI
void addEmptyChunkPosForProcessingNeighbours(::std::shared_ptr<::LevelChunk> lc);
210 MCAPI
void checkAndLaunchChunkGenerationTasks(
bool calledFromTask);
212 MCAPI ::GridArea<::std::shared_ptr<::LevelChunk>> createEmptyView(
213 ::ChunkSource::LoadMode lm,
215 ::std::function<
void(::gsl::span<::std::shared_ptr<::LevelChunk>>)> add,
216 ::ChunkSourceViewGenerateMode chunkViewGenerateMode,
217 float const* serverBuildRatio
227 MCAPI
static bool& gPerfIsClientSide();
233 MCAPI
void* $ctor(::std::unique_ptr<::ChunkSource> parent);
245 MCAPI
void $shutdown();
247 MCAPI
bool $isShutdownDone();
249 MCFOLD ::std::shared_ptr<::LevelChunk> $getExistingChunk(
::ChunkPos const& pos);
251 MCFOLD ::std::shared_ptr<::LevelChunk> $getRandomChunk(
::Random& random);
253 MCAPI
bool $isChunkKnown(
::ChunkPos const& chunkPos);
255 MCAPI
bool $isChunkSaved(
::ChunkPos const& chunkPos);
257 MCAPI ::std::shared_ptr<::LevelChunk>
258 $createNewChunk(
::ChunkPos const& cp, ::ChunkSource::LoadMode lm,
bool readOnly);
260 MCAPI ::std::shared_ptr<::LevelChunk>
261 $getOrLoadChunk(
::ChunkPos const& cp, ::ChunkSource::LoadMode lm,
bool readOnly);
269 MCFOLD
bool $verifyChunkNeedsNeighborAwareUpgrade(
::LevelChunk& lc);
273 MCAPI
void $loadChunk(
::LevelChunk& lc,
bool forceImmediateReplacementDataLoad);
275 MCAPI
void $postProcessMobsAt(
::BlockSource& region,
int chunkWestBlock,
int chunkNorthBlock,
::Random& random);
279 MCAPI
void $deleteAllChunkData(
280 ::std::unordered_set<::ChunkPos> chunksToDelete,
281 ::std::function<
void()> completionCallback,
282 ::std::shared_ptr<::ChunkDeletionMetadata> metadata
285 MCAPI
void $deleteStoredChunkData(
286 ::std::unordered_set<::ChunkPos> chunksToDelete,
287 ::std::function<
void()> completionCallback,
288 ::std::shared_ptr<::ChunkDeletionMetadata> metadata
293 MCAPI
void $writeEntityChunkTransfer(
::LevelChunk& levelChunk);
295 MCAPI
void $writeEntityChunkTransfersToUnloadedChunk(
297 ::std::vector<::ActorUnloadedChunkTransferEntry>
const& transfers
300 MCAPI
void $deserializeActorStorageToLevelChunk(
::LevelChunk& levelChunk);
302 MCAPI
void $hintDiscardBatchBegin();
304 MCAPI
void $hintDiscardBatchEnd();
306 MCAPI
void $acquireDiscarded(::std::unique_ptr<::LevelChunk, ::LevelChunkFinalDeleter> ptr);
308 MCAPI
void $compact();
310 MCAPI
void $flushPendingDiscardedChunkWrites();
312 MCAPI
void $flushThreadBatch();
314 MCFOLD
bool $isWithinWorldLimit(
::ChunkPos const& cp)
const;
316 MCFOLD ::std::unordered_map<::ChunkPos, ::std::weak_ptr<::LevelChunk>>
const* $getChunkMap();
318 MCAPI ::std::unordered_map<::ChunkPos, ::std::weak_ptr<::LevelChunk>>
const& $getStorage()
const;
320 MCFOLD
void $clearDeletedEntities();
322 MCFOLD
bool $canCreateViews()
const;
324 MCAPI ::std::unique_ptr<::BlendingDataProvider> $tryGetBlendingDataProvider();
326 MCAPI ::std::shared_ptr<::LevelChunkMetaDataDictionary> $loadLevelChunkMetaDataDictionary();
328 MCFOLD
void $setLevelChunk(::std::shared_ptr<::LevelChunk> lc);
330 MCAPI
bool $canLaunchTasks()
const;
332 MCAPI
bool $chunkPosNeedsBlending(
::ChunkPos const& cp);
334 MCAPI
void $_clearBlendingCache();
336 MCAPI ::std::shared_ptr<::br::worldgen::StructureInstance>