92 LLAPI
void deserializeBorderBlocks(
::IDataInput& stream);
103 enum class DeserializeEntityResult :
int {
104 FailedToLoadActor = 0,
105 FailedToAddToLevel = 1,
109 enum class Finalization :
int {
110 NeedsInstaticking = 0,
119 ::ll::TypedStorage<1, 1, uchar> mNeighbors;
125 MCAPI static ::std::array<::std::pair<::LevelChunkNeighbor, ::ChunkPos>, 8>
const& sOffsetMap();
133 ::ll::TypedStorage<4, 24, ::BoundingBox> aabb;
134 ::ll::TypedStorage<1, 1, ::HardcodedSpawnAreaType> type;
142 ::ll::TypedStorage<1, 1, bool> mWasStored;
143 ::ll::TypedStorage<1, 1, bool> mWasGenerated;
144 ::ll::TypedStorage<1, 1, bool> mWasRequestedInsideTickRange;
145 ::ll::TypedStorage<1, 1, bool> mWasLoadedInsideTickRange;
149 using BBorder = bool;
153 using BlockActorVector = ::std::vector<::std::shared_ptr<::BlockActor>>;
155 using MoveLock = ::std::lock_guard<::SpinLockImpl>;
162 ::ll::TypedStorage<8, 80, ::std::mutex> mBlockEntityAccessLock;
163 ::ll::TypedStorage<8, 8, ::ILevel&> mLevel;
164 ::ll::TypedStorage<8, 8, ::Dimension&> mDimension;
165 ::ll::TypedStorage<4, 12, ::BlockPos> mMin;
166 ::ll::TypedStorage<4, 12, ::BlockPos> mMax;
167 ::ll::TypedStorage<8, 8, ::ChunkPos> mPosition;
168 ::ll::TypedStorage<1, 1, bool> mLightingFixupDone;
169 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mLightingTaskActive;
170 ::ll::TypedStorage<1, 1, bool> mReadOnly;
171 ::ll::TypedStorage<8, 8, ::ChunkSource*> mGenerator;
172 ::ll::TypedStorage<4, 4, ::LevelChunkTicking::Entity> mTmpTickingEntity;
173 ::ll::TypedStorage<1, 2, ::std::optional<::LevelChunkFormat>> mLoadedFormat;
174 ::ll::TypedStorage<1, 1, bool> mHadSerializedEntities;
175 ::ll::TypedStorage<8, 32, ::std::string> mSerializedEntitiesBuffer;
176 ::ll::TypedStorage<8, 32, ::std::string> mFailedSerializedEntitiesBuffer;
177 ::ll::TypedStorage<8, 24, ::std::vector<::ActorLink>> mUnresolvedActorLinks;
178 ::ll::TypedStorage<1, 1, ::std::atomic<::ChunkState>> mLoadState;
179 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mIsCurrentLoadStateIndeterminate;
180 ::ll::TypedStorage<1, 1, ::ChunkTerrainDataState> mTerrainDataState;
181 ::ll::TypedStorage<1, 1, ::ChunkDebugDisplaySavedState> mDebugDisplaySavedState;
182 ::ll::TypedStorage<1, 1, ::ChunkCachedDataState> mCachedDataState;
183 ::ll::TypedStorage<8, 24, ::SpinLockImpl> mCachedDataStateSpinLock;
184 ::ll::TypedStorage<8, 24, ::SpinLockImpl> mClientRequestHeightmapAdjustSpinLock;
185 ::ll::TypedStorage<8, 8, ::Tick> mLastTick;
186 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::BlockTickingQueue>> mTickQueue;
187 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::BlockTickingQueue>> mRandomTickQueue;
188 ::ll::TypedStorage<8, 24, ::std::vector<::SubChunk>> mSubChunks;
189 ::ll::TypedStorage<8, 552, ::LevelChunkBiomes> mBiomes;
190 ::ll::TypedStorage<4, 2048, ::std::array<::ColumnCachedData, 256>> mCachedData;
191 ::ll::TypedStorage<2, 512, ::std::array<::ChunkLocalHeight, 256>> mHeightmap;
192 ::ll::TypedStorage<2, 512, ::std::array<::ChunkLocalHeight, 256>> mRenderHeightmap;
193 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::std::vector<short>>> mPreWorldGenHeightmap;
194 ::ll::TypedStorage<2, 2, ::ChunkLocalHeight> mNonAirMaxHeight;
195 ::ll::TypedStorage<8, 64, ::std::unordered_map<::BiomeIdType, ::BiomeChunkState>> mBiomeStates;
196 ::ll::TypedStorage<1, 1, bool> mHasCachedTemperatureNoise;
197 ::ll::TypedStorage<1, 256, ::std::array<bool, 256>> mBorderBlockMap;
198 ::ll::TypedStorage<1, 1, bool> mIsRedstoneLoaded;
199 ::ll::TypedStorage<1, 1, bool> mOwnedByTickingThread;
200 ::ll::TypedStorage<1, 1, bool> mUse3DBiomeMaps;
201 ::ll::TypedStorage<1, 1, bool> mLevelChunkHas3dBiomeTag;
202 ::ll::TypedStorage<4, 4, int> mCurrentInstatick;
203 ::ll::TypedStorage<4, 4, ::LevelChunk::Finalization> mFinalized;
204 ::ll::TypedStorage<1, 4, ::LevelChunk::Telemetry> mTelemetry;
205 ::ll::TypedStorage<8, 64, ::ChunkGenContext> mChunkGenContext;
206 ::ll::TypedStorage<4, 48, ::DirtyTicksCounter[6]> mFullChunkDirtyTicksCounters;
207 ::ll::TypedStorage<4, 8, ::DirtyTicksCounter> mChunkActorsDirtyTicksCounter;
208 ::ll::TypedStorage<2, 512, ::std::array<::ChunkLocalHeight, 256>> mRainHeights;
209 ::ll::TypedStorage<8, 24, ::std::vector<::WeakEntityRef>> mEntities;
210 ::ll::TypedStorage<8, 24, ::std::vector<::std::string>> mRemovedActorStorageKeys;
211 ::ll::TypedStorage<8, 184, ::LevelChunkBlockActorStorage> mBlockEntities;
212 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::BlockActor>>> mPreservedBlockEntities;
213 ::ll::TypedStorage<8, 8, ::Tick> mPreservedBlockEntitiesTick;
214 ::ll::TypedStorage<8, 24, ::std::vector<::WeakRef<::EntityContext>>> mVolumes;
215 ::ll::TypedStorage<1, 2, ::BrightnessPair> mDefaultBrightness;
216 ::ll::TypedStorage<8, 24, ::std::vector<::LevelChunk::SpawningArea>> mSpawningAreas;
217 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mLastNetworkLightingTime;
218 ::ll::TypedStorage<8, 8, uint64> mLoadedMetaDataHash;
219 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::LevelChunkMetaData>> mMetaData;
220 ::ll::TypedStorage<4, 16, float[2][2]> mChunkInterpolants;
221 ::ll::TypedStorage<4, 8, ::std::optional<uint>> mGenerationSeed;
222 ::ll::TypedStorage<1, 1, bool> mbChunkHasConverterTag;
223 ::ll::TypedStorage<1, 1, ::LevelChunk::Neighbors> mSavedNeighbors;
224 ::ll::TypedStorage<1, 1, bool> mClientNeedsToRequestSubChunks;
225 ::ll::TypedStorage<1, 1, bool> mLevelChunkHasHadOriginalLighting;
226 ::ll::TypedStorage<1, 1, bool> mGeneratedPreCavesAndCliffsBlending;
227 ::ll::TypedStorage<1, 1, bool> mOnChunkLoadedCalled;
228 ::ll::TypedStorage<1, 1, bool> mAllSerializedEntitiesLoaded;
229 ::ll::TypedStorage<8, 32, ::std::string> mOutOfBoundsBlockEntitiesBuffer;
230 ::ll::TypedStorage<1, 1, bool> mSaveNonActorDataIfDirty;
231 ::ll::TypedStorage<1, 1, bool> mSaveIfNeverSaved;
232 ::ll::TypedStorage<1, 1, bool> mHasSubChunksToPrune;
233 ::ll::TypedStorage<1, 1, bool> mHaveSubChunksBeenPruned;
234 ::ll::TypedStorage<1, 1, bool> mShouldShiftUpFlatWorldSubChunks;
235 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::std::vector<::SubChunk>>> mSubChunksToPruneOutsideRange;
236 ::ll::TypedStorage<8, 8, ::gsl::not_null<::std::unique_ptr<::Bedrock::LevelChunkTimings>>> mChunkTimings;
237 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::GameEventListenerRegistry>> mGameEventListenerRegistry;
238 ::ll::TypedStorage<4, 4, ::std::atomic<int>> mSnowRandomValue;
239 ::ll::TypedStorage<1, 1, bool> mIsClientGenerated;
240 ::ll::TypedStorage<1, 1, bool> mWasClientGenerated;
241 ::ll::TypedStorage<1, 1, bool> mIsEmptyClientChunk;
242 ::ll::TypedStorage<1, 1, bool> mActorStorageUpdatedAfterCheckingForReplacementData;
243 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mIsTransient;
244 ::ll::TypedStorage<1, 1, bool> mDidSaveJigsawStructureBlueprints;
245 ::ll::TypedStorage<8, 856, ::LevelChunkVolumeData> mLevelChunkVolumeData;
246 ::ll::TypedStorage<8, 24, ::SpinLockImpl> mMoveLockMutex;
247 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mIsBeingMoved;
248 ::ll::TypedStorage<1, 1, ::std::atomic<::LevelChunkCreationMode>> mChunkCreationMode;
253 LevelChunk& operator=(LevelChunk
const&);
254 LevelChunk(LevelChunk
const&);
264 ::SubChunkInitMode initBlocks,
265 bool initializeMetaData,
266 ::LevelChunkBlockActorStorage::TrackingMode blockActorTrackingMode
269 MCAPI
void _addEntityToVolumes(::gsl::not_null<::Actor*> actor);
283 MCAPI
void _fixupCorruptedBlockActors(
289 MCAPI
void _handleHeightmapDataFromSubChunkPacketWithDeserializationChanges(
295 MCAPI
void _lightingCallbacks(
302 MCAPI
void _placeBlockEntity(::std::shared_ptr<::BlockActor> te);
308 MCAPI
void _setAllBiomesFrom2D(::std::array<::BiomeIdType, 256>& legacyBiomes);
314 MCAPI
void addHardcodedSpawningArea(
::BoundingBox const& spawnerAABB, ::HardcodedSpawnAreaType type);
319 MCAPI
void changeState(::ChunkState from, ::ChunkState to);
322 MCAPI
bool checkSeasonsPostProcessDirty()
const;
325 MCAPI
void clearBlockEntitiesInSubChunk(
331 MCAPI
void clientSubChunkRequestGenerateLightingForSubChunk(
::ChunkViewSource& neighborhood,
short absoluteIndex);
333 MCAPI
void deserializeBiomes(
::IDataInput& stream,
bool fromNetwork);
336 MCAPI
void deserializeBlockEntities(
::IDataInput& stream);
338 MCAPI
bool deserializeKey(::std::string_view key, ::std::string_view value);
340 MCAPI
void deserializeMetaDataHash(
::IDataInput& stream);
343 MCAPI
void deserializeSubChunk(
346 ::std::optional<::DeserializationChanges*> deserializationChanges
350 MCAPI
void deserializeSubChunk(
353 ::std::optional<schar> absoluteIndex,
354 ::std::optional<::DeserializationChanges*> deserializationChanges
359 MCAPI
void finalizeDeserialization();
361 MCAPI
void finalizePostProcessing();
363 MCAPI
void finalizeSubChunkDeserialization(
369 MCAPI
bool generateOriginalLighting(
371 bool enforceBorderCheck,
376 MCAPI ::ChunkLocalHeight getAboveTopSolidBlock(
378 bool iteratePastInitialBlocking,
383 MCAPI
void getActors(
386 ::std::vector<::Actor*>& actors
396 MCAPI ::std::array<::ChunkLocalHeight, 256> getEntireLightingHeightMap()
const;
400 getEntities(::ActorType type,
::AABB const& bb, ::std::vector<::Actor*>& es,
bool ignoreTargetType)
const;
402 MCAPI
void getEntities(
403 ::gsl::span<::gsl::not_null<::Actor const*>> ignoredEntities,
405 ::std::vector<::Actor*>& entities,
407 ::std::function<
bool(
::Actor*)> selector
414 MCAPI
short getMaxAllocatedY()
const;
416 MCAPI ::std::shared_ptr<::LevelChunkMetaData> getMetaDataCopy()
const;
419 MCAPI ::SubChunk* getSubChunk(
short absoluteIndex);
422 MCAPI
int getSubChunkCountUpToHighestNonAirBlock()
const;
427 MCAPI
void handleHeightmapDataFromSubChunkPacket(
428 short subChunkAbsoluteIndex,
430 ::std::optional<::DeserializationChanges*> deserializationChanges
436 MCAPI
void moveAssignFrom(::LevelChunk&& otherChunk);
439 MCAPI
void moveLevelChunk(::LevelChunk&& otherChunk, uint64 subChunkRequestLimit);
442 MCAPI
bool nonActorDataNeedsSaving(
int wait,
int maxWait)
const;
444 MCAPI
void onDiscarded();
446 MCAPI
void placeCallbacks(
451 ::std::shared_ptr<::BlockActor> blockEntity,
455 MCAPI
void populateHeightMapDataForSubChunkPacket(
456 short subChunkAbsoluteIndex,
461 MCAPI
void pruneBiomesAboveHeightmap();
463 MCAPI
void recalculateChunkSkyLight();
466 MCAPI
void recomputeHeightMap(
bool resetLighting);
468 MCAPI
void releasePreservedBlockEntities(
::BlockSource& tickRegion);
470 MCAPI ::std::shared_ptr<::BlockActor> removeBlockEntity(
::BlockPos const& blockPos);
476 MCAPI
void removeHardcodedSpawningArea(::HardcodedSpawnAreaType type);
480 MCAPI
void serializeBlockEntitiesForSubChunk(
486 MCAPI
bool serializeBorderBlocks(
::IDataOutput& stream)
const;
488 MCAPI
void serializeEntities(
490 bool markProcessedOnChunkDisard,
491 ::std::function<
void(::std::string
const&)> addLiveActorCallback,
492 ::std::function<
void(::std::string
const&)> addActorKeyCallback,
493 ::std::function<
void(::std::string
const&)> addSerializedActor
496 MCAPI
void serializeEntityRemovals(::std::function<
void(::std::string
const&)> callback);
498 MCAPI
void serializeRandomTicks(
::IDataOutput& stream)
const;
506 MCAPI ::Block
const& setBlock(
510 ::std::shared_ptr<::BlockActor> blockEntity,
516 MCAPI
void setBlockVolume(
::BlockVolume const& box, uint yOffset);
521 MCAPI
void setClientNeedsToRequestSubchunks(::std::optional<uint64> requestLimit);
523 MCAPI
void setEmptyClientChunk();
531 MCAPI
void setPendingEntities(::std::string entitiesData);
533 MCAPI
void setPreWorldGenHeightMap(::std::unique_ptr<::std::vector<short>> heightmap);
541 MCAPI
void tickImpl(
::BlockSource& tickRegion,
::Tick const& tick, ::std::function<
void()> spawnerCallback);
543 MCAPI
bool tryChangeState(::ChunkState from, ::ChunkState to);
545 MCAPI
void validateAndFixBiomeStates();
553 MCAPI static ::std::unique_ptr<::LevelChunk, ::LevelChunkPhase1Deleter> createNew(
557 ::SubChunkInitMode initBlocks,
558 ::LevelChunkBlockActorStorage::TrackingMode blockActorTrackingMode
561 MCAPI static ::std::unique_ptr<::LevelChunk>
562 createNewNoCustomDeleter(
::Dimension& dimension,
::ChunkPos cp,
bool readOnly, ::SubChunkInitMode initBlocks);
564 MCAPI static ::std::pair<ushort, ::std::vector<::std::unique_ptr<::SubChunkStorage<::Biome>>>> deserialize3DBiomes(
567 ushort dimensionHeightInSubchunks,
572 MCAPI static ::std::optional<::BlockPos> findExposedLightningRod(
::BlockPos const& pos,
::BlockSource& region);
575 tuple<::std::array<::ChunkLocalHeight, 256>, ::std::array<::BiomeIdType, 256>, ::std::vector<::SubChunk>>
576 staticDeserializeLegacyTerrain(
::IDataInput& stream,
short minY, ushort dimensionSizeInSubchunks);
586 ::SubChunkInitMode initBlocks,
587 bool initializeMetaData,
588 ::LevelChunkBlockActorStorage::TrackingMode blockActorTrackingMode