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);
213 MCAPI ::GridArea<::std::shared_ptr<::LevelChunk>> createEmptyView(
214 ::ChunkSource::LoadMode lm,
216 ::std::function<
void(::gsl::span<::std::shared_ptr<::LevelChunk>>)> add,
217 ::ChunkSourceViewGenerateMode chunkViewGenerateMode,
218 float const* serverBuildRatio
229 MCAPI
static bool& gPerfIsClientSide();
235 MCAPI
void* $ctor(::std::unique_ptr<::ChunkSource> parent);
247 MCAPI
void $shutdown();
249 MCAPI
bool $isShutdownDone();
251 MCFOLD ::std::shared_ptr<::LevelChunk> $getExistingChunk(
::ChunkPos const& pos);
253 MCFOLD ::std::shared_ptr<::LevelChunk> $getRandomChunk(
::Random& random);
255 MCAPI
bool $isChunkKnown(
::ChunkPos const& chunkPos);
257 MCAPI
bool $isChunkSaved(
::ChunkPos const& chunkPos);
259 MCAPI ::std::shared_ptr<::LevelChunk>
260 $createNewChunk(
::ChunkPos const& cp, ::ChunkSource::LoadMode lm,
bool readOnly);
262 MCAPI ::std::shared_ptr<::LevelChunk>
263 $getOrLoadChunk(
::ChunkPos const& cp, ::ChunkSource::LoadMode lm,
bool readOnly);
271 MCFOLD
bool $verifyChunkNeedsNeighborAwareUpgrade(
::LevelChunk& lc);
275 MCAPI
void $loadChunk(
::LevelChunk& lc,
bool forceImmediateReplacementDataLoad);
277 MCAPI
void $postProcessMobsAt(
::BlockSource& region,
int chunkWestBlock,
int chunkNorthBlock,
::Random& random);
281 MCAPI
void $deleteAllChunkData(
282 ::std::unordered_set<::ChunkPos> chunksToDelete,
283 ::std::function<
void()> completionCallback,
284 ::std::shared_ptr<::ChunkDeletionMetadata> metadata
287 MCAPI
void $deleteStoredChunkData(
288 ::std::unordered_set<::ChunkPos> chunksToDelete,
289 ::std::function<
void()> completionCallback,
290 ::std::shared_ptr<::ChunkDeletionMetadata> metadata
295 MCAPI
void $writeEntityChunkTransfer(
::LevelChunk& levelChunk);
297 MCAPI
void $writeEntityChunkTransfersToUnloadedChunk(
299 ::std::vector<::ActorUnloadedChunkTransferEntry>
const& transfers
302 MCAPI
void $deserializeActorStorageToLevelChunk(
::LevelChunk& levelChunk);
304 MCAPI
void $hintDiscardBatchBegin();
306 MCAPI
void $hintDiscardBatchEnd();
308 MCAPI
void $acquireDiscarded(::std::unique_ptr<::LevelChunk, ::LevelChunkFinalDeleter> ptr);
310 MCAPI
void $compact();
312 MCAPI
void $flushPendingDiscardedChunkWrites();
314 MCAPI
void $flushThreadBatch();
316 MCFOLD
bool $isWithinWorldLimit(
::ChunkPos const& cp)
const;
318 MCFOLD ::std::unordered_map<::ChunkPos, ::std::weak_ptr<::LevelChunk>>
const* $getChunkMap();
320 MCAPI ::std::unordered_map<::ChunkPos, ::std::weak_ptr<::LevelChunk>>
const& $getStorage()
const;
322 MCFOLD
void $clearDeletedEntities();
324 MCFOLD
bool $canCreateViews()
const;
326 MCAPI ::std::unique_ptr<::BlendingDataProvider> $tryGetBlendingDataProvider();
328 MCAPI ::std::shared_ptr<::LevelChunkMetaDataDictionary> $loadLevelChunkMetaDataDictionary();
331 MCAPI
void $setLevelChunk(::std::shared_ptr<::LevelChunk> lc);
333 MCFOLD
void $setLevelChunk(::std::shared_ptr<::LevelChunk> lc);
336 MCAPI
bool $canLaunchTasks()
const;
338 MCAPI
bool $chunkPosNeedsBlending(
::ChunkPos const& cp);
340 MCAPI
void $_clearBlendingCache();
342 MCAPI ::std::shared_ptr<::br::worldgen::StructureInstance>