LeviLamina
Loading...
Searching...
No Matches
SubChunk.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/platform/brstd/function_ref.h"
7#include "mc/world/level/BlockDataFetchResult.h"
8#include "mc/world/level/chunk/DirtyTicksCounter.h"
9#include "mc/world/level/chunk/SubChunkBrightnessStorage.h"
10#include "mc/world/level/chunk/SubChunkStorage.h"
11#include "mc/world/level/chunk/sub_chunk_storage_unit/PruneType.h"
12
13// auto generated forward declare list
14// clang-format off
15class Block;
16class BlockPalette;
17class BlockPos;
18class BlockVolume;
19class BoundingBox;
20class IDataInput;
21class IDataOutput;
22class SpinLockImpl;
24class SubChunkPos;
26// clang-format on
27
28struct SubChunk {
29public:
30 // SubChunk inner types define
31 enum class BlockLayer : uchar {
32 Standard = 0,
33 Extra = 1,
34 Count = 2,
35 };
36
37 enum class SubChunkState : int {
38 Invalid = -1,
39 Normal = 0,
40 IsLightingSystemSubChunk = 1,
41 NeedsRequest = 2,
42 ReceivedResponseFromServer = 3,
43 ProcessingSubChunk = 4,
44 WaitingForCacheResponse = 5,
45 ProcessedSubChunk = 6,
46 RequestFinished = 7,
47 };
48
49 using Layer = uchar;
50
51public:
52 // member variables
53 // NOLINTBEGIN
54 ::ll::TypedStorage<4, 8, ::DirtyTicksCounter> mDirtyTicksCounter;
55 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::SubChunkBrightnessStorage>> mSkyLight;
56 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::SubChunkBrightnessStorage>> mBlockLight;
57 ::ll::TypedStorage<4, 4, ::SubChunk::SubChunkState> mSubChunkState;
58 ::ll::TypedStorage<1, 1, bool> mHasMaxSkyLight;
59 ::ll::TypedStorage<1, 1, bool> mNeedsInitLighting;
60 ::ll::TypedStorage<1, 1, bool> mNeedsClientLighting;
61 ::ll::TypedStorage<8, 16, ::std::unique_ptr<::SubChunkStorage<::Block>>[2]> mBlocks;
62 ::ll::TypedStorage<8, 16, ::SubChunkStorage<::Block>* [2]> mBlocksReadPtr;
63 ::ll::TypedStorage<8, 8, ::SpinLockImpl*> mWriteLock;
64 ::ll::TypedStorage<8, 8, uint64> mHash;
65 ::ll::TypedStorage<1, 1, bool> mHashDirty;
66 ::ll::TypedStorage<1, 1, schar> mAbsoluteIndex;
67 ::ll::TypedStorage<1, 1, bool> mIsReplacementSubChunk;
68 ::ll::TypedStorage<1, 1, uchar> mRenderChunkTrackingVersionNumber;
69 // NOLINTEND
70
71public:
72 // prevent constructor by default
73 SubChunk& operator=(SubChunk const&);
74 SubChunk(SubChunk const&);
75
76public:
77 // member functions
78 // NOLINTBEGIN
79 MCAPI SubChunk();
80
81 MCAPI SubChunk(::SubChunk&& rhs);
82
83 MCAPI
84 SubChunk(::Block const* initBlock, bool maxSkyLight, bool fullyLit, ::SpinLockImpl& spinLock, schar absoluteIndex);
85
86 MCAPI ::std::unique_ptr<::SubChunkStorage<::Block>> _compareSubChunkStorageForLightingFixUp(
87 uchar layer,
88 ::SubChunkPos const& subChunkPos,
89 ::std::unique_ptr<::SubChunkStorage<::Block>> newStorage,
90 ::DeserializationChanges& deserializationChanges
91 );
92
93#ifdef LL_PLAT_C
94 MCAPI void _createBlockLightStorage();
95
96 MCAPI void _createSkyLightStorage();
97#endif
98
99#ifdef LL_PLAT_S
100 MCAPI void _resetLight(bool maxSkyLight, bool maxLight);
101#endif
102
103 MCAPI void _setBlock(uchar layer, ushort index, ::Block const& block);
104
105 MCAPI void deserialize(
106 ::IDataInput& stream,
107 ::BlockPalette const& palette,
108 ::SubChunkPos const& subChunkPos,
109 ::std::optional<::DeserializationChanges*> deserializationChanges
110 );
111
112 MCAPI void fetchBlocks(
113 ::BlockPos const& subChunkOrigin,
114 ::BlockPos const& volumeOrigin,
115 short dimensionMinHeight,
116 ::BlockVolume& volume
117 ) const;
118
119 MCAPI void fetchBlocksInBox(
120 ::BlockPos const& positionOfChunk,
121 ::BoundingBox const& box,
122 ::brstd::function_ref<bool(::Block const&)> const& predicate,
123 ::std::vector<::BlockDataFetchResult<::Block>>& output
124 ) const;
125
126 MCAPI void fetchBlocksInCylinder(
127 ::BlockPos const& positionOfChunk,
128 ::BlockPos const& pos,
129 uint radius,
130 uint height,
131 ::brstd::function_ref<bool(::Block const&)> const& predicate,
132 ::std::vector<::BlockDataFetchResult<::Block>>& output
133 ) const;
134
135 MCFOLD schar getAbsoluteIndex() const;
136
137 MCAPI ::Block const& getBlock(ushort index) const;
138
139 MCAPI ::Block const& getExtraBlock(ushort index) const;
140
141 MCAPI ::SubChunkBrightnessStorage::LightPair getLight(ushort idx) const;
142
143#ifdef LL_PLAT_C
144 MCFOLD ::SpinLockImpl& getLock() const;
145
146 MCAPI uchar getRenderChunkTrackingVersionNumber() const;
147#endif
148
149 MCFOLD ::SubChunk::SubChunkState getSubChunkState() const;
150
151 MCAPI bool hasAnyBlockMatchingFilter(::std::function<bool(::Block const&)> const& predicate) const;
152
153 MCAPI void initialize(
154 ::Block const* initBlock,
155 bool maxSkyLight,
156 bool fullyLit,
157 ::SpinLockImpl& spinLock,
158 schar absoluteIndex
159 );
160
161 MCAPI bool isEmpty() const;
162
163 MCAPI bool isEmpty(::SubChunk::BlockLayer layer) const;
164
165 MCAPI bool isPaletteUniform(::Block const& block) const;
166
167 MCAPI bool isPlaceHolderSubChunk() const;
168
169 MCAPI bool isReadPtrEmpty(::SubChunk::BlockLayer layer) const;
170
171 MCFOLD bool isReplacementSubChunk() const;
172
173 MCAPI bool isUniform(::Block const& block) const;
174
175 MCFOLD bool likelyHasNonUniformBlockLight() const;
176
177#ifdef LL_PLAT_C
178 MCFOLD bool needsClientLighting() const;
179#endif
180
181 MCFOLD bool needsInitLighting() const;
182
183 MCAPI ::SubChunk& operator=(::SubChunk&& rhs);
184
185 MCAPI void prune();
186
187 MCAPI void prune(::SubChunkStorageUnit::PruneType pruneType);
188
189 MCAPI void recalculateHash(bool network);
190
191 MCAPI ::std::string recalculateHashAndSerialize(bool network);
192
193 MCAPI void reset(::Block const* resetBlock, bool maxSkyLight, bool fullyLit);
194
195 MCAPI bool safeToModify() const;
196
197 MCAPI void serialize(::IDataOutput& stream, bool network) const;
198
199 MCFOLD void setAbsoluteIndex(schar index);
200
201 MCAPI void setAllIsMaxSkyLight();
202
203 MCAPI void setAllIsNoSkyLight();
204
205 MCAPI void setBlock(ushort index, ::Block const& block);
206
207#ifdef LL_PLAT_S
208 MCAPI void setBlockLight(ushort index, uchar lightValue);
209#endif
210
211 MCAPI void setBlocksToUniform(::Block const& initBlock, bool maxSkyLight, bool fullyLit);
212
213 MCAPI void setExtraBlock(ushort index, ::Block const& block);
214
215 MCAPI void setFromBlockVolume(::BlockVolume const& box, short height);
216
217#ifdef LL_PLAT_C
218 MCFOLD void setIsReplacementSubChunk(bool isReplacement);
219#endif
220
221 MCAPI void setLight(ushort idx, ::SubChunkBrightnessStorage::LightPair pair);
222
223 MCAPI void setNeedsClientLighting(bool state);
224
225 MCAPI void setNeedsInitLighting(bool state);
226
227#ifdef LL_PLAT_C
228 MCFOLD void setRenderChunkTrackingVersionNumber(uchar versionNumber);
229#endif
230
231 MCAPI void setSkyLight(ushort index, uchar lightValue);
232
233#ifdef LL_PLAT_C
234 MCFOLD void setSubChunkState(::SubChunk::SubChunkState subChunkState);
235#endif
236
237 MCAPI ~SubChunk();
238 // NOLINTEND
239
240public:
241 // static functions
242 // NOLINTBEGIN
243 MCAPI static void flushGarbageCollectors();
244 // NOLINTEND
245
246public:
247 // constructor thunks
248 // NOLINTBEGIN
249 MCAPI void* $ctor();
250
251 MCAPI void* $ctor(::SubChunk&& rhs);
252
253 MCAPI void*
254 $ctor(::Block const* initBlock, bool maxSkyLight, bool fullyLit, ::SpinLockImpl& spinLock, schar absoluteIndex);
255 // NOLINTEND
256
257public:
258 // destructor thunk
259 // NOLINTBEGIN
260 MCAPI void $dtor();
261 // NOLINTEND
262};
Definition BlockDataFetchResult.h:8
Definition BlockPalette.h:21
Definition BlockPos.h:21
Definition BlockVolume.h:14
Definition Block.h:69
Definition BoundingBox.h:13
Definition IDataInput.h:8
Definition IDataOutput.h:5
Definition SpinLockImpl.h:5
Definition SubChunkBrightnessStorage.h:5
Definition SubChunkPos.h:5
Definition SubChunkStorage.h:30
Definition function_ref.h:60
Definition DeserializationChanges.h:14
Definition SubChunkBrightnessStorage.h:13