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