89 enum class DeserializeEntityResult :
int {
90 FailedToLoadActor = 0,
91 FailedToAddToLevel = 1,
95 enum class Finalization :
int {
96 NeedsInstaticking = 0,
105 ::ll::TypedStorage<1, 1, uchar> mNeighbors;
111 MCAPI static ::std::array<::std::pair<::LevelChunkNeighbor, ::ChunkPos>, 8>
const& sOffsetMap();
119 ::ll::TypedStorage<4, 24, ::BoundingBox> aabb;
120 ::ll::TypedStorage<1, 1, ::HardcodedSpawnAreaType> type;
128 ::ll::TypedStorage<1, 1, bool> mWasStored;
129 ::ll::TypedStorage<1, 1, bool> mWasGenerated;
130 ::ll::TypedStorage<1, 1, bool> mWasRequestedInsideTickRange;
131 ::ll::TypedStorage<1, 1, bool> mWasLoadedInsideTickRange;
135 using BBorder = bool;
139 using BlockActorVector = ::std::vector<::std::shared_ptr<::BlockActor>>;
144 ::ll::TypedStorage<8, 80, ::Bedrock::Threading::Mutex> mBlockEntityAccessLock;
145 ::ll::TypedStorage<8, 8, ::ILevel&> mLevel;
146 ::ll::TypedStorage<8, 8, ::Dimension&> mDimension;
147 ::ll::TypedStorage<4, 12, ::BlockPos> mMin;
148 ::ll::TypedStorage<4, 12, ::BlockPos> mMax;
149 ::ll::TypedStorage<8, 8, ::ChunkPos> mPosition;
150 ::ll::TypedStorage<1, 1, bool> mLightingFixupDone;
151 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mLightingTaskActive;
152 ::ll::TypedStorage<1, 1, bool> mReadOnly;
153 ::ll::TypedStorage<8, 8, ::ChunkSource*> mGenerator;
154 ::ll::TypedStorage<4, 4, ::LevelChunkTicking::Entity> mTmpTickingEntity;
155 ::ll::TypedStorage<1, 2, ::std::optional<::LevelChunkFormat>> mLoadedFormat;
156 ::ll::TypedStorage<8, 32, ::std::string> mSerializedEntitiesBuffer;
157 ::ll::TypedStorage<8, 32, ::std::string> mFailedSerializedEntitiesBuffer;
158 ::ll::TypedStorage<1, 1, bool> mHadSerializedEntities;
159 ::ll::TypedStorage<8, 24, ::std::vector<::ActorLink>> mUnresolvedActorLinks;
160 ::ll::TypedStorage<1, 1, ::std::atomic<::ChunkState>> mLoadState;
161 ::ll::TypedStorage<1, 1, ::ChunkTerrainDataState> mTerrainDataState;
162 ::ll::TypedStorage<1, 1, ::ChunkDebugDisplaySavedState> mDebugDisplaySavedState;
163 ::ll::TypedStorage<1, 1, ::ChunkCachedDataState> mCachedDataState;
164 ::ll::TypedStorage<8, 24, ::SpinLockImpl> mCachedDataStateSpinLock;
165 ::ll::TypedStorage<8, 24, ::SpinLockImpl> mClientRequestHeightmapAdjustSpinLock;
166 ::ll::TypedStorage<8, 8, ::Tick> mLastTick;
167 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::BlockTickingQueue>> mTickQueue;
168 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::BlockTickingQueue>> mRandomTickQueue;
169 ::ll::TypedStorage<8, 24, ::std::vector<::SubChunk>> mSubChunks;
170 ::ll::TypedStorage<8, 24, ::std::vector<::std::unique_ptr<::SpinLockImpl>>> mSubChunkSpinLocks;
171 ::ll::TypedStorage<8, 24, ::std::vector<::std::unique_ptr<::SubChunkStorage<::Biome>>>> mBiomeSubchunks;
172 ::ll::TypedStorage<2, 512, ::std::array<::BiomeIdType, 256>> m2DBiomes;
173 ::ll::TypedStorage<8, 8, ::std::shared_mutex> mBiomesMutex;
174 ::ll::TypedStorage<4, 2048, ::std::array<::ColumnCachedData, 256>> mCachedData;
175 ::ll::TypedStorage<2, 512, ::std::array<::ChunkLocalHeight, 256>> mHeightmap;
176 ::ll::TypedStorage<2, 512, ::std::array<::ChunkLocalHeight, 256>> mRenderHeightmap;
177 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::std::vector<short>>> mPreWorldGenHeightmap;
178 ::ll::TypedStorage<2, 2, ::ChunkLocalHeight> mNonAirMaxHeight;
179 ::ll::TypedStorage<8, 64, ::std::unordered_map<::BiomeIdType, ::BiomeChunkState>> mBiomeStates;
180 ::ll::TypedStorage<2, 2, ushort> m3dBiomeStackSize;
181 ::ll::TypedStorage<1, 1, bool> mHasCachedTemperatureNoise;
182 ::ll::TypedStorage<1, 256, ::std::array<bool, 256>> mBorderBlockMap;
183 ::ll::TypedStorage<4, 4, int> mCurrentInstatick;
184 ::ll::TypedStorage<4, 4, ::LevelChunk::Finalization> mFinalized;
185 ::ll::TypedStorage<1, 1, bool> mIsRedstoneLoaded;
186 ::ll::TypedStorage<1, 1, bool> mOwnedByTickingThread;
187 ::ll::TypedStorage<1, 1, bool> mUse3DBiomeMaps;
188 ::ll::TypedStorage<1, 1, bool> mLevelChunkHas3dBiomeTag;
189 ::ll::TypedStorage<1, 4, ::LevelChunk::Telemetry> mTelemetry;
190 ::ll::TypedStorage<4, 48, ::DirtyTicksCounter[6]> mFullChunkDirtyTicksCounters;
191 ::ll::TypedStorage<4, 8, ::DirtyTicksCounter> mChunkActorsDirtyTicksCounter;
192 ::ll::TypedStorage<2, 512, ::std::array<::ChunkLocalHeight, 256>> mRainHeights;
193 ::ll::TypedStorage<8, 24, ::std::vector<::WeakEntityRef>> mEntities;
194 ::ll::TypedStorage<8, 24, ::std::vector<::std::string>> mRemovedActorStorageKeys;
195 ::ll::TypedStorage<8, 136, ::LevelChunkBlockActorStorage> mBlockEntities;
196 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::BlockActor>>> mPreservedBlockEntities;
197 ::ll::TypedStorage<8, 24, ::std::vector<::WeakRef<::EntityContext>>> mVolumes;
198 ::ll::TypedStorage<1, 2, ::BrightnessPair> mDefaultBrightness;
199 ::ll::TypedStorage<8, 24, ::std::vector<::LevelChunk::SpawningArea>> mSpawningAreas;
200 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mLastNetworkLightingTime;
201 ::ll::TypedStorage<8, 8, uint64> mLoadedMetaDataHash;
202 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::LevelChunkMetaData>> mMetaData;
203 ::ll::TypedStorage<1, 1, bool> mClientNeedsToRequestSubChunks;
204 ::ll::TypedStorage<1, 1, bool> mLevelChunkHasHadOriginalLighting;
205 ::ll::TypedStorage<4, 16, float[2][2]> mChunkInterpolants;
206 ::ll::TypedStorage<1, 1, bool> mbChunkHasConverterTag;
207 ::ll::TypedStorage<1, 1, ::LevelChunk::Neighbors> mSavedNeighbors;
208 ::ll::TypedStorage<4, 8, ::std::optional<uint>> mGenerationSeed;
209 ::ll::TypedStorage<1, 1, bool> mGeneratedPreCavesAndCliffsBlending;
210 ::ll::TypedStorage<1, 1, bool> mOnChunkLoadedCalled;
211 ::ll::TypedStorage<1, 1, bool> mAllSerializedEntitiesLoaded;
212 ::ll::TypedStorage<8, 32, ::std::string> mOutOfBoundsBlockEntitiesBuffer;
213 ::ll::TypedStorage<1, 1, bool> mSaveNonActorDataIfDirty;
214 ::ll::TypedStorage<1, 1, bool> mSaveIfNeverSaved;
215 ::ll::TypedStorage<4, 4, ::std::atomic<int>> mSnowRandomValue;
216 ::ll::TypedStorage<1, 1, bool> mHasSubChunksToPrune;
217 ::ll::TypedStorage<1, 1, bool> mHaveSubChunksBeenPruned;
218 ::ll::TypedStorage<1, 1, bool> mShouldShiftUpFlatWorldSubChunks;
219 ::ll::TypedStorage<8, 24, ::SpinLockImpl> mSubChunksToPruneLock;
220 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::std::vector<::SubChunk>>> mSubChunksToPruneOutsideRange;
221 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::GameEventListenerRegistry>> mGameEventListenerRegistry;
222 ::ll::TypedStorage<1, 1, bool> mIsClientGenerated;
223 ::ll::TypedStorage<1, 1, bool> mWasClientGenerated;
224 ::ll::TypedStorage<1, 1, bool> mIsEmptyClientChunk;
225 ::ll::TypedStorage<1, 1, bool> mActorStorageUpdatedAfterCheckingForReplacementData;
226 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mIsTransient;
227 ::ll::TypedStorage<8, 856, ::LevelChunkVolumeData> mLevelChunkVolumeData;
232 LevelChunk& operator=(LevelChunk
const&);
233 LevelChunk(LevelChunk
const&);
243 ::SubChunkInitMode initBlocks,
244 bool initializeMetaData,
245 ::LevelChunkBlockActorStorage::TrackingMode blockActorTrackingMode
248 MCAPI
void _addEntityToVolumes(::gsl::not_null<::Actor*> actor);
250 MCAPI
void _checkAndInferMetaDataAfterDeserialization();
252 MCAPI ::std::shared_ptr<::BlockActor> _createBlockEntity(
265 MCAPI ::LevelChunk::DeserializeEntityResult
270 MCAPI
void _dispatchBlockBreakEvents(
278 MCAPI
void _fixupCommandBlocksOnTickingQueue(
::BlockSource& tickRegion);
280 MCAPI
void _fixupCorruptedBlockActors(
285 MCAPI
void _generateOriginalLighting(
::ChunkViewSource& neighborhood,
bool enforceBorderCheck);
287 MCAPI
void _generateOriginalLightingSubChunk(
::BlockSource& source, uint64 subchunkIdx,
bool);
290 MCAPI
void _handleHeightmapDataFromSubChunkPacketWithDeserializationChanges(
296 MCAPI
void _lightingCallbacks(
303 MCAPI
void _makeUniformBiomes(
::Biome const& biome);
305 MCAPI
void _placeBlockEntity(::std::shared_ptr<::BlockActor> te);
309 MCAPI
void _removeCallbacks(
317 MCAPI
void _replaceBiomeStorage(
318 ushort subChunkIndex,
325 MCAPI
void _setAllBiomesFrom2D(::std::array<::BiomeIdType, 256>& legacyBiomes);
329 MCAPI
void _setBiome(
331 ushort subChunkIndex,
340 MCAPI
void addHardcodedSpawningArea(
::BoundingBox const& spawnerAABB, ::HardcodedSpawnAreaType type);
348 MCAPI
bool checkSeasonsPostProcessDirty()
const;
351 MCAPI
void clearBlockEntitiesInSubChunk(
358 MCAPI
void clientSubChunkRequestGenerateLightingForSubChunk(
::ChunkViewSource& neighborhood,
short absoluteIndex);
363 MCAPI
void deserializeBiomes(
::IDataInput& stream,
bool fromNetwork);
366 MCAPI
void deserializeBlockEntities(
::IDataInput& stream);
369 MCAPI
void deserializeBorderBlocks(
::IDataInput& stream);
372 MCAPI
bool deserializeKey(::std::string_view key, ::std::string_view value);
374 MCAPI
void deserializeMetaDataHash(
::IDataInput& stream);
376 MCAPI
void deserializeSubChunk(
379 ::std::optional<schar> absoluteIndex,
380 ::std::optional<::DeserializationChanges*> deserializationChanges
383 MCAPI
void discardPrunedSubChunks();
387 MCAPI
void finalizeDeserialization();
389 MCAPI
void finalizePostProcessing();
393 MCAPI
bool generateOriginalLighting(
::ChunkViewSource& neighborhood,
bool enforceBorderCheck);
395 MCAPI ::ChunkLocalHeight getAboveTopSolidBlock(
397 bool iteratePastInitialBlocking,
402 MCAPI
void getActors(
405 ::std::vector<::Actor*>& actors
408 MCAPI ::buffer_span_mut<::SubChunk> getAllSubChunks();
414 MCAPI ::BrightnessPair getBrightness(
::ChunkBlockPos const& pos)
const;
417 MCAPI ::std::array<::ChunkLocalHeight, 256> getEntireLightingHeightMap()
const;
420 MCAPI
void getEntities(
421 ::gsl::span<::gsl::not_null<::Actor const*>> ignoredEntities,
423 ::std::vector<::Actor*>& entities,
428 getEntities(::ActorType type,
::AABB const& bb, ::std::vector<::Actor*>& es,
bool ignoreTargetType)
const;
430 MCAPI ::Block
const& getExtraBlock(
::ChunkBlockPos const& localPos)
const;
432 MCAPI
short getHighestNonAirSubChunkIndex()
const;
434 MCAPI ::std::shared_ptr<::LevelChunkMetaData> getMetaDataCopy()
const;
439 MCAPI ::SubChunk* getSubChunk(
short absoluteIndex);
442 MCAPI ::SubChunk
const* getSubChunksToPruneOutsideDimensionRange(uint64 index)
const;
447 MCAPI
void handleHeightmapDataFromSubChunkPacket(
448 short subChunkAbsoluteIndex,
450 ::std::optional<::DeserializationChanges*> deserializationChanges
456 MCAPI
bool hasSubChunksToPrune()
const;
458 MCAPI
bool isNonActorDataDirty()
const;
460 MCAPI
void legacyDeserializeBlockExtraData(
::IDataInput& stream);
462 MCAPI
void legacyDeserializeTerrain(
::IDataInput& stream);
466 MCAPI ::LevelChunk& operator=(::LevelChunk&& otherChunk);
468 MCAPI
void placeCallbacks(
473 ::std::shared_ptr<::BlockActor> blockEntity,
477 MCAPI
void populateHeightMapDataForSubChunkPacket(
478 short subChunkAbsoluteIndex,
483 MCAPI
void recalculateChunkSkyLight();
486 MCAPI
void recomputeHeightMap(
bool resetLighting);
488 MCAPI ::std::shared_ptr<::BlockActor> removeBlockEntity(
::BlockPos const& blockPos);
494 MCAPI
void removeHardcodedSpawningArea(::HardcodedSpawnAreaType type);
496 MCAPI
void serializeBiomeStates(
::IDataOutput& stream)
const;
502 MCAPI
void serializeBlockEntitiesForSubChunk(
508 MCAPI
bool serializeBorderBlocks(
::IDataOutput& stream)
const;
510 MCAPI
void serializeEntities(
512 bool markProcessedOnChunkDisard,
513 ::std::function<
void(::std::string
const&)> addLiveActorCallback,
514 ::std::function<
void(::std::string
const&)> addActorKeyCallback,
515 ::std::function<
void(::std::string
const&)> addSerializedActor
518 MCAPI
void serializeEntityRemovals(::std::function<
void(::std::string
const&)> callback);
528 MCAPI ::Block
const& setBlock(
532 ::std::shared_ptr<::BlockActor> blockEntity,
538 MCAPI
void setBlockVolume(
::BlockVolume const& box, uint yOffset);
541 MCAPI
void setClientNeedsToRequestSubchunks(::std::optional<uint64> requestLimit);
547 MCAPI
void setMetaData(::std::shared_ptr<::LevelChunkMetaData> metaData);
549 MCAPI
void setPendingEntities(::std::string entitiesData);
551 MCAPI
void setPreWorldGenHeightMap(::std::unique_ptr<::std::vector<short>> heightmap);
553 MCAPI
void setSaved();
555 MCAPI
void setUnsaved();
563 MCAPI
void tickImpl(
::BlockSource& tickRegion,
::Tick const& tick, ::std::function<
void()> spawnerCallback);
568 MCAPI
void updateLoadedMetaDataHash();
571 MCAPI
void validateAndFixBiomeStates();
580 MCAPI static ::std::unique_ptr<::LevelChunk, ::LevelChunkPhase1Deleter> createNew(
584 ::SubChunkInitMode initBlocks,
585 ::LevelChunkBlockActorStorage::TrackingMode blockActorTrackingMode
588 MCAPI static ::std::unique_ptr<::LevelChunk>
589 createNewNoCustomDeleter(
::Dimension& dimension,
::ChunkPos cp,
bool readOnly, ::SubChunkInitMode initBlocks);
592 MCAPI static ::std::tuple<::std::array<::ChunkLocalHeight, 256>, ::std::array<::BiomeIdType, 256>>
593 deserialize2DData(
::IDataInput& stream, ::std::optional<::LevelChunkFormat>
const& lcFormat,
bool isClientSide);
595 MCAPI static ::std::pair<ushort, ::std::vector<::std::unique_ptr<::SubChunkStorage<::Biome>>>> deserialize3DBiomes(
598 ushort dimensionHeightInSubchunks,
603 MCAPI static ::std::optional<::BlockPos> findExposedLightningRod(
::BlockPos const& pos,
::BlockSource& region);
605 MCAPI
static void serializeEntities(
606 ::std::vector<::WeakEntityRef>
const& entities,
607 ::std::string
const& serializedEntitiesBuffer,
608 ::std::string
const& failedSerializedEntitiesBuffer,
610 bool markProcessedOnChunkDisard,
611 ::std::function<
void(::std::string
const&)> addLiveActorCallback,
612 ::std::function<
void(::std::string
const&)> addActorKeyCallback,
613 ::std::function<
void(::std::string
const&)> addSerializedActor
617 tuple<::std::array<::ChunkLocalHeight, 256>, ::std::array<::BiomeIdType, 256>, ::std::vector<::SubChunk>>
618 staticDeserializeLegacyTerrain(
::IDataInput& stream,
short minY, ushort dimensionSizeInSubchunks);
628 ::SubChunkInitMode initBlocks,
629 bool initializeMetaData,
630 ::LevelChunkBlockActorStorage::TrackingMode blockActorTrackingMode