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>>;
141 using BlockList = ::std::vector<::BlockPos>;
146 ::ll::TypedStorage<8, 80, ::Bedrock::Threading::Mutex> mBlockEntityAccessLock;
147 ::ll::TypedStorage<8, 8, ::ILevel&> mLevel;
148 ::ll::TypedStorage<8, 8, ::Dimension&> mDimension;
149 ::ll::TypedStorage<4, 12, ::BlockPos> mMin;
150 ::ll::TypedStorage<4, 12, ::BlockPos> mMax;
151 ::ll::TypedStorage<8, 8, ::ChunkPos> mPosition;
152 ::ll::TypedStorage<1, 1, bool> mLightingFixupDone;
153 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mLightingTaskActive;
154 ::ll::TypedStorage<1, 1, bool> mReadOnly;
155 ::ll::TypedStorage<8, 8, ::ChunkSource*> mGenerator;
156 ::ll::TypedStorage<4, 4, ::LevelChunkTicking::Entity> mTmpTickingEntity;
157 ::ll::TypedStorage<1, 2, ::std::optional<::LevelChunkFormat>> mLoadedFormat;
158 ::ll::TypedStorage<8, 32, ::std::string> mSerializedEntitiesBuffer;
159 ::ll::TypedStorage<8, 32, ::std::string> mFailedSerializedEntitiesBuffer;
160 ::ll::TypedStorage<1, 1, bool> mHadSerializedEntities;
161 ::ll::TypedStorage<8, 24, ::std::vector<::ActorLink>> mUnresolvedActorLinks;
162 ::ll::TypedStorage<1, 1, ::std::atomic<::ChunkState>> mLoadState;
163 ::ll::TypedStorage<1, 1, ::ChunkTerrainDataState> mTerrainDataState;
164 ::ll::TypedStorage<1, 1, ::ChunkDebugDisplaySavedState> mDebugDisplaySavedState;
165 ::ll::TypedStorage<1, 1, ::ChunkCachedDataState> mCachedDataState;
166 ::ll::TypedStorage<8, 32, ::SpinLockImpl> mCachedDataStateSpinLock;
167 ::ll::TypedStorage<8, 32, ::SpinLockImpl> mClientRequestHeightmapAdjustSpinLock;
168 ::ll::TypedStorage<8, 8, ::Tick> mLastTick;
169 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::BlockTickingQueue>> mTickQueue;
170 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::BlockTickingQueue>> mRandomTickQueue;
171 ::ll::TypedStorage<8, 24, ::std::vector<::SubChunk>> mSubChunks;
172 ::ll::TypedStorage<8, 24, ::std::vector<::std::unique_ptr<::SpinLockImpl>>> mSubChunkSpinLocks;
173 ::ll::TypedStorage<8, 24, ::std::vector<::std::unique_ptr<::SubChunkStorage<::Biome>>>> mBiomes;
174 ::ll::TypedStorage<2, 512, ::std::array<::BiomeChunkData, 256>> m2DBiomes;
175 ::ll::TypedStorage<8, 8, ::std::shared_mutex> mBiomesMutex;
176 ::ll::TypedStorage<4, 2048, ::std::array<::ColumnCachedData, 256>> mCachedData;
177 ::ll::TypedStorage<2, 512, ::std::array<::ChunkLocalHeight, 256>> mHeightmap;
178 ::ll::TypedStorage<2, 512, ::std::array<::ChunkLocalHeight, 256>> mRenderHeightmap;
179 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::std::vector<short>>> mPreWorldGenHeightmap;
180 ::ll::TypedStorage<2, 2, ::ChunkLocalHeight> mNonAirMaxHeight;
181 ::ll::TypedStorage<8, 64, ::std::unordered_map<::BiomeIdType, ::BiomeChunkState>> mBiomeStates;
182 ::ll::TypedStorage<2, 2, ushort> m3dBiomeStackSize;
183 ::ll::TypedStorage<1, 1, bool> mHasCachedTemperatureNoise;
184 ::ll::TypedStorage<1, 256, ::std::array<bool, 256>> mBorderBlockMap;
185 ::ll::TypedStorage<4, 4, int> mCurrentInstatick;
186 ::ll::TypedStorage<4, 4, ::LevelChunk::Finalization> mFinalized;
187 ::ll::TypedStorage<1, 1, bool> mIsRedstoneLoaded;
188 ::ll::TypedStorage<1, 1, bool> mOwnedByTickingThread;
189 ::ll::TypedStorage<1, 1, bool> mUse3DBiomeMaps;
190 ::ll::TypedStorage<1, 1, bool> mLevelChunkHas3dBiomeTag;
191 ::ll::TypedStorage<1, 4, ::LevelChunk::Telemetry> mTelemetry;
192 ::ll::TypedStorage<4, 48, ::DirtyTicksCounter[6]> mFullChunkDirtyTicksCounters;
193 ::ll::TypedStorage<4, 8, ::DirtyTicksCounter> mChunkActorsDirtyTicksCounter;
194 ::ll::TypedStorage<2, 512, ::std::array<::ChunkLocalHeight, 256>> mRainHeights;
195 ::ll::TypedStorage<8, 24, ::std::vector<::WeakEntityRef>> mEntities;
196 ::ll::TypedStorage<8, 24, ::std::vector<::std::string>> mRemovedActorStorageKeys;
197 ::ll::TypedStorage<8, 136, ::LevelChunkBlockActorStorage> mBlockEntities;
198 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::BlockActor>>> mPreservedBlockEntities;
199 ::ll::TypedStorage<8, 24, ::std::vector<::WeakRef<::EntityContext>>> mVolumes;
200 ::ll::TypedStorage<1, 2, ::BrightnessPair> mDefaultBrightness;
201 ::ll::TypedStorage<8, 24, ::std::vector<::LevelChunk::SpawningArea>> mSpawningAreas;
202 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mLastNetworkLightingTime;
203 ::ll::TypedStorage<8, 8, uint64> mLoadedMetaDataHash;
204 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::LevelChunkMetaData>> mMetaData;
205 ::ll::TypedStorage<1, 1, bool> mClientNeedsToRequestSubChunks;
206 ::ll::TypedStorage<1, 1, bool> mLevelChunkHasHadOriginalLighting;
207 ::ll::TypedStorage<4, 16, float[2][2]> mChunkInterpolants;
208 ::ll::TypedStorage<1, 1, bool> mbChunkHasConverterTag;
209 ::ll::TypedStorage<1, 1, ::LevelChunk::Neighbors> mSavedNeighbors;
210 ::ll::TypedStorage<4, 8, ::std::optional<uint>> mGenerationSeed;
211 ::ll::TypedStorage<1, 1, bool> mGeneratedPreCavesAndCliffsBlending;
212 ::ll::TypedStorage<1, 1, bool> mOnChunkLoadedCalled;
213 ::ll::TypedStorage<1, 1, bool> mAllSerializedEntitiesLoaded;
214 ::ll::TypedStorage<8, 32, ::std::string> mOutOfBoundsEntitiesBuffer;
215 ::ll::TypedStorage<8, 32, ::std::string> mOutOfBoundsBlockEntitiesBuffer;
216 ::ll::TypedStorage<1, 1, bool> mSaveNonActorDataIfDirty;
217 ::ll::TypedStorage<1, 1, bool> mSaveIfNeverSaved;
218 ::ll::TypedStorage<4, 4, ::std::atomic<int>> mSnowRandomValue;
219 ::ll::TypedStorage<1, 1, bool> mHasSubChunksToPrune;
220 ::ll::TypedStorage<1, 1, bool> mHaveSubChunksBeenPruned;
221 ::ll::TypedStorage<1, 1, bool> mShouldShiftUpFlatWorldSubChunks;
222 ::ll::TypedStorage<8, 32, ::SpinLockImpl> mSubChunksToPruneLock;
223 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::std::vector<::SubChunk>>> mSubChunksToPruneOutsideRange;
224 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::GameEventListenerRegistry>> mGameEventListenerRegistry;
225 ::ll::TypedStorage<1, 1, bool> mIsClientGenerated;
226 ::ll::TypedStorage<1, 1, bool> mWasClientGenerated;
227 ::ll::TypedStorage<1, 1, bool> mIsEmptyClientChunk;
228 ::ll::TypedStorage<1, 1, bool> mActorStorageUpdatedAfterCheckingForReplacementData;
229 ::ll::TypedStorage<8, 856, ::LevelChunkVolumeData> mLevelChunkVolumeData;
234 LevelChunk& operator=(LevelChunk
const&);
235 LevelChunk(LevelChunk
const&);
245 ::SubChunkInitMode initBlocks,
246 bool initializeMetaData,
247 ::LevelChunkBlockActorStorage::TrackingMode blockActorTrackingMode
250 MCAPI
void _addEntityToVolumes(::gsl::not_null<::Actor*> actor);
252 MCAPI
void _checkAndInferMetaDataAfterDeserialization();
254 MCAPI ::std::shared_ptr<::BlockActor> _createBlockEntity(
267 MCAPI ::LevelChunk::DeserializeEntityResult
272 MCAPI
void _dispatchBlockBreakEvents(
280 MCAPI
void _fixupCommandBlocksOnTickingQueue(
::BlockSource& tickRegion);
285 MCAPI
void _generateOriginalLighting(
::ChunkViewSource& neighborhood,
bool enforceBorderCheck);
287 MCAPI
void _generateOriginalLightingSubChunk(
::BlockSource& source, uint64 subchunkIdx,
bool);
289 MCAPI_C
void _handleHeightmapDataFromSubChunkPacketWithDeserializationChanges(
294 MCAPI
void _lightingCallbacks(
301 MCAPI
void _makeUniformBiomes(
::Biome const& biome);
303 MCAPI
void _placeBlockEntity(::std::shared_ptr<::BlockActor> te);
307 MCAPI
void _removeCallbacks(
315 MCAPI
void _replaceBiomeStorage(
316 ushort subChunkIndex,
323 MCAPI
void _setAllBiomesFrom2D(::std::array<::BiomeChunkData, 256>& legacyBiomes);
327 MCAPI
void _setBiome(
329 ushort subChunkIndex,
338 MCAPI
void addHardcodedSpawningArea(
::BoundingBox const& spawnerAABB, ::HardcodedSpawnAreaType type);
344 MCAPI
bool checkSeasonsPostProcessDirty();
346 MCAPI_C
void clearBlockEntitiesInSubChunk(schar absoluteIndex);
348 MCAPI
void clientSubChunkRequestGenerateLightingForSubChunk(
::ChunkViewSource& neighborhood,
short absoluteIndex);
352 MCAPI_C
void deserializeBiomes(
::IDataInput& stream,
bool fromNetwork);
354 MCAPI
void deserializeBlockEntities(
::IDataInput& stream);
356 MCAPI_C
void deserializeBorderBlocks(
::IDataInput& stream);
358 MCAPI
bool deserializeKey(::std::string_view key, ::std::string_view value);
360 MCAPI
void deserializeMetaDataHash(
::IDataInput& stream);
362 MCAPI
void deserializeSubChunk(
365 ::std::optional<schar> absoluteIndex,
366 ::std::optional<::DeserializationChanges*> deserializationChanges
369 MCAPI
void discardPrunedSubChunks();
375 MCAPI
void finalizeDeserialization();
377 MCAPI
void finalizePostProcessing();
383 MCAPI
bool generateOriginalLighting(
::ChunkViewSource& neighborhood,
bool enforceBorderCheck);
385 MCAPI ::ChunkLocalHeight getAboveTopSolidBlock(
387 bool iteratePastInitialBlocking,
392 MCAPI
void getActors(
395 ::std::vector<::Actor*>& actors
398 MCAPI ::buffer_span_mut<::SubChunk> getAllSubChunks();
404 MCAPI ::BrightnessPair getBrightness(
::ChunkBlockPos const& pos)
const;
406 MCAPI_C ::std::array<::ChunkLocalHeight, 256> getEntireLightingHeightMap()
const;
408 MCAPI
void getEntities(
409 ::gsl::span<::gsl::not_null<::Actor const*>> ignoredEntities,
411 ::std::vector<::Actor*>& entities,
416 getEntities(::ActorType type,
::AABB const& bb, ::std::vector<::Actor*>& es,
bool ignoreTargetType)
const;
418 MCAPI ::Block
const& getExtraBlock(
::ChunkBlockPos const& localPos)
const;
420 MCAPI
short getHighestNonAirSubChunkIndex()
const;
422 MCAPI ::std::shared_ptr<::LevelChunkMetaData> getMetaDataCopy()
const;
426 MCAPI_C ::SubChunk* getSubChunk(
short absoluteIndex);
428 MCAPI ::SubChunk* getSubChunksToPruneOutsideDimensionRange(uint64 index);
432 MCAPI_C
void handleHeightmapDataFromSubChunkPacket(
433 short subChunkAbsoluteIndex,
435 ::std::optional<::DeserializationChanges*> deserializationChanges
440 MCAPI
bool hasSubChunksToPrune()
const;
442 MCAPI
bool isNonActorDataDirty()
const;
444 MCAPI
void legacyDeserializeBlockExtraData(
::IDataInput& stream);
446 MCAPI
void legacyDeserializeTerrain(
::IDataInput& stream);
450 MCAPI ::LevelChunk& operator=(::LevelChunk&& otherChunk);
452 MCAPI
void placeCallbacks(
457 ::std::shared_ptr<::BlockActor> blockEntity
460 MCAPI
void populateHeightMapDataForSubChunkPacket(
461 short subChunkAbsoluteIndex,
465 MCAPI_C
void recalculateChunkSkyLight();
467 MCAPI
void recomputeHeightMap(
bool resetLighting);
473 MCAPI
void removeHardcodedSpawningArea(::HardcodedSpawnAreaType type);
475 MCAPI
void serializeBiomeStates(
::IDataOutput& stream)
const;
481 MCAPI
void serializeBlockEntitiesForSubChunk(
487 MCAPI
bool serializeBorderBlocks(
::IDataOutput& stream)
const;
489 MCAPI
void serializeEntities(
491 bool markProcessedOnChunkDisard,
492 ::std::function<
void(::std::string
const&)> addLiveActorCallback,
493 ::std::function<
void(::std::string
const&)> addActorKeyCallback,
494 ::std::function<
void(::std::string
const&)> addSerializedActor
497 MCAPI
void serializeEntityRemovals(::std::function<
void(::std::string
const&)> callback);
505 MCAPI ::Block
const& setBlock(
509 ::std::shared_ptr<::BlockActor> blockEntity,
515 MCAPI
void setBlockVolume(
::BlockVolume const& box, uint yOffset);
517 MCAPI_C
void setClientNeedsToRequestSubchunks(::std::optional<uint64> requestLimit);
522 MCAPI
void setMetaData(::std::shared_ptr<::LevelChunkMetaData> metaData);
524 MCAPI
void setPendingEntities(::std::string entitiesData);
526 MCAPI
void setPreWorldGenHeightMap(::std::unique_ptr<::std::vector<short>> heightmap);
528 MCAPI
void setSaved();
530 MCAPI
void setUnsaved();
538 MCAPI
void tickImpl(
::BlockSource& tickRegion,
::Tick const& tick, ::std::function<
void()> spawnerCallback);
542 MCAPI
void validateAndFixBiomeStates();
550 MCAPI_C static ::std::unique_ptr<::LevelChunk>
551 createNewNoCustomDeleter(
::Dimension& dimension,
::ChunkPos cp,
bool readOnly, ::SubChunkInitMode initBlocks);
553 MCAPI static ::std::tuple<::std::array<::ChunkLocalHeight, 256>, ::std::array<::BiomeChunkData, 256>>
554 deserialize2DData(
::IDataInput& stream, ::std::optional<::LevelChunkFormat>
const& lcFormat,
bool isClientSide);
556 MCAPI static ::std::pair<ushort, ::std::vector<::std::unique_ptr<::SubChunkStorage<::Biome>>>> deserialize3DBiomes(
559 ushort dimensionHeightInSubchunks,
564 MCAPI
static void serializeEntities(
565 ::std::vector<::WeakEntityRef>
const& entities,
566 ::std::string
const& serializedEntitiesBuffer,
567 ::std::string
const& failedSerializedEntitiesBuffer,
569 bool markProcessedOnChunkDisard,
570 ::std::function<
void(::std::string
const&)> addLiveActorCallback,
571 ::std::function<
void(::std::string
const&)> addActorKeyCallback,
572 ::std::function<
void(::std::string
const&)> addSerializedActor
576 tuple<::std::array<::ChunkLocalHeight, 256>, ::std::array<::BiomeChunkData, 256>, ::std::vector<::SubChunk>>
577 staticDeserializeLegacyTerrain(
::IDataInput& stream,
short minY, ushort dimensionSizeInSubchunks);
587 ::SubChunkInitMode initBlocks,
588 bool initializeMetaData,
589 ::LevelChunkBlockActorStorage::TrackingMode blockActorTrackingMode