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;
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 using BlockComplexAliasPostSplitBlockNamesLookupMap = ::entt::dense_map<uint64, uint64>;
138
139 using BlockNameHashToHashedStringMap = ::entt::dense_map<uint64, ::HashedString>;
140
142 public:
143 // member variables
144 // NOLINTBEGIN
145 ::ll::TypedStorage<8, 8, ::BlockType const&> mAirBlock;
146 // NOLINTEND
147
148 public:
149 // prevent constructor by default
150 DirectAccessBlocks& operator=(DirectAccessBlocks const&);
153 };
154
155 enum class LookupByNameImplResolve : int {
156 BlockType = 0,
157 Block = 1,
158 };
159
160public:
161 // member variables
162 // NOLINTBEGIN
163 ::ll::TypedStorage<8, 16, ::std::map<::HashedString, ::SharedPtr<::BlockType>>> mBlockLookupMap;
164 ::ll::TypedStorage<8, 64, ::std::unordered_map<::HashedString, ::HashedString>> mBlockAliasLookupMap;
165 ::ll::TypedStorage<8, 72, ::entt::dense_map<::HashedString, ::BlockTypeRegistry::BlockComplexAliasContent>>
166 mBlockComplexAliasLookupMap;
167 ::ll::TypedStorage<8, 24, ::std::vector<::std::vector<::std::reference_wrapper<::HashedString const>>>>
168 mBlockComplexAliasPostSplitBlockNamesList;
169 ::ll::TypedStorage<8, 72, ::entt::dense_map<uint64, uint64>> mBlockComplexAliasPostSplitBlockNamesLookupMap;
170 ::ll::TypedStorage<8, 16, ::std::map<::HashedString, ::HashedString>> mBlockComplexAliasPreSplitBlockNamesLookupMap;
171 ::ll::TypedStorage<8, 16, ::std::set<::std::string>> mKnownNamespaces;
172 ::ll::TypedStorage<8, 72, ::entt::dense_map<uint64, ::HashedString>> mBlockNameHashToStringMap;
173 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::BlockTypeRegistry::DirectAccessBlocks>> mDirectAccessBlocks;
174 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::BlockTypeRegistryRWLock>> mRWLock;
175 // NOLINTEND
176
177public:
178 // member functions
179 // NOLINTBEGIN
180 MCAPI BlockTypeRegistry();
181
182 MCAPI ::BlockTypeRegistryReadLock _lockAgainstRegistryModifications() const;
183
184 MCAPI ::BlockTypeRegistryModificationsLock _lockForRegistryModifications() const;
185
186 MCAPI ::BlockTypeRegistry::LookupByNameImplReturnType _lookupByNameImpl(
187 ::HashedString const& name,
188 int data,
189 ::BlockTypeRegistry::LookupByNameImplResolve resolve,
190 bool logNotFound = false
191 ) const;
192
193 MCAPI void checkBlockPermutationCap() const;
194
195 MCAPI uint64 computeBlockTypeRegistryChecksum(::BaseGameVersion const& worldBaseGameVersion) const;
196
197 MCAPI void finalizeBlockComponentStorage();
198
199 MCAPI void finalizeBlockCustomComponentEvents(::ServerScriptManager const& scriptManager);
200
201 MCAPI void forEachBlockType(::brstd::function_ref<bool(::BlockType const&)> callback) const;
202
203 MCAPI ::HashedString const& getBlockNameFromNameHash(uint64 hash) const;
204
205 MCAPI ::std::vector<::std::reference_wrapper<::HashedString const>> const&
206 getComplexAliasPostSplitBlockNames(::HashedString const& oldName) const;
207
208 MCAPI ::Block const& getDefaultBlockState(::HashedString const& name, bool logNotFound = false) const;
209
210 MCAPI ::BlockTypeRegistry::DirectAccessBlocks const& getDirectAccessBlocks() const;
211
212 MCAPI void initHardCodedBlockComponents(::Experiments const& experiments);
213
214 MCAPI bool isComplexAliasBlock(::HashedString const& blockName) const;
215
216 MCAPI ::WeakPtr<::BlockType> lookupByName(::HashedString const& name, bool logNotFound = false) const;
217
218 MCAPI void prepareBlocks(uint latestUpdaterVersion);
219
220 MCAPI void registerAlias(::HashedString const& alias, ::HashedString const& name);
221
222 MCAPI void registerComplexAlias(
223 ::HashedString const& alias,
224 ::std::function<::Block const*(int)> callback,
225 ::std::vector<::std::reference_wrapper<::HashedString const>> const& postSplitBlockNames,
226 ::BaseGameVersion const& minRequiredVersion,
227 ::SemVersion const& blocksJsonFormatVersion,
228 ::HashedString defaultNewBlockName,
229 int startVariant
230 );
231
232 MCAPI void setupDirectAccessBlocks();
233
234 MCAPI void setupVoxelShapeRegistryAccessOnAllBlocks(
235 ::std::shared_ptr<::VoxelShapes::VoxelShapeRegistry> const& voxelShapeRegistry
236 ) const;
237
238 MCAPI void unregisterBlock(::HashedString const& name);
239
240 MCAPI void unregisterBlocks();
241
242 MCAPI ~BlockTypeRegistry();
243 // NOLINTEND
244
245public:
246 // static functions
247 // NOLINTBEGIN
248 MCAPI static ::BlockTypeRegistry& get();
249
250 MCAPI static ::Bedrock::NotNullNonOwnerPtr<::BlockTypeRegistry> getNonOwner();
251 // NOLINTEND
252
253public:
254 // static variables
255 // NOLINTBEGIN
256 MCAPI static ::Bedrock::Owner<::BlockTypeRegistry>& mBlockTypeRegistry();
257 // NOLINTEND
258
259public:
260 // constructor thunks
261 // NOLINTBEGIN
262 MCAPI void* $ctor();
263 // NOLINTEND
264
265public:
266 // destructor thunk
267 // NOLINTBEGIN
268 MCAPI void $dtor();
269 // NOLINTEND
270};
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:38
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:141
Definition BlockTypeRegistry.h:100