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