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;
65 virtual ~ChunkSource() ;
67 virtual void shutdown();
69 virtual bool isShutdownDone();
71 virtual ::std::shared_ptr<::LevelChunk> getExistingChunk(
::ChunkPos const& pos);
73 virtual ::std::shared_ptr<::LevelChunk> getRandomChunk(
::Random& random);
75 virtual bool isChunkKnown(
::ChunkPos const& chunkPos);
77 virtual bool isChunkSaved(
::ChunkPos const& chunkPos);
79 virtual ::std::shared_ptr<::LevelChunk>
80 createNewChunk(
::ChunkPos const& cp, ::ChunkSource::LoadMode lm,
bool readOnly);
82 virtual ::std::shared_ptr<::LevelChunk>
83 getOrLoadChunk(
::ChunkPos const& cp, ::ChunkSource::LoadMode lm,
bool readOnly);
91 virtual bool verifyChunkNeedsNeighborAwareUpgrade(
::LevelChunk& lc);
95 virtual void loadChunk(
::LevelChunk& lc,
bool forceImmediateReplacementDataLoad);
97 virtual void postProcessMobsAt(
::BlockSource& region,
int chunkWestBlock,
int chunkNorthBlock,
::Random& random);
101 virtual void deleteAllChunkData(
102 ::std::unordered_set<::ChunkPos> chunksToDelete,
103 ::std::function<
void()> completionCallback,
104 ::std::shared_ptr<::ChunkDeletionMetadata> metadata
107 virtual void deleteStoredChunkData(
108 ::std::unordered_set<::ChunkPos> chunksToDelete,
109 ::std::function<
void()> completionCallback,
110 ::std::shared_ptr<::ChunkDeletionMetadata> metadata
115 virtual void writeEntityChunkTransfer(
::LevelChunk& levelChunk);
117 virtual void writeEntityChunkTransfersToUnloadedChunk(
119 ::std::vector<::ActorUnloadedChunkTransferEntry>
const& transfers
122 virtual void deserializeActorStorageToLevelChunk(
::LevelChunk& levelChunk);
124 virtual void hintDiscardBatchBegin();
126 virtual void hintDiscardBatchEnd();
128 virtual void acquireDiscarded(::std::unique_ptr<::LevelChunk, ::LevelChunkFinalDeleter> ptr);
130 virtual void compact();
132 virtual void flushPendingDiscardedChunkWrites();
134 virtual void flushThreadBatch();
136 virtual bool isWithinWorldLimit(
::ChunkPos const& cp)
const;
138 virtual ::std::unordered_map<::ChunkPos, ::std::weak_ptr<::LevelChunk>>
const* getChunkMap()
const;
140 virtual ::std::unordered_map<::ChunkPos, ::std::weak_ptr<::LevelChunk>>
const& getStorage()
const;
142 virtual void clearDeletedEntities();
144 virtual bool canCreateViews()
const;
146 virtual ::std::unique_ptr<::BlendingDataProvider> tryGetBlendingDataProvider();
148 virtual ::std::shared_ptr<::LevelChunkMetaDataDictionary> loadLevelChunkMetaDataDictionary();
150 virtual void setLevelChunk(::std::shared_ptr<::LevelChunk> lc);
152 virtual bool canLaunchTasks()
const;
154 virtual bool chunkPosNeedsBlending(
::ChunkPos const& cp);
156 virtual void _clearBlendingCache();
158 virtual ::std::shared_ptr<::br::worldgen::StructureInstance>
165 MCAPI
explicit ChunkSource(::std::unique_ptr<::ChunkSource> parent);
168 MCAPI
void _checkForUnblockingChunks(
::ChunkPos cp);
172 MCAPI
void _checkForUnblockingChunks(
::ChunkPos cp);
176 MCAPI
void _createOrReplaceGridAreaMap(::std::shared_ptr<::LevelChunk> lc,
bool createNeighbourGridsIfMissing);
179 MCAPI
void _freeChunkGenerationGridMap(
::ChunkPos const& cp,
bool isLevelChunkDeletion);
181 MCAPI
void _launchChunkTask(
182 ::std::string_view taskName,
190 MCAPI
void _spawnChunkGenerationTasks(
int numTasks,
bool calledFromTask);
193 MCAPI
void addEmptyChunkPosForProcessingNeighbours(::std::shared_ptr<::LevelChunk> lc);
196 MCAPI
void checkAndLaunchChunkGenerationTasks(
bool calledFromTask);
199 MCAPI ::GridArea<::std::shared_ptr<::LevelChunk>> createEmptyView(
200 ::ChunkSource::LoadMode lm,
202 ::std::function<
void(::gsl::span<::std::shared_ptr<::LevelChunk>>)> add,
203 ::ChunkSourceViewGenerateMode chunkViewGenerateMode,
204 float const* serverBuildRatio
209 LLAPI ::std::shared_ptr<::LevelChunk> getAvailableChunk(
::ChunkPos const& cp);
218 MCAPI
static bool& gPerfIsClientSide();
224 MCAPI
void* $ctor(::std::unique_ptr<::ChunkSource> parent);
236 MCAPI
void $shutdown();
238 MCAPI
bool $isShutdownDone();
240 MCFOLD ::std::shared_ptr<::LevelChunk> $getExistingChunk(
::ChunkPos const& pos);
242 MCFOLD ::std::shared_ptr<::LevelChunk> $getRandomChunk(
::Random& random);
244 MCAPI
bool $isChunkKnown(
::ChunkPos const& chunkPos);
246 MCAPI
bool $isChunkSaved(
::ChunkPos const& chunkPos);
248 MCAPI ::std::shared_ptr<::LevelChunk>
249 $createNewChunk(
::ChunkPos const& cp, ::ChunkSource::LoadMode lm,
bool readOnly);
251 MCAPI ::std::shared_ptr<::LevelChunk>
252 $getOrLoadChunk(
::ChunkPos const& cp, ::ChunkSource::LoadMode lm,
bool readOnly);
260 MCFOLD
bool $verifyChunkNeedsNeighborAwareUpgrade(
::LevelChunk& lc);
264 MCAPI
void $loadChunk(
::LevelChunk& lc,
bool forceImmediateReplacementDataLoad);
266 MCAPI
void $postProcessMobsAt(
::BlockSource& region,
int chunkWestBlock,
int chunkNorthBlock,
::Random& random);
270 MCAPI
void $deleteAllChunkData(
271 ::std::unordered_set<::ChunkPos> chunksToDelete,
272 ::std::function<
void()> completionCallback,
273 ::std::shared_ptr<::ChunkDeletionMetadata> metadata
276 MCAPI
void $deleteStoredChunkData(
277 ::std::unordered_set<::ChunkPos> chunksToDelete,
278 ::std::function<
void()> completionCallback,
279 ::std::shared_ptr<::ChunkDeletionMetadata> metadata
284 MCAPI
void $writeEntityChunkTransfer(
::LevelChunk& levelChunk);
286 MCAPI
void $writeEntityChunkTransfersToUnloadedChunk(
288 ::std::vector<::ActorUnloadedChunkTransferEntry>
const& transfers
291 MCAPI
void $deserializeActorStorageToLevelChunk(
::LevelChunk& levelChunk);
293 MCAPI
void $hintDiscardBatchBegin();
295 MCAPI
void $hintDiscardBatchEnd();
297 MCAPI
void $acquireDiscarded(::std::unique_ptr<::LevelChunk, ::LevelChunkFinalDeleter> ptr);
299 MCAPI
void $compact();
301 MCAPI
void $flushPendingDiscardedChunkWrites();
303 MCAPI
void $flushThreadBatch();
305 MCFOLD
bool $isWithinWorldLimit(
::ChunkPos const& cp)
const;
307 MCFOLD ::std::unordered_map<::ChunkPos, ::std::weak_ptr<::LevelChunk>>
const* $getChunkMap()
const;
309 MCAPI ::std::unordered_map<::ChunkPos, ::std::weak_ptr<::LevelChunk>>
const& $getStorage()
const;
311 MCFOLD
void $clearDeletedEntities();
313 MCFOLD
bool $canCreateViews()
const;
315 MCAPI ::std::unique_ptr<::BlendingDataProvider> $tryGetBlendingDataProvider();
317 MCAPI ::std::shared_ptr<::LevelChunkMetaDataDictionary> $loadLevelChunkMetaDataDictionary();
319 MCFOLD
void $setLevelChunk(::std::shared_ptr<::LevelChunk> lc);
321 MCAPI
bool $canLaunchTasks()
const;
323 MCAPI
bool $chunkPosNeedsBlending(
::ChunkPos const& cp);
325 MCAPI
void $_clearBlendingCache();
327 MCAPI ::std::shared_ptr<::br::worldgen::StructureInstance>