LeviLamina
Loading...
Searching...
No Matches
ChunkSource.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/deps/core/utility/EnableNonOwnerReferences.h"
7#include "mc/deps/core/utility/buffer_span.h"
8#include "mc/util/GridArea.h"
9#include "mc/world/level/chunk/ChunkSourceViewGenerateMode.h"
10#include "mc/world/level/chunk/ChunkState.h"
11#include "mc/world/level/chunk/LevelChunkGridAreaElement.h"
12
13// auto generated forward declare list
14// clang-format off
16class BlockSource;
17class BoundingBox;
18class ChunkKey;
19class ChunkPos;
20class ChunkViewSource;
21class Dimension;
23class Level;
24class LevelChunk;
27class LevelStorage;
28class Random;
31namespace Bedrock::PubSub { class Subscription; }
32// clang-format on
33
35public:
36 // ChunkSource inner types define
37 enum class LoadMode : int {
38 None = 0,
39 Deferred = 1,
40 };
41
42public:
43 // member variables
44 // NOLINTBEGIN
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;
54 // NOLINTEND
55
56public:
57 // virtual functions
58 // NOLINTBEGIN
59 // vIndex: 0
60 virtual ~ChunkSource() /*override*/;
61
62 // vIndex: 1
63 virtual void shutdown();
64
65 // vIndex: 2
66 virtual bool isShutdownDone();
67
68 // vIndex: 3
69 virtual ::std::shared_ptr<::LevelChunk> getExistingChunk(::ChunkPos const&);
70
71 // vIndex: 4
72 virtual ::std::shared_ptr<::LevelChunk> getRandomChunk(::Random& random);
73
74 // vIndex: 5
75 virtual bool isChunkKnown(::ChunkPos const& chunkPos);
76
77 // vIndex: 6
78 virtual bool isChunkSaved(::ChunkPos const& chunkPos);
79
80 // vIndex: 7
81 virtual ::std::shared_ptr<::LevelChunk>
82 createNewChunk(::ChunkPos const& cp, ::ChunkSource::LoadMode lm, bool readOnly);
83
84 // vIndex: 8
85 virtual ::std::shared_ptr<::LevelChunk>
86 getOrLoadChunk(::ChunkPos const& cp, ::ChunkSource::LoadMode lm, bool readOnly);
87
88 // vIndex: 9
89 virtual bool postProcess(::ChunkViewSource& neighborhood);
90
91 // vIndex: 10
92 virtual void checkAndReplaceChunk(::ChunkViewSource& neighborhood, ::LevelChunk& lc);
93
94 // vIndex: 11
95 virtual void loadChunk(::LevelChunk& lc, bool forceImmediateReplacementDataLoad);
96
97 // vIndex: 13
98 virtual void postProcessMobsAt(::BlockSource& region, int chunkWestBlock, int chunkNorthBlock, ::Random& random);
99
100 // vIndex: 12
101 virtual void postProcessMobsAt(::BlockSource& region, ::BoundingBox const& chunkBB) const;
102
103 // vIndex: 14
104 virtual bool saveLiveChunk(::LevelChunk& lc);
105
106 // vIndex: 15
107 virtual void writeEntityChunkTransfer(::LevelChunk& levelChunk);
108
109 // vIndex: 16
110 virtual void writeEntityChunkTransfersToUnloadedChunk(
111 ::ChunkKey const& chunkKey,
112 ::std::vector<::ActorUnloadedChunkTransferEntry> const& transfers
113 );
114
115 // vIndex: 17
116 virtual void deserializeActorStorageToLevelChunk(::LevelChunk& levelChunk);
117
118 // vIndex: 18
119 virtual void hintDiscardBatchBegin();
120
121 // vIndex: 19
122 virtual void hintDiscardBatchEnd();
123
124 // vIndex: 20
125 virtual void acquireDiscarded(::std::unique_ptr<::LevelChunk, ::LevelChunkFinalDeleter> ptr);
126
127 // vIndex: 21
128 virtual void compact();
129
130 // vIndex: 22
131 virtual void flushPendingDiscardedChunkWrites();
132
133 // vIndex: 23
134 virtual void flushThreadBatch();
135
136 // vIndex: 24
137 virtual bool isWithinWorldLimit(::ChunkPos const& cp) const;
138
139 // vIndex: 25
140 virtual ::std::unordered_map<::ChunkPos, ::std::weak_ptr<::LevelChunk>> const* getChunkMap();
141
142 // vIndex: 26
143 virtual ::std::unordered_map<::ChunkPos, ::std::weak_ptr<::LevelChunk>> const& getStorage() const;
144
145 // vIndex: 27
146 virtual void clearDeletedEntities();
147
148 // vIndex: 28
149 virtual bool canCreateViews() const;
150
151 // vIndex: 29
152 virtual ::std::unique_ptr<::BlendingDataProvider> tryGetBlendingDataProvider();
153
154 // vIndex: 30
155 virtual ::std::shared_ptr<::LevelChunkMetaDataDictionary> loadLevelChunkMetaDataDictionary();
156
157 // vIndex: 31
158 virtual void setLevelChunk(::std::shared_ptr<::LevelChunk>);
159
160 // vIndex: 32
161 virtual bool canLaunchTasks() const;
162
163 // vIndex: 33
164 virtual bool chunkPosNeedsBlending(::ChunkPos const& cp);
165 // NOLINTEND
166
167public:
168 // member functions
169 // NOLINTBEGIN
170 MCAPI explicit ChunkSource(::std::unique_ptr<::ChunkSource> parent);
171
172 MCAPI bool _checkAndDispatchTaskForLevelChunk(
173 ::std::pair<::ChunkPos, ::ChunkState> const& chunkPosAndExpectedState,
174 bool areInTask
175 );
176
177 MCAPI void _checkForReplacementDataTask(::LevelChunk& lc, ::ChunkViewSource& chunks);
178
179 MCAPI void _checkForUnblockingChunks(::LevelChunk const& lc);
180
181 MCAPI void _checkLevelChunkForNextStage(
182 ::LevelChunk const& lc,
183 ::LevelChunkGridAreaElement<::std::weak_ptr<::LevelChunk>>& grid,
184 ::ChunkState stateToCheck
185 );
186
187 MCAPI void _checkLevelChunkForPostProcessing(
188 ::LevelChunk const& lc,
189 ::LevelChunkGridAreaElement<::std::weak_ptr<::LevelChunk>>& grid
190 );
191
192 MCAPI bool _chunkAtStage(::std::weak_ptr<::LevelChunk> lcwp, ::ChunkState stateToCheck);
193
194 MCAPI void _createOrReplaceGridAreaMap(::std::shared_ptr<::LevelChunk> lc, bool createNeighbourGridsIfMissing);
195
196 MCAPI void _freeChunkGenerationGridMap(::ChunkPos const& cp, bool isLevelChunkDeletion);
197
198 MCAPI void _launchGenerationTask(::std::shared_ptr<::LevelChunk> const& lc, bool areInTask);
199
200 MCAPI void _launchLightingTask(
201 ::std::shared_ptr<::LevelChunk> const& lc,
202 ::std::shared_ptr<::ChunkViewSource> const& chunks,
203 bool areInTask
204 );
205
206 MCAPI void _launchPostProcessingTask(
207 ::std::shared_ptr<::LevelChunk> const& lc,
208 ::std::shared_ptr<::ChunkViewSource> const& chunks,
209 bool areInTask
210 );
211
212 MCAPI void _launchReplacementDataTask(
213 ::std::shared_ptr<::LevelChunk> const& lc,
214 ::std::shared_ptr<::ChunkViewSource> const& chunks,
215 bool areInTask
216 );
217
218 MCAPI void _lightingTask(::std::shared_ptr<::LevelChunk> const& lc, ::ChunkViewSource& chunks);
219
220 MCAPI void _loadChunkTask(::LevelChunk& lc);
221
222 MCAPI void _postProcessingTask(::LevelChunk& lc, ::ChunkViewSource& chunks);
223
224 MCAPI void _saveDirtyChunks(::LevelStorage&);
225
226 MCAPI void _spawnChunkGenerationTasks(int numTasks, bool calledFromTask);
227
228 MCAPI void checkAndLaunchChunkGenerationTasks(bool calledFromTask);
229
230 MCAPI ::GridArea<::std::shared_ptr<::LevelChunk>> createEmptyView(
231 ::ChunkSource::LoadMode lm,
232 bool circle,
233 ::std::function<void(::buffer_span_mut<::std::shared_ptr<::LevelChunk>>, ::buffer_span<uint>)> add,
234 ::ChunkSourceViewGenerateMode chunkViewGenerateMode,
235 float const* serverBuildRatio
236 );
237
238 MCAPI ::std::shared_ptr<::LevelChunk> getAvailableChunk(::ChunkPos const& cp);
239
240 MCAPI void initializeWithLevelStorageManagerConnector(::ILevelStorageManagerConnector& levelStorageManagerConnector
241 );
242
243 MCAPI bool shouldServerGeneratePos(::ChunkPos const& chunkPos, float serverBuildRatio, int viewRadius);
244 // NOLINTEND
245
246public:
247 // static variables
248 // NOLINTBEGIN
249 MCAPI static bool& gPerfIsClientSide();
250 // NOLINTEND
251
252public:
253 // constructor thunks
254 // NOLINTBEGIN
255 MCAPI void* $ctor(::std::unique_ptr<::ChunkSource> parent);
256 // NOLINTEND
257
258public:
259 // destructor thunk
260 // NOLINTBEGIN
261 MCAPI void $dtor();
262 // NOLINTEND
263
264public:
265 // virtual function thunks
266 // NOLINTBEGIN
267 MCAPI void $shutdown();
268
269 MCAPI bool $isShutdownDone();
270
271 MCFOLD ::std::shared_ptr<::LevelChunk> $getExistingChunk(::ChunkPos const&);
272
273 MCFOLD ::std::shared_ptr<::LevelChunk> $getRandomChunk(::Random& random);
274
275 MCAPI bool $isChunkKnown(::ChunkPos const& chunkPos);
276
277 MCAPI bool $isChunkSaved(::ChunkPos const& chunkPos);
278
279 MCAPI ::std::shared_ptr<::LevelChunk>
280 $createNewChunk(::ChunkPos const& cp, ::ChunkSource::LoadMode lm, bool readOnly);
281
282 MCAPI ::std::shared_ptr<::LevelChunk>
283 $getOrLoadChunk(::ChunkPos const& cp, ::ChunkSource::LoadMode lm, bool readOnly);
284
285 MCFOLD bool $postProcess(::ChunkViewSource& neighborhood);
286
287 MCFOLD void $checkAndReplaceChunk(::ChunkViewSource& neighborhood, ::LevelChunk& lc);
288
289 MCAPI void $loadChunk(::LevelChunk& lc, bool forceImmediateReplacementDataLoad);
290
291 MCAPI void $postProcessMobsAt(::BlockSource& region, int chunkWestBlock, int chunkNorthBlock, ::Random& random);
292
293 MCAPI void $postProcessMobsAt(::BlockSource& region, ::BoundingBox const& chunkBB) const;
294
295 MCAPI bool $saveLiveChunk(::LevelChunk& lc);
296
297 MCAPI void $writeEntityChunkTransfer(::LevelChunk& levelChunk);
298
299 MCAPI void $writeEntityChunkTransfersToUnloadedChunk(
300 ::ChunkKey const& chunkKey,
301 ::std::vector<::ActorUnloadedChunkTransferEntry> const& transfers
302 );
303
304 MCAPI void $deserializeActorStorageToLevelChunk(::LevelChunk& levelChunk);
305
306 MCAPI void $hintDiscardBatchBegin();
307
308 MCAPI void $hintDiscardBatchEnd();
309
310 MCAPI void $acquireDiscarded(::std::unique_ptr<::LevelChunk, ::LevelChunkFinalDeleter> ptr);
311
312 MCAPI void $compact();
313
314 MCAPI void $flushPendingDiscardedChunkWrites();
315
316 MCAPI void $flushThreadBatch();
317
318 MCFOLD bool $isWithinWorldLimit(::ChunkPos const& cp) const;
319
320 MCFOLD ::std::unordered_map<::ChunkPos, ::std::weak_ptr<::LevelChunk>> const* $getChunkMap();
321
322 MCAPI ::std::unordered_map<::ChunkPos, ::std::weak_ptr<::LevelChunk>> const& $getStorage() const;
323
324 MCFOLD void $clearDeletedEntities();
325
326 MCFOLD bool $canCreateViews() const;
327
328 MCAPI ::std::unique_ptr<::BlendingDataProvider> $tryGetBlendingDataProvider();
329
330 MCAPI ::std::shared_ptr<::LevelChunkMetaDataDictionary> $loadLevelChunkMetaDataDictionary();
331
332 MCFOLD void $setLevelChunk(::std::shared_ptr<::LevelChunk>);
333
334 MCAPI bool $canLaunchTasks() const;
335
336 MCAPI bool $chunkPosNeedsBlending(::ChunkPos const& cp);
337 // NOLINTEND
338
339public:
340 // vftables
341 // NOLINTBEGIN
342 MCAPI static void** $vftable();
343 // NOLINTEND
344};
Definition EnableNonOwnerReferences.h:7
Definition BlendingDataProvider.h:5
Definition BlockSource.h:67
Definition BoundingBox.h:18
Definition ChunkKey.h:14
Definition ChunkPos.h:11
Definition ChunkSource.h:34
Definition ChunkViewSource.h:22
Definition Dimension.h:83
Definition ILevelStorageManagerConnector.h:13
Definition LevelChunkBuilderData.h:16
Definition LevelChunkGridAreaElement.h:6
Definition LevelChunkMetaDataDictionary.h:11
Definition LevelChunk.h:73
Definition LevelStorage.h:24
Definition Level.h:234
Definition Random.h:16
Definition _HeaderOutputPredefine.h:179
Definition buffer_span.h:6
Definition ActorUnloadedChunkTransferEntry.h:11
Definition LevelChunkFinalDeleter.h:5