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