LeviLamina
Loading...
Searching...
No Matches
ItemRegistry.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/pub_sub/Publisher.h"
12#include "mc/deps/game_refs/WeakRef.h"
13#include "mc/deps/json/Value.h"
14#include "mc/util/BaseGameVersion.h"
15
16// auto generated forward declare list
17// clang-format off
21class Experiments;
27class Item;
28class ItemRegistryRef;
29class LevelData;
32struct ItemData;
33struct ItemParseContext;
35struct ItemTag;
36namespace Bedrock::PubSub::ThreadModel { struct MultiThreaded; }
37namespace Bedrock::Threading { class Mutex; }
38namespace Core { class Path; }
39namespace PuvLoadData { struct LoadResultWithTiming; }
40namespace cereal { struct ReflectionCtx; }
41// clang-format on
42
43class ItemRegistry : public ::std::enable_shared_from_this<::ItemRegistry> {
44public:
45 // ItemRegistry inner types declare
46 // clang-format off
47 struct ItemAlias;
48 struct ItemHashAlias;
49 struct ItemLoadResult;
50 struct LoadedItemAsset;
51 // clang-format on
52
53 // ItemRegistry inner types define
54 using ItemRegistryMap = ::std::vector<::SharedPtr<::Item>>;
55
57 public:
58 // member variables
59 // NOLINTBEGIN
60 ::ll::TypedStorage<8, 16, ::Json::Value> mUpgradedJsonRoot;
61 ::ll::TypedStorage<8, 24, ::SemVersion> mDocumentVersion;
62 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::IPackLoadContext>> mPackLoadContext;
63 ::ll::TypedStorage<8, 32, ::std::string> mLoadedPackName;
64 // NOLINTEND
65
66 public:
67 // prevent constructor by default
68 LoadedItemAsset& operator=(LoadedItemAsset const&);
71
72 public:
73 // member functions
74 // NOLINTBEGIN
76
77 MCAPI ~LoadedItemAsset();
78 // NOLINTEND
79
80 public:
81 // constructor thunks
82 // NOLINTBEGIN
83 MCAPI void* $ctor(::ItemRegistry::LoadedItemAsset&&);
84 // NOLINTEND
85
86 public:
87 // destructor thunk
88 // NOLINTBEGIN
89 MCAPI void $dtor();
90 // NOLINTEND
91 };
92
93 using CreativeItemsServerInitCallbackSignature = void(
97 ::BaseGameVersion const&,
98 ::Experiments const&,
103 );
104
105 struct ItemAlias {
106 public:
107 // member variables
108 // NOLINTBEGIN
109 ::ll::TypedStorage<8, 48, ::HashedString> currentName;
110 ::ll::TypedStorage<8, 32, ::BaseGameVersion> sinceVersion;
111 // NOLINTEND
112
113 public:
114 // member functions
115 // NOLINTBEGIN
116 MCAPI ~ItemAlias();
117 // NOLINTEND
118
119 public:
120 // destructor thunk
121 // NOLINTBEGIN
122 MCAPI void $dtor();
123 // NOLINTEND
124 };
125
127 public:
128 // member variables
129 // NOLINTBEGIN
130 ::ll::TypedStorage<8, 8, uint64> aliasName;
131 ::ll::TypedStorage<8, 32, ::BaseGameVersion> sinceVersion;
132 // NOLINTEND
133
134 public:
135 // prevent constructor by default
136 ItemHashAlias& operator=(ItemHashAlias const&);
139
140 public:
141 // member functions
142 // NOLINTBEGIN
143 MCAPI ItemHashAlias(uint64 nameHash, ::BaseGameVersion const& version);
144
145 MCAPI ::ItemRegistry::ItemHashAlias& operator=(::ItemRegistry::ItemHashAlias&&);
146
147 MCAPI ~ItemHashAlias();
148 // NOLINTEND
149
150 public:
151 // constructor thunks
152 // NOLINTBEGIN
153 MCAPI void* $ctor(uint64 nameHash, ::BaseGameVersion const& version);
154 // NOLINTEND
155
156 public:
157 // destructor thunk
158 // NOLINTBEGIN
159 MCFOLD void $dtor();
160 // NOLINTEND
161 };
162
164 public:
165 // member variables
166 // NOLINTBEGIN
167 ::ll::TypedStorage<8, 96, ::std::optional<::ItemRegistry::LoadedItemAsset>> mLoadedItemAsset;
168 ::ll::TypedStorage<8, 32, ::std::string> mError;
169 // NOLINTEND
170
171 public:
172 // member functions
173 // NOLINTBEGIN
174 MCAPI ~ItemLoadResult();
175 // NOLINTEND
176
177 public:
178 // destructor thunk
179 // NOLINTBEGIN
180 MCAPI void $dtor();
181 // NOLINTEND
182 };
183
184public:
185 // member variables
186 // NOLINTBEGIN
187 ::ll::TypedStorage<8, 8, ::gsl::not_null<::std::unique_ptr<::cereal::ReflectionCtx>>> mCerealContext;
188 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::LinkedAssetValidator>> mValidator;
189 ::ll::TypedStorage<8, 24, ::std::vector<::SharedPtr<::Item>>> mItemRegistry;
190 ::ll::TypedStorage<8, 64, ::std::unordered_map<int, ::WeakPtr<::Item>>> mIdToItemMap;
191 ::ll::TypedStorage<8, 64, ::std::unordered_map<::HashedString, ::WeakPtr<::Item>>> mNameToItemMap;
192 ::ll::TypedStorage<8, 64, ::std::unordered_map<::HashedString, ::WeakPtr<::Item>>> mTileNamespaceToItemMap;
193 ::ll::TypedStorage<8, 64, ::std::unordered_map<::HashedString, ::WeakPtr<::Item>>> mTileItemNameToItemMap;
194 ::ll::TypedStorage<8, 64, ::std::unordered_map<::HashedString, ::ItemRegistry::ItemAlias>> mItemAliasLookupMap;
195 ::ll::TypedStorage<8, 64, ::std::unordered_map<uint64, ::ItemRegistry::ItemHashAlias>> mReverseAliasLookupMap;
196 ::ll::TypedStorage<8, 64, ::std::unordered_map<uint64, ::ItemRegistry::ItemHashAlias>>
197 mReverseFullNameAliasLookupMap;
198 ::ll::TypedStorage<8, 64, ::std::unordered_map<::HashedString, ::ItemRegistryComplexAlias>> mComplexAliasLookupMap;
199 ::ll::TypedStorage<8, 64, ::std::unordered_map<short, ::HashedString>> mLegacyIDToNameMap;
200 ::ll::TypedStorage<2, 2, short> mMaxItemID;
201 ::ll::TypedStorage<8, 24, ::std::vector<::HashedString>> mAttachableDefinitions;
202 ::ll::TypedStorage<8, 64, ::std::unordered_map<::ItemTag, ::std::unordered_set<::Item const*>>> mTagToItemsMap;
203 ::ll::TypedStorage<8, 64, ::std::unordered_set<::Item const*> const> mEmptyItemSet;
204 ::ll::TypedStorage<1, 1, bool> mServerInitializingCreativeItems;
205 ::ll::TypedStorage<1, 1, bool> mIsInitialized;
206 ::ll::TypedStorage<8, 64, ::std::function<void(::ItemRegistryRef)>> mExtraItemInitCallback;
207 ::ll::TypedStorage<
208 8,
209 8,
211 mFinishedInitServerPublisher;
212 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::std::atomic<int>>> mCanUpdateTags;
213 ::ll::TypedStorage<8, 24, ::std::vector<::SharedPtr<::Item>>> mDeadItemRegistry;
214 ::ll::TypedStorage<8, 32, ::BaseGameVersion> mWorldBaseGameVersion;
215 ::ll::TypedStorage<1, 1, bool> mCheckForItemWorldCompatibility;
216 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::Bedrock::Threading::Mutex>> mCompatibilityCheckMutex;
217 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::CreativeItemRegistry>> mCreativeItemRegistry;
218 // NOLINTEND
219
220public:
221 // member functions
222 // NOLINTBEGIN
223 MCAPI ItemRegistry();
224
225 MCAPI void _initServerData(
226 ::std::vector<::ItemRegistry::LoadedItemAsset> const& allItemAssets,
227 ::ItemParseContext& parseContext,
228 ::IMinecraftEventing& eventing
229 );
230
231 MCAPI ::PuvLoadData::LoadResultWithTiming
232 _loadItemDefinition(::ItemRegistry::LoadedItemAsset const& loadedItemAsset, ::ItemParseContext& parseContext);
233
234 MCAPI void addItemToTagMap(::Item const& item);
235
236 MCAPI void alterAvailableCreativeItems(::ActorInfoRegistry* registry, ::LevelData& levelData);
237
238 MCAPI void clearItemAndCreativeItemRegistry();
239
240 MCAPI void finishedRegistration();
241
242 MCAPI ::std::vector<::std::reference_wrapper<::HashedString const>> const&
243 getComplexAliasSplitNames(::HashedString const& oldName) const;
244
245 MCAPI ::WeakPtr<::Item> getItem(short id);
246
247 MCAPI ::std::pair<::HashedString, int> getNameFromAlias(::HashedString const& name, int aux) const;
248
249 MCAPI ::HashedString getNameFromLegacyID(short id);
250
251 MCAPI void initCreativeItemsServer(
252 ::BlockDefinitionGroup const& blockDefinitionGroup,
253 ::Experiments const& experiments,
254 ::ResourcePackManager const& resourcePackManager,
256 ::IMinecraftEventing& eventing,
257 ::std::function<void(
261 ::BaseGameVersion const&,
262 ::Experiments const&,
267 )> registerCallback
268 );
269
270 MCAPI void initServer(
271 ::Experiments const& experiments,
272 ::BaseGameVersion const& baseGameVersion,
275 ::IMinecraftEventing& eventing
276 );
277
278 MCAPI ::WeakPtr<::Item> lookupByName(int& inOutItemAux, ::std::string_view inString) const;
279
280 MCAPI ::WeakPtr<::Item> lookupByNameNoAlias(::std::string_view inString) const;
281
282 MCAPI ::WeakPtr<::Item> lookupByNameNoParsing(int& inOutItemAux, ::HashedString const& fullName) const;
283
284 MCAPI void onLevelInit(
285 ::WeakRef<::IDynamicContainerSerialization> containerSerialization,
288 );
289
290 MCAPI void
291 registerAlias(::HashedString const& alias, ::HashedString const& name, ::BaseGameVersion const& fromVersion);
292
293 MCAPI ::WeakPtr<::Item>
294 registerComplexAlias(::HashedString const& alias, ::ItemRegistryComplexAlias const& complexAlias);
295
296 MCAPI void registerItem(::SharedPtr<::Item> item);
297
298 MCAPI void registerLegacyMapping(
299 ::HashedString const& alias,
300 ::HashedString const& name,
301 ::BaseGameVersion const& fromVersion
302 );
303
304 MCAPI void registerValidatorIdentifier(::std::string const& str);
305
306 MCAPI void setCheckForItemWorldCompatibility(bool value);
307
308 MCAPI void unregisterItem(::HashedString const& itemName);
309
310 MCAPI ::std::vector<::std::string> validateServerItemComponents(::std::vector<::ItemData> const& items);
311
312 MCAPI ~ItemRegistry();
313 // NOLINTEND
314
315public:
316 // static functions
317 // NOLINTBEGIN
318 MCAPI static ::std::vector<::ItemRegistry::LoadedItemAsset> _loadAllItemAssets(
319 ::ResourcePackManager const& resourcePackManager,
320 ::Experiments const& experiments,
323 );
324
325 MCAPI static ::ItemRegistry::ItemLoadResult _tryLoadItemAsset(
326 ::std::string jsonData,
327 ::std::shared_ptr<::IPackLoadContext> packLoadContext,
328 ::Core::Path const& filenameWithExtension,
330 ::std::string const& packName
331 );
332 // NOLINTEND
333
334public:
335 // static variables
336 // NOLINTBEGIN
337 MCAPI static ::std::string_view const& MINECRAFT_NAMESPACE();
338 // NOLINTEND
339
340public:
341 // constructor thunks
342 // NOLINTBEGIN
343 MCAPI void* $ctor();
344 // NOLINTEND
345
346public:
347 // destructor thunk
348 // NOLINTBEGIN
349 MCAPI void $dtor();
350 // NOLINTEND
351};
Definition ActorInfoRegistry.h:10
Definition BaseGameVersion.h:8
Definition NonOwnerPointer.h:9
Definition Publisher.h:8
Definition BlockDefinitionGroup.h:39
Definition Path.h:11
Definition CreativeItemRegistry.h:21
Definition Experiments.h:14
Definition HashedString.h:5
Definition IContainerRegistryAccess.h:14
Definition IContainerRegistryTracker.h:15
Definition IDynamicContainerSerialization.h:12
Definition IMinecraftEventing.h:149
Definition IPackLoadContext.h:20
Definition ItemRegistryRef.h:34
Definition ItemRegistry.h:43
Definition Item.h:66
Definition LevelData.h:49
Definition LinkedAssetValidator.h:8
Definition Path.h:16
Definition ResourcePackManager.h:24
Definition SharedPtr.h:10
Definition WeakRef.h:8
Definition ItemData.h:15
Definition ItemParseContext.h:19
Definition ItemRegistryComplexAlias.h:10
Definition ItemRegistry.h:105
Definition ItemRegistry.h:126
Definition ItemRegistry.h:163
Definition ItemRegistry.h:56
Definition ItemTag.h:8
Definition ReflectionCtx.h:11
Definition ctx.h:5