LeviLamina
Loading...
Searching...
No Matches
BlockTypeRegistry.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4#include "mc/deps/core/string/HashedString.h"
5
6// auto generated inclusion list
7#include "mc/common/SharedPtr.h"
8#include "mc/common/WeakPtr.h"
9#include "mc/deps/core/sem_ver/SemVersion.h"
10#include "mc/deps/core/string/HashedString.h"
11#include "mc/deps/core/utility/NonOwnerPointer.h"
12#include "mc/deps/core/utility/Owner.h"
13#include "mc/platform/brstd/function_ref.h"
14#include "mc/util/BaseGameVersion.h"
15
16// auto generated forward declare list
17// clang-format off
18class Block;
19class BlockType;
23class Experiments;
26namespace VoxelShapes { class VoxelShapeRegistry; }
27// clang-format on
28
29class BlockTypeRegistry {
30public:
31 // BlockTypeRegistry inner types declare
32 // clang-format off
35 struct DirectAccessBlocks;
37 // clang-format on
38
39 // BlockTypeRegistry inner types define
40 enum class LookupByNameImplResolve : int {
41 BlockType = 0,
42 Block = 1,
43 };
44
45 struct BlockComplexAliasBlockState {
46 public:
47 BlockComplexAliasBlockState(HashedString const& stateName, int value) noexcept
48 : stateName(stateName),
49 value(value) {}
50
51 public:
52 // member variables
53 // NOLINTBEGIN
54 ::HashedString stateName;
55 int value;
56 // NOLINTEND
57
58 public:
59 // destructor thunk
60 // NOLINTBEGIN
61 MCFOLD void $dtor();
62 // NOLINTEND
63 };
64
65 class BlockComplexAliasContent {
66 public:
67 // member variables
68 // NOLINTBEGIN
69 ::ll::TypedStorage<8, 64, ::std::function<::Block const*(int)>> mCallback;
70 ::ll::TypedStorage<8, 32, ::BaseGameVersion> mMinRequiredVersion;
71 ::ll::TypedStorage<8, 24, ::SemVersion> mFlattenedInBlocksJsonVersion;
72 ::ll::TypedStorage<4, 4, int> mStartVariant;
73 // NOLINTEND
74
75 public:
76 // prevent constructor by default
77 BlockComplexAliasContent& operator=(BlockComplexAliasContent const&);
78 BlockComplexAliasContent();
79
80 public:
81 // member functions
82 // NOLINTBEGIN
83 MCAPI BlockComplexAliasContent(::BlockTypeRegistry::BlockComplexAliasContent const&);
84
85 MCAPI BlockComplexAliasContent(
86 ::std::function<::Block const*(int)> callback,
87 ::BaseGameVersion const& minRequiredVersion,
88 ::SemVersion const& blocksJsonFormatVersion,
89 int startVariant
90 );
91
92 MCFOLD ::BaseGameVersion const& getRequiredBaseGameVersion() const;
93
94 MCAPI ::BlockTypeRegistry::BlockComplexAliasContent& operator=(::BlockTypeRegistry::BlockComplexAliasContent&&);
95
96 MCAPI ~BlockComplexAliasContent();
97 // NOLINTEND
98
99 public:
100 // constructor thunks
101 // NOLINTBEGIN
102 MCAPI void* $ctor(::BlockTypeRegistry::BlockComplexAliasContent const&);
103
104 MCAPI void* $ctor(
105 ::std::function<::Block const*(int)> callback,
106 ::BaseGameVersion const& minRequiredVersion,
107 ::SemVersion const& blocksJsonFormatVersion,
108 int startVariant
109 );
110 // NOLINTEND
111
112 public:
113 // destructor thunk
114 // NOLINTBEGIN
115 MCAPI void $dtor();
116 // NOLINTEND
117 };
118
119 struct DirectAccessBlocks {
120 public:
121 // member variables
122 // NOLINTBEGIN
123 ::ll::TypedStorage<8, 8, ::BlockType const&> mAirBlock;
124 // NOLINTEND
125
126 public:
127 // prevent constructor by default
128 DirectAccessBlocks& operator=(DirectAccessBlocks const&);
129 DirectAccessBlocks(DirectAccessBlocks const&);
130 DirectAccessBlocks();
131 };
132
133 struct LookupByNameImplReturnType {
134 public:
135 // member variables
136 // NOLINTBEGIN
137 ::ll::TypedStorage<8, 8, ::WeakPtr<::BlockType const>> mBlockType;
138 ::ll::TypedStorage<8, 8, ::Block const*> mBlock;
139 // NOLINTEND
140
141 public:
142 // prevent constructor by default
143 LookupByNameImplReturnType();
144
145 public:
146 // member functions
147 // NOLINTBEGIN
148 MCAPI LookupByNameImplReturnType(::Block const* block, bool resolveBlockType);
149
150 MCAPI LookupByNameImplReturnType(::WeakPtr<::BlockType const> blockType, int data, bool resolveBlock);
151 // NOLINTEND
152
153 public:
154 // constructor thunks
155 // NOLINTBEGIN
156 MCAPI void* $ctor(::Block const* block, bool resolveBlockType);
157
158 MCAPI void* $ctor(::WeakPtr<::BlockType const> blockType, int data, bool resolveBlock);
159 // NOLINTEND
160 };
161
162 using BlockAliasLookupMap = ::std::unordered_map<::HashedString, ::HashedString>;
163
164 using BlockComplexAliasCallback = ::std::function<::Block const*(int)>;
165
166 using BlockComplexAliasLookupMap = ::entt::dense_map<::HashedString, ::BlockTypeRegistry::BlockComplexAliasContent>;
167
168 using BlockComplexAliasPostSplitBlockNames = ::std::vector<::std::reference_wrapper<::HashedString const>>;
169
170 using BlockComplexAliasPostSplitBlockNamesList =
171 ::std::vector<::std::vector<::std::reference_wrapper<::HashedString const>>>;
172
173 using BlockComplexAliasPostSplitBlockNamesLookupMap = ::entt::dense_map<uint64, uint64>;
174
175 using BlockLookupMap = ::std::map<::HashedString, ::SharedPtr<::BlockType>>;
176
177 using BlockNameHashToHashedStringMap = ::entt::dense_map<uint64, ::HashedString>;
178
179public:
180 // member variables
181 // NOLINTBEGIN
182 ::ll::TypedStorage<8, 16, ::std::map<::HashedString, ::SharedPtr<::BlockType>>> mBlockLookupMap;
183 ::ll::TypedStorage<8, 64, ::std::unordered_map<::HashedString, ::HashedString>> mBlockAliasLookupMap;
184 ::ll::TypedStorage<8, 72, ::entt::dense_map<::HashedString, ::BlockTypeRegistry::BlockComplexAliasContent>>
185 mBlockComplexAliasLookupMap;
186 ::ll::TypedStorage<8, 24, ::std::vector<::std::vector<::std::reference_wrapper<::HashedString const>>>>
187 mBlockComplexAliasPostSplitBlockNamesList;
188 ::ll::TypedStorage<8, 72, ::entt::dense_map<uint64, uint64>> mBlockComplexAliasPostSplitBlockNamesLookupMap;
189 ::ll::TypedStorage<8, 16, ::std::map<::HashedString, ::HashedString>> mBlockComplexAliasPreSplitBlockNamesLookupMap;
190 ::ll::TypedStorage<8, 16, ::std::set<::std::string>> mKnownNamespaces;
191 ::ll::TypedStorage<8, 72, ::entt::dense_map<uint64, ::HashedString>> mBlockNameHashToStringMap;
192 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::BlockTypeRegistry::DirectAccessBlocks>> mDirectAccessBlocks;
193 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::BlockTypeRegistryRWLock>> mRWLock;
194 // NOLINTEND
195
196public:
197 // member functions
198 // NOLINTBEGIN
199 MCAPI BlockTypeRegistry();
200
201 MCAPI ::BlockTypeRegistryReadLock _lockAgainstRegistryModifications() const;
202
203 MCAPI ::BlockTypeRegistryModificationsLock _lockForRegistryModifications() const;
204
205 MCAPI ::BlockTypeRegistry::LookupByNameImplReturnType _lookupByNameImpl(
206 ::HashedString const& name,
207 int data,
208 ::BlockTypeRegistry::LookupByNameImplResolve resolve,
209 bool logNotFound = false
210 ) const;
211
212#ifdef LL_PLAT_C
213 MCAPI void addBlocksToValidator(::LinkedAssetValidator& validator, ::BaseGameVersion const& baseGameVersion) const;
214#endif
215
216 MCAPI void checkBlockPermutationCap() const;
217
218 MCAPI uint64 computeBlockTypeRegistryChecksum(::BaseGameVersion const& worldBaseGameVersion) const;
219
220 MCAPI void finalizeBlockComponentStorage();
221
222#ifdef LL_PLAT_C
223 MCAPI void finalizeBlockComponentStorageForRendering(::brstd::function_ref<void(::BlockType&)> finalizer);
224#endif
225
226 MCAPI void finalizeBlockCustomComponentEvents(::ServerScriptManager const& scriptManager);
227
228#ifdef LL_PLAT_C
229 MCFOLD void forEachBlockDEPRECATED(::brstd::function_ref<bool(::BlockType&)> callback);
230#endif
231
232 MCAPI void forEachBlockMutable(::brstd::function_ref<bool(::Block&)> callback);
233
234 MCFOLD void forEachBlockType(::brstd::function_ref<bool(::BlockType const&)> callback) const;
235
236 MCAPI ::HashedString const& getBlockNameFromNameHash(uint64 hash) const;
237
238 MCAPI ::std::vector<::std::reference_wrapper<::HashedString const>> const&
239 getComplexAliasPostSplitBlockNames(::HashedString const& oldName) const;
240
241#ifdef LL_PLAT_C
242 MCAPI ::HashedString const* getComplexAliasPreSplitBlockName(::HashedString const& postSplitName) const;
243#endif
244
245 MCAPI ::Block const& getDefaultBlockState(::HashedString const& name, bool logNotFound = false) const;
246
247 MCAPI ::BlockTypeRegistry::DirectAccessBlocks const& getDirectAccessBlocks() const;
248
249#ifdef LL_PLAT_C
250 MCAPI int getStartVariantForComplexAliasBlock(::HashedString const& blockName) const;
251#endif
252
253 MCAPI void initHardCodedBlockComponents(::Experiments const& experiments);
254
255 MCAPI void initRWLock();
256
257 MCAPI bool isComplexAliasBlock(::HashedString const& blockName) const;
258
259#ifdef LL_PLAT_C
260 MCAPI bool isExpectFlattenedInBlocksJson(::HashedString const& blockName, ::SemVersion const& currentVersion) const;
261#endif
262
263 MCAPI ::Block const* lookupByName(::HashedString const& name, int data, bool logNotFound = false) const;
264
265 MCAPI ::Block const* lookupByName(
266 ::HashedString const& name,
267 ::std::vector<::BlockTypeRegistry::BlockComplexAliasBlockState> const& states,
268 bool logNotFound = false
269 ) const;
270
271 MCAPI ::WeakPtr<::BlockType> lookupByName(::HashedString const& name, bool logNotFound = false) const;
272
273 MCAPI void prepareBlocks(uint latestUpdaterVersion);
274
275 MCAPI void registerAlias(::HashedString const& alias, ::HashedString const& name);
276
277 MCAPI void registerComplexAlias(
278 ::HashedString const& alias,
279 ::std::function<::Block const*(int)> callback,
280 ::std::vector<::std::reference_wrapper<::HashedString const>> const& postSplitBlockNames,
281 ::BaseGameVersion const& minRequiredVersion,
282 ::SemVersion const& blocksJsonFormatVersion,
283 ::HashedString defaultNewBlockName,
284 int startVariant
285 );
286
287 MCAPI void setupDirectAccessBlocks();
288
289 MCAPI void setupVoxelShapeRegistryAccessOnAllBlocks(
290 ::std::shared_ptr<::VoxelShapes::VoxelShapeRegistry> const& voxelShapeRegistry
291 ) const;
292
293 MCAPI void unregisterBlock(::HashedString const& name);
294
295 MCAPI void unregisterBlocks();
296
297 MCAPI ~BlockTypeRegistry();
298 // NOLINTEND
299
300public:
301 // static functions
302 // NOLINTBEGIN
303 MCAPI static ::BlockTypeRegistry& get();
304
305 MCAPI static ::Bedrock::NotNullNonOwnerPtr<::BlockTypeRegistry> getNonOwner();
306 // NOLINTEND
307
308public:
309 // static variables
310 // NOLINTBEGIN
311 MCAPI static ::Bedrock::Owner<::BlockTypeRegistry>& mBlockTypeRegistry();
312 // NOLINTEND
313
314public:
315 // constructor thunks
316 // NOLINTBEGIN
317 MCAPI void* $ctor();
318 // NOLINTEND
319
320public:
321 // destructor thunk
322 // NOLINTBEGIN
323 MCAPI void $dtor();
324 // NOLINTEND
325};
Definition BaseGameVersion.h:13
Definition BlockTypeRegistryModificationsLock.h:10
Definition BlockTypeRegistryRWLock.h:8
Definition BlockTypeRegistryReadLock.h:10
Definition BlockTypeRegistry.h:65
Definition BlockType.h:84
Definition Block.h:69
Definition Experiments.h:14
Definition HashedString.h:5
Definition LinkedAssetValidator.h:8
Definition SemVersion.h:15
Definition ServerScriptManager.h:77
Definition VoxelShapeRegistry.h:14
Definition WeakPtr.h:10
Definition function_ref.h:60
Definition BlockTypeRegistry.h:45
Definition BlockTypeRegistry.h:119
Definition BlockTypeRegistry.h:133