40 enum class LoadMode :
int {
48 ::ll::TypedStorage<4, 4, int> mChunkSide;
49 ::ll::TypedStorage<8, 8, ::Level*> mLevel;
50 ::ll::TypedStorage<8, 8, ::Dimension*> mDimension;
51 ::ll::TypedStorage<8, 8, ::ChunkSource*> mParent;
52 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ChunkSource>> mOwnedParent;
53 ::ll::TypedStorage<8, 8, ::LevelChunkBuilderData*> mLevelChunkBuilderData;
54 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mShuttingDown;
55 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mOnSaveSubscription;
56 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mOnLevelStorageAppSuspendSubscription;
66 virtual ~ChunkSource() ;
68 virtual void shutdown();
70 virtual bool isShutdownDone();
72 virtual ::std::shared_ptr<::LevelChunk> getExistingChunk(
::ChunkPos const&);
74 virtual ::std::shared_ptr<::LevelChunk> getRandomChunk(
::Random& random);
76 virtual bool isChunkKnown(
::ChunkPos const& chunkPos);
78 virtual bool isChunkSaved(
::ChunkPos const& chunkPos);
80 virtual ::std::shared_ptr<::LevelChunk>
81 createNewChunk(
::ChunkPos const& cp, ::ChunkSource::LoadMode lm,
bool readOnly);
83 virtual ::std::shared_ptr<::LevelChunk>
84 getOrLoadChunk(
::ChunkPos const& cp, ::ChunkSource::LoadMode lm,
bool readOnly);
92 virtual bool verifyChunkNeedsNeighborAwareUpgrade(
::LevelChunk&);
96 virtual void loadChunk(
::LevelChunk& lc,
bool forceImmediateReplacementDataLoad);
98 virtual void postProcessMobsAt(
::BlockSource& region,
int chunkWestBlock,
int chunkNorthBlock,
::Random& random);
104 virtual void writeEntityChunkTransfer(
::LevelChunk& levelChunk);
106 virtual void writeEntityChunkTransfersToUnloadedChunk(
108 ::std::vector<::ActorUnloadedChunkTransferEntry>
const& transfers
111 virtual void deserializeActorStorageToLevelChunk(
::LevelChunk& levelChunk);
113 virtual void hintDiscardBatchBegin();
115 virtual void hintDiscardBatchEnd();
117 virtual void acquireDiscarded(::std::unique_ptr<::LevelChunk, ::LevelChunkFinalDeleter> ptr);
119 virtual void compact();
121 virtual void flushPendingDiscardedChunkWrites();
123 virtual void flushThreadBatch();
125 virtual bool isWithinWorldLimit(
::ChunkPos const& cp)
const;
127 virtual ::std::unordered_map<::ChunkPos, ::std::weak_ptr<::LevelChunk>>
const* getChunkMap();
129 virtual ::std::unordered_map<::ChunkPos, ::std::weak_ptr<::LevelChunk>>
const& getStorage()
const;
131 virtual void clearDeletedEntities();
133 virtual bool canCreateViews()
const;
135 virtual ::std::unique_ptr<::BlendingDataProvider> tryGetBlendingDataProvider();
137 virtual ::std::shared_ptr<::LevelChunkMetaDataDictionary> loadLevelChunkMetaDataDictionary();
139 virtual void setLevelChunk(::std::shared_ptr<::LevelChunk>);
141 virtual bool canLaunchTasks()
const;
143 virtual bool chunkPosNeedsBlending(
::ChunkPos const& cp);
149 MCAPI
explicit ChunkSource(::std::unique_ptr<::ChunkSource> parent);
151 MCAPI
bool _checkAndDispatchTaskForLevelChunk(
152 ::std::pair<::ChunkPos, ::ChunkState>
const& chunkPosAndExpectedState,
158 MCAPI
void _checkForUnblockingChunks(
::LevelChunk const& lc);
160 MCAPI
void _checkLevelChunkForNextStage(
163 ::ChunkState stateToCheck
166 MCAPI
void _checkSpecificLevelChunkForUnblocking(
171 MCAPI
bool _chunkAtStage(::std::weak_ptr<::LevelChunk> lcwp, ::ChunkState stateToCheck);
173 MCAPI
void _createOrReplaceGridAreaMap(::std::shared_ptr<::LevelChunk> lc,
bool createNeighbourGridsIfMissing);
177 MCAPI
void _dispatchTaskForLevelChunk(
178 ::std::shared_ptr<::LevelChunk>
const& lc,
179 ::std::shared_ptr<::ChunkViewSource>
const& chunks,
183 MCAPI
void _freeChunkGenerationGridMap(
::ChunkPos const& cp,
bool isLevelChunkDeletion);
185 MCAPI
void _handleTaskFailure(
::LevelChunk& levelChunk, ::ChunkState currentState, ::ChunkState previousState);
187 MCAPI
void _launchChunkTask(
188 ::std::string_view taskName,
194 MCAPI
void _launchDecorationPostProcessingTask(
195 ::std::shared_ptr<::LevelChunk>
const& lc,
196 ::std::shared_ptr<::ChunkViewSource>
const& chunks,
200 MCAPI
void _launchLightingTask(
201 ::std::shared_ptr<::LevelChunk>
const& lc,
202 ::std::shared_ptr<::ChunkViewSource>
const& chunks,
206 MCAPI
void _launchNeighborAwareUpgradeTask(
207 ::std::shared_ptr<::LevelChunk>
const& lc,
208 ::std::shared_ptr<::ChunkViewSource>
const& chunks,
212 MCAPI
void _launchReplacementDataTask(
213 ::std::shared_ptr<::LevelChunk>
const& lc,
214 ::std::shared_ptr<::ChunkViewSource>
const& chunks,
218 MCAPI
void _launchStructurePostProcessingTask(
219 ::std::shared_ptr<::LevelChunk>
const& lc,
220 ::std::shared_ptr<::ChunkViewSource>
const& chunks,
224 MCAPI
void _lightingTask(::std::shared_ptr<::LevelChunk>
const& lc,
::ChunkViewSource& chunks);
232 MCAPI
void _spawnChunkGenerationTasks(
int numTasks,
bool calledFromTask);
234 MCAPI_C
void addEmptyChunkPosForProcessingNeighbours(::std::shared_ptr<::LevelChunk> lc);
236 MCAPI
void checkAndLaunchChunkGenerationTasks(
bool calledFromTask);
238 MCAPI ::GridArea<::std::shared_ptr<::LevelChunk>> createEmptyView(
239 ::ChunkSource::LoadMode lm,
242 ::ChunkSourceViewGenerateMode chunkViewGenerateMode,
243 float const* serverBuildRatio
246 MCAPI ::std::shared_ptr<::LevelChunk> getAvailableChunk(
::ChunkPos const& cp);
248 MCAPI_C ::std::shared_ptr<::LevelChunk> getAvailableChunkAt(
::BlockPos const& pos);
253 MCAPI
bool shouldServerGeneratePos(
::ChunkPos const& chunkPos,
float serverBuildRatio,
int viewRadius);
259 MCAPI
static bool& gPerfIsClientSide();
265 MCAPI
void* $ctor(::std::unique_ptr<::ChunkSource> parent);
277 MCAPI
void $shutdown();
279 MCAPI
bool $isShutdownDone();
281 MCFOLD ::std::shared_ptr<::LevelChunk> $getExistingChunk(
::ChunkPos const&);
283 MCFOLD ::std::shared_ptr<::LevelChunk> $getRandomChunk(
::Random& random);
285 MCAPI
bool $isChunkKnown(
::ChunkPos const& chunkPos);
287 MCAPI
bool $isChunkSaved(
::ChunkPos const& chunkPos);
289 MCAPI ::std::shared_ptr<::LevelChunk>
290 $createNewChunk(
::ChunkPos const& cp, ::ChunkSource::LoadMode lm,
bool readOnly);
292 MCAPI ::std::shared_ptr<::LevelChunk>
293 $getOrLoadChunk(
::ChunkPos const& cp, ::ChunkSource::LoadMode lm,
bool readOnly);
301 MCFOLD
bool $verifyChunkNeedsNeighborAwareUpgrade(
::LevelChunk&);
305 MCAPI
void $loadChunk(
::LevelChunk& lc,
bool forceImmediateReplacementDataLoad);
307 MCAPI
void $postProcessMobsAt(
::BlockSource& region,
int chunkWestBlock,
int chunkNorthBlock,
::Random& random);
313 MCAPI
void $writeEntityChunkTransfer(
::LevelChunk& levelChunk);
315 MCAPI
void $writeEntityChunkTransfersToUnloadedChunk(
317 ::std::vector<::ActorUnloadedChunkTransferEntry>
const& transfers
320 MCAPI
void $deserializeActorStorageToLevelChunk(
::LevelChunk& levelChunk);
322 MCAPI
void $hintDiscardBatchBegin();
324 MCAPI
void $hintDiscardBatchEnd();
326 MCAPI
void $acquireDiscarded(::std::unique_ptr<::LevelChunk, ::LevelChunkFinalDeleter> ptr);
328 MCAPI
void $compact();
330 MCAPI
void $flushPendingDiscardedChunkWrites();
332 MCAPI
void $flushThreadBatch();
334 MCFOLD
bool $isWithinWorldLimit(
::ChunkPos const& cp)
const;
336 MCFOLD ::std::unordered_map<::ChunkPos, ::std::weak_ptr<::LevelChunk>>
const* $getChunkMap();
338 MCAPI ::std::unordered_map<::ChunkPos, ::std::weak_ptr<::LevelChunk>>
const& $getStorage()
const;
340 MCFOLD
void $clearDeletedEntities();
342 MCFOLD
bool $canCreateViews()
const;
344 MCAPI ::std::unique_ptr<::BlendingDataProvider> $tryGetBlendingDataProvider();
346 MCAPI ::std::shared_ptr<::LevelChunkMetaDataDictionary> $loadLevelChunkMetaDataDictionary();
348 MCFOLD
void $setLevelChunk(::std::shared_ptr<::LevelChunk>);
350 MCAPI
bool $canLaunchTasks()
const;
352 MCAPI
bool $chunkPosNeedsBlending(
::ChunkPos const& cp);