LeviLamina
Loading...
Searching...
No Matches
LevelChunk.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/deps/core/container/small_vector.h"
7#include "mc/deps/core/container/small_vector_base.h"
8#include "mc/deps/core/utility/buffer_span.h"
9#include "mc/deps/game_refs/WeakRef.h"
10#include "mc/network/packet/SubChunkPacket.h"
11#include "mc/platform/threading/Mutex.h"
12#include "mc/platform/threading/SharedLock.h"
13#include "mc/platform/threading/SpinLockImpl.h"
14#include "mc/world/actor/ActorType.h"
15#include "mc/world/level/BlockPos.h"
16#include "mc/world/level/ChunkLocalHeight.h"
17#include "mc/world/level/ChunkPos.h"
18#include "mc/world/level/Tick.h"
19#include "mc/world/level/biome/BiomeIdType.h"
20#include "mc/world/level/block/BrightnessPair.h"
21#include "mc/world/level/block/chunk_volume/VolumeOf.h"
22#include "mc/world/level/chunk/ChunkCachedDataState.h"
23#include "mc/world/level/chunk/ChunkDebugDisplaySavedState.h"
24#include "mc/world/level/chunk/ChunkState.h"
25#include "mc/world/level/chunk/ChunkTerrainDataState.h"
26#include "mc/world/level/chunk/ColumnCachedData.h"
27#include "mc/world/level/chunk/DirtyTicksCounter.h"
28#include "mc/world/level/chunk/LevelChunkBiomes.h"
29#include "mc/world/level/chunk/LevelChunkBlockActorStorage.h"
30#include "mc/world/level/chunk/LevelChunkFormat.h"
31#include "mc/world/level/chunk/LevelChunkNeighbor.h"
32#include "mc/world/level/chunk/LevelChunkTag.h"
33#include "mc/world/level/chunk/LevelChunkVolumeData.h"
34#include "mc/world/level/chunk/SubChunkInitMode.h"
35#include "mc/world/level/chunk/SubChunkStorage.h"
36#include "mc/world/level/chunk/level_chunk_ticking/Entity.h"
37#include "mc/world/level/levelgen/structure/BoundingBox.h"
38#include "mc/world/level/levelgen/v1/HardcodedSpawnAreaType.h"
39
40// auto generated forward declare list
41// clang-format off
42class AABB;
43class Actor;
44class Biome;
45class BiomeRegistry;
46class Block;
47class BlockActor;
49class BlockPalette;
50class BlockSource;
52class BlockVolume;
53class ChunkBlockPos;
54class ChunkSource;
55class ChunkViewSource;
56class Dimension;
58class EntityContext;
61class IDataInput;
62class IDataOutput;
63class ILevel;
66class Random;
67class SaveContext;
68class StringByteInput;
70class SubChunkPos;
71class Vec3;
72class WeakEntityRef;
73class Weather;
75struct ActorLink;
76struct ActorUniqueID;
77struct BiomeChunkState;
78struct BlockID;
79struct Brightness;
82struct NibblePair;
83struct SubChunk;
84namespace LevelChunkTicking { struct Registry; }
85// clang-format on
86
87class LevelChunk {
88public:
89 // LevelChunk inner types declare
90 // clang-format off
91 class Neighbors;
92 struct SpawningArea;
93 struct Telemetry;
94 // clang-format on
95
96 // LevelChunk inner types define
97 enum class DeserializeEntityResult : int {
98 FailedToLoadActor = 0,
99 FailedToAddToLevel = 1,
100 Succeeded = 2,
101 };
102
103 enum class Finalization : int {
104 NeedsInstaticking = 0,
105 NeedsPopulation = 1,
106 Done = 2,
107 };
108
109 class Neighbors {
110 public:
111 // member variables
112 // NOLINTBEGIN
113 ::ll::TypedStorage<1, 1, uchar> mNeighbors;
114 // NOLINTEND
115
116 public:
117 // member functions
118 // NOLINTBEGIN
119 MCAPI Neighbors();
120
121 MCAPI explicit Neighbors(::StringByteInput& stream);
122
123 MCFOLD bool hasNeighbor(::LevelChunkNeighbor neighbor) const;
124
125 MCAPI bool isSurrounded() const;
126
127 MCAPI void serialize(::StringByteOutput& stream) const;
128
129 MCFOLD void setNeighbor(::LevelChunkNeighbor neighbor, bool value);
130 // NOLINTEND
131
132 public:
133 // static variables
134 // NOLINTBEGIN
135 MCAPI static ::std::array<::std::pair<::LevelChunkNeighbor, ::ChunkPos>, 8> const& sOffsetMap();
136 // NOLINTEND
137
138 public:
139 // constructor thunks
140 // NOLINTBEGIN
141 MCFOLD void* $ctor();
142
143 MCAPI void* $ctor(::StringByteInput& stream);
144 // NOLINTEND
145 };
146
148 public:
149 // member variables
150 // NOLINTBEGIN
151 ::ll::TypedStorage<4, 24, ::BoundingBox> aabb;
152 ::ll::TypedStorage<1, 1, ::HardcodedSpawnAreaType> type;
153 // NOLINTEND
154 };
155
156 struct Telemetry {
157 public:
158 // member variables
159 // NOLINTBEGIN
160 ::ll::TypedStorage<1, 1, bool> mWasStored;
161 ::ll::TypedStorage<1, 1, bool> mWasGenerated;
162 ::ll::TypedStorage<1, 1, bool> mWasRequestedInsideTickRange;
163 ::ll::TypedStorage<1, 1, bool> mWasLoadedInsideTickRange;
164 // NOLINTEND
165 };
166
167 using BBorder = bool;
168
170
171 using BlockActorVector = ::std::vector<::std::shared_ptr<::BlockActor>>;
172
173public:
174 // member variables
175 // NOLINTBEGIN
176 ::ll::TypedStorage<8, 80, ::Bedrock::Threading::Mutex> mBlockEntityAccessLock;
177 ::ll::TypedStorage<8, 8, ::ILevel&> mLevel;
178 ::ll::TypedStorage<8, 8, ::Dimension&> mDimension;
179 ::ll::TypedStorage<4, 12, ::BlockPos> mMin;
180 ::ll::TypedStorage<4, 12, ::BlockPos> mMax;
181 ::ll::TypedStorage<8, 8, ::ChunkPos> mPosition;
182 ::ll::TypedStorage<1, 1, bool> mLightingFixupDone;
183 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mLightingTaskActive;
184 ::ll::TypedStorage<1, 1, bool> mReadOnly;
185 ::ll::TypedStorage<8, 8, ::ChunkSource*> mGenerator;
186 ::ll::TypedStorage<4, 4, ::LevelChunkTicking::Entity> mTmpTickingEntity;
187 ::ll::TypedStorage<1, 2, ::std::optional<::LevelChunkFormat>> mLoadedFormat;
188 ::ll::TypedStorage<8, 32, ::std::string> mSerializedEntitiesBuffer;
189 ::ll::TypedStorage<8, 32, ::std::string> mFailedSerializedEntitiesBuffer;
190 ::ll::TypedStorage<1, 1, bool> mHadSerializedEntities;
191 ::ll::TypedStorage<8, 24, ::std::vector<::ActorLink>> mUnresolvedActorLinks;
192 ::ll::TypedStorage<1, 1, ::std::atomic<::ChunkState>> mLoadState;
193 ::ll::TypedStorage<1, 1, ::ChunkTerrainDataState> mTerrainDataState;
194 ::ll::TypedStorage<1, 1, ::ChunkDebugDisplaySavedState> mDebugDisplaySavedState;
195 ::ll::TypedStorage<1, 1, ::ChunkCachedDataState> mCachedDataState;
196 ::ll::TypedStorage<8, 24, ::SpinLockImpl> mCachedDataStateSpinLock;
197 ::ll::TypedStorage<8, 24, ::SpinLockImpl> mClientRequestHeightmapAdjustSpinLock;
198 ::ll::TypedStorage<8, 8, ::Tick> mLastTick;
199 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::BlockTickingQueue>> mTickQueue;
200 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::BlockTickingQueue>> mRandomTickQueue;
201 ::ll::TypedStorage<8, 24, ::std::vector<::SubChunk>> mSubChunks;
202 ::ll::TypedStorage<8, 24, ::std::vector<::std::unique_ptr<::SpinLockImpl>>> mSubChunkSpinLocks;
203 ::ll::TypedStorage<8, 552, ::LevelChunkBiomes> mBiomes;
204 ::ll::TypedStorage<4, 2048, ::std::array<::ColumnCachedData, 256>> mCachedData;
205 ::ll::TypedStorage<2, 512, ::std::array<::ChunkLocalHeight, 256>> mHeightmap;
206 ::ll::TypedStorage<2, 512, ::std::array<::ChunkLocalHeight, 256>> mRenderHeightmap;
207 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::std::vector<short>>> mPreWorldGenHeightmap;
208 ::ll::TypedStorage<2, 2, ::ChunkLocalHeight> mNonAirMaxHeight;
209 ::ll::TypedStorage<8, 64, ::std::unordered_map<::BiomeIdType, ::BiomeChunkState>> mBiomeStates;
210 ::ll::TypedStorage<1, 1, bool> mHasCachedTemperatureNoise;
211 ::ll::TypedStorage<1, 256, ::std::array<bool, 256>> mBorderBlockMap;
212 ::ll::TypedStorage<4, 4, int> mCurrentInstatick;
213 ::ll::TypedStorage<4, 4, ::LevelChunk::Finalization> mFinalized;
214 ::ll::TypedStorage<1, 1, bool> mIsRedstoneLoaded;
215 ::ll::TypedStorage<1, 1, bool> mOwnedByTickingThread;
216 ::ll::TypedStorage<1, 1, bool> mUse3DBiomeMaps;
217 ::ll::TypedStorage<1, 1, bool> mLevelChunkHas3dBiomeTag;
218 ::ll::TypedStorage<1, 4, ::LevelChunk::Telemetry> mTelemetry;
219 ::ll::TypedStorage<4, 48, ::DirtyTicksCounter[6]> mFullChunkDirtyTicksCounters;
220 ::ll::TypedStorage<4, 8, ::DirtyTicksCounter> mChunkActorsDirtyTicksCounter;
221 ::ll::TypedStorage<2, 512, ::std::array<::ChunkLocalHeight, 256>> mRainHeights;
222 ::ll::TypedStorage<8, 24, ::std::vector<::WeakEntityRef>> mEntities;
223 ::ll::TypedStorage<8, 24, ::std::vector<::std::string>> mRemovedActorStorageKeys;
224 ::ll::TypedStorage<8, 136, ::LevelChunkBlockActorStorage> mBlockEntities;
225 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::BlockActor>>> mPreservedBlockEntities;
226 ::ll::TypedStorage<8, 24, ::std::vector<::WeakRef<::EntityContext>>> mVolumes;
227 ::ll::TypedStorage<1, 2, ::BrightnessPair> mDefaultBrightness;
228 ::ll::TypedStorage<8, 24, ::std::vector<::LevelChunk::SpawningArea>> mSpawningAreas;
229 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mLastNetworkLightingTime;
230 ::ll::TypedStorage<8, 8, uint64> mLoadedMetaDataHash;
231 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::LevelChunkMetaData>> mMetaData;
232 ::ll::TypedStorage<1, 1, bool> mClientNeedsToRequestSubChunks;
233 ::ll::TypedStorage<1, 1, bool> mLevelChunkHasHadOriginalLighting;
234 ::ll::TypedStorage<4, 16, float[2][2]> mChunkInterpolants;
235 ::ll::TypedStorage<1, 1, bool> mbChunkHasConverterTag;
236 ::ll::TypedStorage<1, 1, ::LevelChunk::Neighbors> mSavedNeighbors;
237 ::ll::TypedStorage<4, 8, ::std::optional<uint>> mGenerationSeed;
238 ::ll::TypedStorage<1, 1, bool> mGeneratedPreCavesAndCliffsBlending;
239 ::ll::TypedStorage<1, 1, bool> mOnChunkLoadedCalled;
240 ::ll::TypedStorage<1, 1, bool> mAllSerializedEntitiesLoaded;
241 ::ll::TypedStorage<8, 32, ::std::string> mOutOfBoundsBlockEntitiesBuffer;
242 ::ll::TypedStorage<1, 1, bool> mSaveNonActorDataIfDirty;
243 ::ll::TypedStorage<1, 1, bool> mSaveIfNeverSaved;
244 ::ll::TypedStorage<4, 4, ::std::atomic<int>> mSnowRandomValue;
245 ::ll::TypedStorage<1, 1, bool> mHasSubChunksToPrune;
246 ::ll::TypedStorage<1, 1, bool> mHaveSubChunksBeenPruned;
247 ::ll::TypedStorage<1, 1, bool> mShouldShiftUpFlatWorldSubChunks;
248 ::ll::TypedStorage<8, 24, ::SpinLockImpl> mSubChunksToPruneLock;
249 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::std::vector<::SubChunk>>> mSubChunksToPruneOutsideRange;
250 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::GameEventListenerRegistry>> mGameEventListenerRegistry;
251 ::ll::TypedStorage<1, 1, bool> mIsClientGenerated;
252 ::ll::TypedStorage<1, 1, bool> mWasClientGenerated;
253 ::ll::TypedStorage<1, 1, bool> mIsEmptyClientChunk;
254 ::ll::TypedStorage<1, 1, bool> mActorStorageUpdatedAfterCheckingForReplacementData;
255 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mIsTransient;
256 ::ll::TypedStorage<8, 856, ::LevelChunkVolumeData> mLevelChunkVolumeData;
257 // NOLINTEND
258
259public:
260 // prevent constructor by default
261 LevelChunk& operator=(LevelChunk const&);
262 LevelChunk(LevelChunk const&);
263 LevelChunk();
264
265public:
266 // member functions
267 // NOLINTBEGIN
268 MCAPI LevelChunk(
269 ::Dimension& dimension,
270 ::ChunkPos const& cp,
271 bool readOnly,
272 ::SubChunkInitMode initBlocks,
273 bool initializeMetaData,
274 ::LevelChunkBlockActorStorage::TrackingMode blockActorTrackingMode
275 );
276
277 MCAPI void _addEntityToVolumes(::gsl::not_null<::Actor*> actor);
278
279#ifdef LL_PLAT_C
280 MCFOLD void _assertChunkLoadedNotCalledAlready() const;
281#endif
282
283 MCAPI void _changeTerrainDataState(::ChunkTerrainDataState, ::ChunkTerrainDataState to);
284
285 MCAPI void _checkAndInferMetaDataAfterDeserialization();
286
287 MCAPI ::std::shared_ptr<::BlockActor> _createBlockEntity(
288 ::BlockPos const& block,
289 ::BlockSource* currentSource,
290 ::Block const& current,
291 ::Block const& old
292 );
293
294 MCAPI void _deserializeBiomes(::IDataInput& stream, ::BiomeRegistry const& biomeRegistry, bool fromNetwork);
295
296 MCAPI void _deserializeBlockEntities(::IDataInput& stream, ::LevelChunkBlockActorStorage& blockEntityMap);
297
298 MCAPI void _deserializeCCsubChunks(short index, ::StringByteInput& stream);
299
300 MCAPI ::LevelChunk::DeserializeEntityResult
301 _deserializeEntity(::BlockSource& source, ::IDataInput& stream, ::std::vector<::ActorLink>& links);
302
303 MCAPI bool _deserializeSubChunk(short index, ::StringByteInput& stream);
304
305 MCAPI void _dispatchBlockBreakEvents(
306 ::BlockPos const& pos,
307 ::Block const& oldBlock,
308 ::Block const& current,
309 ::BlockSource* currentSource,
310 ::BlockChangeContext const& changeSourceContext
311 );
312
313 MCAPI void _fixupCommandBlocksOnTickingQueue(::BlockSource& tickRegion);
314
315 MCAPI void _fixupCorruptedBlockActors(
316 ::LevelChunkBlockActorStorage& deserialized,
318 ) const;
319
320 MCAPI void _generateOriginalLighting(::ChunkViewSource& neighborhood, bool);
321
322 MCAPI void _generateOriginalLightingSubChunk(::BlockSource& source, uint64 subchunkIdx, bool);
323
324 MCFOLD ::ChunkTerrainDataState _getTerrainDataState() const;
325
326#ifdef LL_PLAT_C
327 MCAPI void _handleHeightmapDataFromSubChunkPacketWithDeserializationChanges(
328 short subChunkIndex,
329 ::SubChunkPacket::SubChunkPacketData const& subChunkPacketData
330 );
331#endif
332
333 MCAPI void _lightingCallbacks(
334 ::ChunkBlockPos const& pos,
335 ::Block const& old,
336 ::Block const& current,
337 ::BlockSource* currentSource
338 );
339
340 MCAPI void _onRandomTickingQueueChanged();
341
342 MCAPI void _onTickingQueueChanged();
343
344 MCAPI void _placeBlockEntity(::std::shared_ptr<::BlockActor> te);
345
346 MCAPI void _placeCallbackIfChunkLoaded(
347 ::BlockSource& currentSource,
348 ::BlockPos const& blockPos,
349 ::Block const& old,
350 ::gsl::not_null<::Block const*> current,
351 ::BlockChangeContext const& changeSourceContext
352 );
353
354 MCAPI void
355 _propagateSkyLight(uchar x, uchar z, ::ChunkLocalHeight const& oldFloor, ::ChunkLocalHeight const& newFloor);
356
357 MCAPI void _reassignSubChunks(::buffer_span_mut<::SubChunk> newChunks);
358
359 MCAPI bool _recalcHeight(::ChunkBlockPos const& start, ::BlockSource* source);
360
361 MCAPI void _removeCallbacks(
362 ::ChunkBlockPos const& pos,
363 ::Block const& oldBlock,
364 ::Block const& current,
365 ::BlockSource* currentSource,
366 ::BlockChangeContext const& changeSourceContext
367 );
368
369 MCAPI void _set2DBiomesFrom3D(::IDataInput& stream);
370
371 MCAPI void _setAllBiomesFrom2D(::std::array<::BiomeIdType, 256>& legacyBiomes);
372
373 MCAPI void _setBiome(::Biome const& biome, ::ChunkBlockPos const& pos, bool fillYDimension);
374
375 MCFOLD void _setGenerator(::ChunkSource* generator);
376
377 MCAPI void _tickSnowAndIce(::BlockSource& region, ::Random& random, int xOffset, int zOffset, ::Weather& weather);
378
379 MCAPI void addEntity(::WeakEntityRef entityRef);
380
381 MCAPI void addHardcodedSpawningArea(::BoundingBox const& spawnerAABB, ::HardcodedSpawnAreaType type);
382
383 MCAPI void addSubChunkBlockEntitiesToLevelChunk(::LevelChunkBlockActorStorage& blockActorMap);
384
385 MCAPI bool applySeasonsPostProcess(::BlockSource& region);
386
387 MCAPI void changeState(::ChunkState from, ::ChunkState to);
388
389 MCAPI bool checkSeasonsPostProcessDirty() const;
390
391 MCAPI bool chunkHasConvertedDataTag() const;
392
393#ifdef LL_PLAT_C
394 MCAPI void clearBlockEntitiesInSubChunk(
395 schar absoluteIndex,
396 ::LevelChunkBlockActorStorage const* blockActorMap,
397 ::BlockSource* region
398 );
399#endif
400
401 MCAPI void clearDirtyTickCounters();
402
403 MCAPI void clientSubChunkRequestGenerateLightingForSubChunk(::ChunkViewSource& neighborhood, short absoluteIndex);
404
405 MCAPI void deserialize2DMaps(::IDataInput& stream);
406
407 MCAPI void deserializeBiomeStates(::IDataInput& stream);
408
409 MCAPI void deserializeBiomes(::IDataInput& stream, bool fromNetwork);
410
411 MCAPI void deserializeBlockEntities(::IDataInput& stream);
412
413#ifdef LL_PLAT_C
414 MCAPI void deserializeBorderBlocks(::IDataInput& stream);
415#endif
416
417 MCAPI void deserializeFinalization(::IDataInput& stream);
418
419 MCAPI bool deserializeKey(::std::string_view key, ::std::string_view value);
420
421 MCAPI void deserializeLoadedVersion(::IDataInput& stream);
422
423 MCAPI void deserializeMetaDataHash(::IDataInput& stream);
424
425#ifdef LL_PLAT_C
426 MCAPI void deserializeSubChunk(
427 ::IDataInput& stream,
428 short absoluteIndex,
429 ::std::optional<::DeserializationChanges*> deserializationChanges
430 );
431#endif
432
433 MCAPI void deserializeSubChunk(
434 uchar idx,
435 ::IDataInput& stream,
436 ::std::optional<schar> absoluteIndex,
437 ::std::optional<::DeserializationChanges*> deserializationChanges
438 );
439
440 MCAPI void deserializeSubChunkBlockEntities(::IDataInput& stream, ::LevelChunkBlockActorStorage& blockEntityMap);
441
442 MCAPI void discardPrunedSubChunks();
443
444#ifdef LL_PLAT_C
445 MCAPI bool doesClientNeedToRequestSubchunks() const;
446#endif
447
448 MCFOLD ::LevelChunkBlockActorAccessToken enableBlockEntityAccessForThisThread() const;
449
450 MCAPI void fetchBiomes(::Bedrock::small_vector_base<::gsl::not_null<::Biome const*>>& output) const;
451
452 MCAPI void fetchBlocks(::BlockPos const& volumeOrigin, ::BlockVolume& volume) const;
453
454 MCAPI void finalizeDeserialization();
455
456 MCAPI void finalizePostProcessing();
457
458 MCAPI void finalizeSubChunkDeserialization(
459 ::LevelChunkBlockActorStorage& blockActorMap,
461 );
462
463 MCAPI ::Vec3 findLightningTarget(::BlockPos const& pos, ::BlockSource& region) const;
464
465 MCAPI bool generateOriginalLighting(::ChunkViewSource& neighborhood, bool enforceBorderCheck);
466
467 MCAPI ::ChunkLocalHeight getAboveTopSolidBlock(
468 ::ChunkBlockPos const& start,
469 bool iteratePastInitialBlocking,
470 bool includeWater,
471 bool includeLeaves
472 ) const;
473
474 MCAPI void getActors(
475 ::ActorDefinitionIdentifier const& actorDefinitionId,
476 ::AABB const& bb,
477 ::std::vector<::Actor*>& actors
478 ) const;
479
480 MCAPI ::Biome const& getBiome(::ChunkBlockPos const& pos) const;
481
482#ifdef LL_PLAT_C
483 MCAPI ::std::unique_ptr<::Bedrock::Threading::SharedLock<::std::shared_mutex> const> getBiomesReadLock();
484#endif
485
486 MCAPI ::Block const& getBlock(::ChunkBlockPos const& pos) const;
487
488 MCAPI ::LevelChunkBlockActorStorage const& getBlockEntities() const;
489
490 MCAPI ::BlockActor* getBlockEntity(::ChunkBlockPos const& localPos);
491
492 MCAPI bool getBorder(::ChunkBlockPos const& pos) const;
493
494 MCAPI ::BrightnessPair getBrightness(::ChunkBlockPos const& pos) const;
495
496 MCAPI schar getCachedTemperatureNoise(::ChunkBlockPos const& pos);
497
498 MCAPI ::std::vector<::WeakEntityRef>& getChunkEntities();
499
500 MCFOLD ::Dimension& getDimension() const;
501
502#ifdef LL_PLAT_C
503 MCAPI ::std::array<::ChunkLocalHeight, 256> getEntireLightingHeightMap() const;
504#endif
505
506 MCAPI void getEntities(
507 ::gsl::span<::gsl::not_null<::Actor const*>> ignoredEntities,
508 ::AABB const& bb,
509 ::std::vector<::Actor*>& entities,
510 bool useHitbox
511 ) const;
512
513 MCAPI void
514 getEntities(::ActorType type, ::AABB const& bb, ::std::vector<::Actor*>& es, bool ignoreTargetType) const;
515
516 MCAPI ::Actor* getEntity(::ActorUniqueID const& actorId) const;
517
518 MCAPI ::Block const& getExtraBlock(::ChunkBlockPos const& localPos) const;
519
520 MCAPI ::LevelChunk::Finalization getFinalized() const;
521
522 MCAPI ::GameEventListenerRegistry& getGameEventListenerRegistry() const;
523
524 MCFOLD ::ChunkSource* getGenerator() const;
525
526#ifdef LL_PLAT_C
527 MCAPI int getGrassColor(::ChunkBlockPos const& pos) const;
528#endif
529
530 MCAPI ::DimensionHeightRange const& getHeightRange() const;
531
532 MCAPI short getHeightmap(::ChunkBlockPos const& pos) const;
533
534#ifdef LL_PLAT_C
535 MCAPI ::ChunkLocalHeight getHeightmapLocal(::ChunkBlockPos const& pos) const;
536#endif
537
538 MCAPI short getHighestNonAirSubChunkIndex() const;
539
540 MCAPI float getInterpolant(uint64 x, uint64 y) const;
541
542#ifdef LL_PLAT_C
543 MCAPI ::std::chrono::steady_clock::time_point getLastNetworkLightingTime() const;
544#endif
545
546 MCFOLD ::Tick const& getLastTick() const;
547
548 MCFOLD ::ILevel& getLevel() const;
549
550 MCAPI ::LevelChunkVolumeData& getLevelChunkVolumeData();
551
552 MCAPI ::std::optional<::LevelChunkFormat> getLoadedFormat() const;
553
554 MCAPI ::BlockPos const& getMax() const;
555
556 MCAPI short getMaxAllocatedY() const;
557
558 MCAPI uint64 getMaxSubChunkCnt() const;
559
560 MCAPI short getMaxY() const;
561
562#ifdef LL_PLAT_C
563 MCAPI short getMaxYIndex() const;
564#endif
565
566 MCAPI ::std::shared_ptr<::LevelChunkMetaData const> getMetaData() const;
567
568 MCAPI ::std::shared_ptr<::LevelChunkMetaData> getMetaDataCopy() const;
569
570 MCFOLD ::BlockPos const& getMin() const;
571
572 MCAPI short getMinY() const;
573
574#ifdef LL_PLAT_C
575 MCAPI short getMinYIndex() const;
576#endif
577
578 MCAPI short getNonAirMaxHeight() const;
579
580 MCFOLD ::ChunkPos const& getPosition() const;
581
582 MCAPI ::ChunkLocalHeight getPreWorldGenHeightmap(::ChunkBlockPos const& pos) const;
583
584 MCAPI ::HeightmapWrapper getPreWorldGenHeightmap() const;
585
586 MCAPI ::std::vector<::std::shared_ptr<::BlockActor>> const& getPreservedBlockEntities() const;
587
588 MCFOLD ::BlockTickingQueue& getRandomTickQueue();
589
590 MCAPI ::Brightness getRawBrightness(::ChunkBlockPos const& pos, ::Brightness skyDampen) const;
591
592 MCFOLD ::std::atomic<::ChunkState> const& getState() const;
593
594 MCAPI ::SubChunk const* getSubChunk(short absoluteIndex) const;
595
596 MCAPI ::SubChunk* getSubChunk(short absoluteIndex);
597
598 MCAPI short getSubChunkAbsoluteIndexFromSubChunkIndex(uint64 index) const;
599
600 MCAPI uint64 getSubChunkIndexFromAbsoluteIndex(short absoluteIndex) const;
601
602#ifdef LL_PLAT_C
603 MCAPI ::buffer_span_mut<::SubChunk> getSubChunks(short minIndex, short maxIndex);
604
605 MCAPI ::Biome const& getSurfaceBiome(::BlockPos const& pos) const;
606#endif
607
608 MCAPI ::Biome const& getSurfaceBiome(::ChunkBlockPos pos) const;
609
610 MCFOLD ::BlockTickingQueue const& getTickQueue() const;
611
612 MCFOLD ::BlockTickingQueue& getTickQueue();
613
614 MCAPI ::BlockPos const getTopRainBlockPos(::ChunkBlockPos const& pos);
615
616 MCAPI ::ChunkLocalHeight getTotalAllocatedHeight() const;
617
618#ifdef LL_PLAT_C
619 MCAPI int getWaterColor(::ChunkBlockPos const& pos) const;
620
621 MCAPI void handleHeightmapDataFromSubChunkPacket(
622 short subChunkAbsoluteIndex,
623 ::SubChunkPacket::SubChunkPacketData const& subChunkPacketData,
624 ::std::optional<::DeserializationChanges*> deserializationChanges
625 );
626#endif
627
628 MCAPI bool hasAnyBiomeStates() const;
629
630 MCAPI bool hasBlockEntitiesToSerialize() const;
631
632 MCFOLD bool hasEntitiesPendingToLoad() const;
633
634 MCAPI bool hasEntitiesToSerialize() const;
635
636 MCAPI bool hasEntity(::WeakEntityRef entityRef) const;
637
638 MCAPI bool isAnyBlockEntityDirty() const;
639
640 MCAPI bool isBlockInChunk(::BlockPos const& block) const;
641
642 MCAPI bool isClientGeneratedChunk() const;
643
644 MCAPI bool isEmptyClientChunk() const;
645
646 MCAPI bool isFullyLoaded() const;
647
648 MCAPI bool isNonActorDataDirty() const;
649
650 MCAPI bool isOwnedByTickingThread() const;
651
652 MCAPI bool isReadOnly() const;
653
654 MCAPI bool isSkyLit(::ChunkBlockPos const& pos) const;
655
656#ifdef LL_PLAT_C
657 MCAPI bool isSubChunkHeightWithinRange(short const& subChunkHeight) const;
658#endif
659
660 MCAPI bool isTransient() const;
661
662 MCAPI void legacyDeserializeBlockExtraData(::IDataInput& stream);
663
664 MCAPI void legacyDeserializeTerrain(::IDataInput& stream);
665
666 MCAPI bool levelChunkHad3dBiomeTagOnLastDeserialize() const;
667
668#ifdef LL_PLAT_C
669 MCAPI bool levelChunkHasHadOriginalLighting() const;
670#endif
671
672 MCAPI void markAsTransient();
673
674 MCAPI void markForTickingThisFrame(::LevelChunkTicking::Registry& registry);
675
676 MCAPI void markSaveIfNeverSaved();
677
678 MCAPI void markSaveNonActorDataIfDirty();
679
680 MCAPI bool metaDataDirty() const;
681
682#ifdef LL_PLAT_C
683 MCAPI void moveLevelChunk(::LevelChunk&& otherChunk, uint64 subChunkRequestLimit);
684#endif
685
686 MCAPI bool needsUpgradeFix() const;
687
688 MCAPI bool needsWallFix() const;
689
690 MCAPI bool nonActorDataNeedsSaving(int wait, int maxWait) const;
691
692 MCAPI void onBlockEntityChanged();
693
694 MCAPI void onDiscarded();
695
696 MCAPI void onTickingStarted();
697
698 MCAPI ::LevelChunk& operator=(::LevelChunk&& otherChunk);
699
700 MCAPI void placeCallbacks(
701 ::ChunkBlockPos const& pos,
702 ::Block const& old,
703 ::Block const& current,
704 ::BlockSource* currentSource,
705 ::std::shared_ptr<::BlockActor> blockEntity,
706 ::BlockChangeContext const& changeSourceContext
707 );
708
709 MCAPI void populateHeightMapDataForSubChunkPacket(
710 short subChunkAbsoluteIndex,
711 ::SubChunkPacket::SubChunkPacketData& subChunkPacketData
712 ) const;
713
714 MCAPI void pruneBiomesAboveHeightmap();
715
716 MCAPI void pruneBiomesSubChunk3D(ushort subChunkIndex);
717
718#ifdef LL_PLAT_C
719 MCAPI void recalculateChunkSkyLight();
720#endif
721
722 MCAPI void recalculateSubchunkHashes(bool network);
723
724 MCAPI void recomputeHeightMap(bool resetLighting);
725
726 MCAPI ::std::shared_ptr<::BlockActor> removeBlockEntity(::BlockPos const& blockPos);
727
728 MCAPI bool removeEntityFromChunk(::WeakEntityRef entityRef);
729
730 MCAPI bool removeEntityFromWorld(::WeakEntityRef entityRef);
731
732 MCAPI void removeHardcodedSpawningArea(::HardcodedSpawnAreaType type);
733
734#ifdef LL_PLAT_C
735 MCAPI void resetLightingTaskActive();
736#endif
737
738 MCAPI void serializeBiomeMaps(::IDataOutput& stream) const;
739
740 MCAPI void serializeBiomeStates(::IDataOutput& stream) const;
741
742 MCAPI void serializeBiomes(::IDataOutput& stream) const;
743
744 MCAPI void serializeBlockEntities(::IDataOutput& stream, ::SaveContext const& saveContext) const;
745
746 MCAPI void serializeBlockEntitiesForSubChunk(
747 ::IDataOutput& stream,
748 ::SubChunkPos const& subChunkPos,
749 ::SaveContext const& saveContext
750 ) const;
751
752 MCAPI bool serializeBorderBlocks(::IDataOutput& stream) const;
753
754 MCAPI void serializeEntities(
755 ::std::string& buffer,
756 bool markProcessedOnChunkDisard,
757 ::std::function<void(::std::string const&)> addLiveActorCallback,
758 ::std::function<void(::std::string const&)> addActorKeyCallback,
759 ::std::function<void(::std::string const&)> addSerializedActor
760 ) const;
761
762 MCAPI void serializeEntityRemovals(::std::function<void(::std::string const&)> callback);
763
764 MCAPI void serializeFinalization(::IDataOutput& stream) const;
765
766 MCAPI void serializeMetaDataHash(::IDataOutput& stream) const;
767
768 MCAPI void serializeRandomTicks(::IDataOutput& stream) const;
769
770 MCAPI void serializeTicks(::IDataOutput& stream) const;
771
772 MCAPI void setAllBlockTypeIDAndData(::buffer_span<::BlockID> ids, ::buffer_span<::NibblePair> data);
773
774 MCAPI void setBiome2d(::Biome const& biome, ::ChunkBlockPos const& pos);
775
776 MCAPI void setBiome3d(::Biome const& biome, ::ChunkBlockPos const& pos);
777
778 MCAPI void setBiomeFromVolume(::ChunkVolume::VolumeOf<::Biome> const& volume);
779
780 MCAPI void setBiomeSubChunk3D(::Biome const& biome, ushort subChunkIndex);
781
782 MCAPI ::Block const& setBlock(
783 ::ChunkBlockPos const& pos,
784 ::Block const& block,
785 ::BlockSource* issuingSource,
786 ::std::shared_ptr<::BlockActor> blockEntity,
787 ::BlockChangeContext const& changeSourceContext
788 );
789
790 MCAPI void setBlockSimple(::ChunkBlockPos const& pos, ::Block const& block);
791
792 MCAPI void setBlockVolume(::BlockVolume const& box, uint yOffset);
793
794 MCAPI void setBorder(::ChunkBlockPos const& pos, bool val);
795
796 MCAPI void setCachedTemperatureNoise(::ChunkBlockPos const& pos, schar noiseVal);
797
798 MCAPI void setChunkInterpolants(::LevelChunk::Neighbors const& savedNeighbors);
799
800#ifdef LL_PLAT_C
801 MCAPI void setClientNeedsToRequestSubchunks(::std::optional<uint64> requestLimit);
802
803 MCAPI void setEmptyClientChunk();
804#endif
805
806 MCAPI ::Block const&
807 setExtraBlock(::ChunkBlockPos const& localPos, ::Block const& block, ::BlockSource* issuingSource);
808
809 MCAPI void setExtraBlockSimple(::ChunkBlockPos const& pos, ::Block const& block);
810
811 MCAPI void setFinalized(::LevelChunk::Finalization state);
812
813#ifdef LL_PLAT_C
814 MCAPI void setGrassColor(int grassColor, ::ChunkBlockPos const& pos);
815#endif
816
817 MCAPI void setHadSerializedEntities();
818
819 MCAPI void setIsClientGeneratedChunk(bool isClientGenerated);
820
821#ifdef LL_PLAT_C
822 MCAPI void setLastNetworkLightingTime(::std::chrono::steady_clock::time_point timeToSet);
823#endif
824
825 MCAPI void setMetaData(::std::shared_ptr<::LevelChunkMetaData> metaData);
826
827 MCAPI void setPendingEntities(::std::string entitiesData);
828
829 MCAPI void setPreWorldGenHeightMap(::std::unique_ptr<::std::vector<short>> heightmap);
830
831 MCAPI void setSaved();
832
833 MCAPI void setToSingleBiome(::Biome const& biome);
834
835 MCAPI void setUnsaved();
836
837#ifdef LL_PLAT_C
838 MCAPI void setWaterColor(int waterColor, ::ChunkBlockPos const& pos);
839#endif
840
841 MCAPI void setupRedstoneCircuit(::BlockSource& resource);
842
843 MCAPI bool shouldSaveIfNeverSaved() const;
844
845 MCAPI bool shouldSaveNonActorDataIfDirty() const;
846
847 MCAPI bool subChunkIsSafeReference(::BlockPos const& blockPos) const;
848
849 MCAPI void tick(::BlockSource& tickRegion, ::Tick const& tick);
850
851 MCAPI void tickBlockEntities(::BlockSource& tickRegion);
852
853 MCAPI void tickBlocks(::BlockSource& region);
854
855 MCAPI void tickImpl(::BlockSource& tickRegion, ::Tick const& tick, ::std::function<void()> spawnerCallback);
856
857 MCAPI ::BlockPos toWorldPos(::ChunkBlockPos const& cbp) const;
858
859 MCAPI bool tryChangeState(::ChunkState from, ::ChunkState to);
860
861#ifdef LL_PLAT_C
862 MCAPI bool trySetLightingTaskActive();
863#endif
864
865 MCAPI void trySpawnSkeletonTrap(::BlockSource& region, ::BlockPos const& pos);
866
867 MCAPI void updateLoadedMetaDataHash();
868
869 MCAPI void validateAndFixBiomeStates();
870
871#ifdef LL_PLAT_C
872 MCAPI bool wasEverClientGenerated() const;
873#endif
874
875 MCAPI bool wasTickedThisTick(::Tick const& tick) const;
876
877 MCAPI ~LevelChunk();
878 // NOLINTEND
879
880public:
881 // static functions
882 // NOLINTBEGIN
883 MCAPI static ::std::unique_ptr<::LevelChunk, ::LevelChunkPhase1Deleter> createNew(
884 ::Dimension& dimension,
885 ::ChunkPos cp,
886 bool readOnly,
887 ::SubChunkInitMode initBlocks,
888 ::LevelChunkBlockActorStorage::TrackingMode blockActorTrackingMode
889 );
890
891 MCAPI static ::std::unique_ptr<::LevelChunk>
892 createNewNoCustomDeleter(::Dimension& dimension, ::ChunkPos cp, bool readOnly, ::SubChunkInitMode initBlocks);
893
894 MCAPI static ::std::tuple<::std::array<::ChunkLocalHeight, 256>, ::std::array<::BiomeIdType, 256>>
895 deserialize2DData(::IDataInput& stream, ::std::optional<::LevelChunkFormat> const& lcFormat, bool isClientSide);
896
897 MCAPI static ::std::pair<ushort, ::std::vector<::std::unique_ptr<::SubChunkStorage<::Biome>>>> deserialize3DBiomes(
898 ::IDataInput& stream,
899 ::BiomeRegistry const& biomeRegistry,
900 ushort dimensionHeightInSubchunks,
901 ::Biome const* defaultBiome,
902 bool fromNetwork
903 );
904
905 MCAPI static ::std::tuple<
906 ::std::array<::ChunkLocalHeight, 256>,
907 ushort,
908 ::std::vector<::std::unique_ptr<::SubChunkStorage<::Biome>>>>
909 deserialize3DData(
910 ::IDataInput& stream,
911 ::BiomeRegistry const& biomeRegistry,
912 ushort dimensionHeightInSubchunks,
913 ::Biome const* defaultBiome
914 );
915
916 MCAPI static void deserializeSubChunk(
917 ::IDataInput& stream,
918 ::ChunkPos const& chunkPosition,
919 ::std::optional<schar> absoluteIndex,
920 ::SubChunk& sc,
921 ::BlockPalette& blockPalette,
922 ::std::optional<::DeserializationChanges*> deserializationChanges
923 );
924
925 MCAPI static ::std::optional<::BlockPos> findExposedLightningRod(::BlockPos const& pos, ::BlockSource& region);
926
927 MCAPI static void flushGarbageCollector();
928
929 MCAPI static ::std::pair<::LevelChunkTag, short> getTagAndSubIndexFromKey(::std::string_view key);
930
931 MCAPI static void serializeEntities(
932 ::std::vector<::WeakEntityRef> const& entities,
933 ::std::string const& serializedEntitiesBuffer,
934 ::std::string const& failedSerializedEntitiesBuffer,
935 ::std::string& buffer,
936 bool markProcessedOnChunkDisard,
937 ::std::function<void(::std::string const&)> addLiveActorCallback,
938 ::std::function<void(::std::string const&)> addActorKeyCallback,
939 ::std::function<void(::std::string const&)> addSerializedActor
940 );
941
942 MCAPI static ::std::
943 tuple<::std::array<::ChunkLocalHeight, 256>, ::std::array<::BiomeIdType, 256>, ::std::vector<::SubChunk>>
944 staticDeserializeLegacyTerrain(::IDataInput& stream, short minY, ushort dimensionSizeInSubchunks);
945 // NOLINTEND
946
947public:
948 // constructor thunks
949 // NOLINTBEGIN
950 MCAPI void* $ctor(
951 ::Dimension& dimension,
952 ::ChunkPos const& cp,
953 bool readOnly,
954 ::SubChunkInitMode initBlocks,
955 bool initializeMetaData,
956 ::LevelChunkBlockActorStorage::TrackingMode blockActorTrackingMode
957 );
958 // NOLINTEND
959
960public:
961 // destructor thunk
962 // NOLINTBEGIN
963 MCAPI void $dtor();
964 // NOLINTEND
965};
Definition AABB.h:18
Definition Actor.h:123
Definition small_vector_base.h:8
Definition small_vector.h:8
Definition BiomeRegistry.h:36
Definition Biome.h:24
Definition BlockActor.h:30
Definition BlockChangeContext.h:16
Definition BlockPalette.h:21
Definition BlockPos.h:21
Definition BlockSource.h:72
Definition BlockTickingQueue.h:27
Definition BlockVolume.h:14
Definition Block.h:69
Definition BoundingBox.h:13
Definition ChunkBlockPos.h:10
Definition ChunkLocalHeight.h:5
Definition ChunkPos.h:11
Definition ChunkSource.h:37
Definition ChunkViewSource.h:22
Definition VolumeOf.h:10
Definition DimensionHeightRange.h:5
Definition Dimension.h:88
Definition EntityContext.h:17
Definition GameEventListenerRegistry.h:10
Definition HeightmapWrapper.h:10
Definition IDataInput.h:8
Definition IDataOutput.h:5
Definition ILevel.h:218
Definition LevelChunkBlockActorAccessToken.h:5
Definition LevelChunkBlockActorStorage.h:14
Definition LevelChunkMetaData.h:8
Definition LevelChunk.h:109
Definition Random.h:10
Definition SaveContext.h:5
Definition StringByteInput.h:9
Definition StringByteOutput.h:8
Definition SubChunkPos.h:5
Definition Vec3.h:10
Definition WeakEntityRef.h:14
Definition Weather.h:20
Definition _HeaderOutputPredefine.h:306
Definition buffer_span.h:6
Definition ActorDefinitionIdentifier.h:15
Definition ActorUniqueID.h:10
Definition BiomeChunkState.h:5
Definition BlockID.h:8
Definition Brightness.h:8
Definition DeserializationChanges.h:14
Definition LevelChunkPhase1Deleter.h:10
Definition Registry.h:10
Definition LevelChunk.h:147
Definition LevelChunk.h:156
Definition NibblePair.h:5
Definition SubChunkPacket.h:74
Definition SubChunk.h:28
Definition Tick.h:5
Definition buffer.h:5