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