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
17// auto generated forward declare list
18// clang-format off
22class Experiments;
28class ItemRegistryRef;
29class LevelData;
32struct ItemData;
34struct ItemParseContext;
36struct ItemTag;
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<::IPackLoadContext>> 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 MCAPI_C void digestServerItemComponents(::std::vector<::ItemData> const& items);
242
243 MCAPI_C void findAllAttachableDefinitions();
244
245 MCAPI void finishedRegistration();
246
247 MCAPI ::std::vector<::std::reference_wrapper<::HashedString const>> const&
248 getComplexAliasSplitNames(::HashedString const& oldName) const;
249
250 MCAPI ::WeakPtr<::Item> getItem(short id);
251
252 MCAPI ::std::pair<::HashedString, int> getNameFromAlias(::HashedString const& name, int aux) const;
253
254 MCAPI ::HashedString getNameFromLegacyID(short id);
255
256 MCAPI_C void initClient(
257 ::std::vector<::ItemData> const& serverItemData,
258 ::Experiments const& experiments,
259 ::BaseGameVersion const& baseGameVersion
260 );
261
262 MCAPI_C void initClientData(
263 ::ResourcePackManager& resourcePackManager,
264 ::Experiments const& experiments,
265 ::ItemIconInfoFactory iconFactory
266 );
267
268 MCAPI void initCreativeItemsServer(
269 ::BlockDefinitionGroup const& blockDefinitionGroup,
270 ::Experiments const& experiments,
271 ::ResourcePackManager const& resourcePackManager,
273 ::IMinecraftEventing& eventing,
274 ::std::function<void(
278 ::BaseGameVersion const&,
279 ::Experiments const&,
284 )> registerCallback
285 );
286
287 MCAPI void initServer(
288 ::Experiments const& experiments,
289 ::BaseGameVersion const& baseGameVersion,
292 ::IMinecraftEventing& eventing
293 );
294
295 MCAPI ::WeakPtr<::Item> lookupByName(int& inOutItemAux, ::std::string_view inString) const;
296
297 MCAPI ::WeakPtr<::Item> lookupByNameNoAlias(::std::string_view inString) const;
298
299 MCAPI ::WeakPtr<::Item> lookupByNameNoParsing(int& inOutItemAux, ::HashedString const& fullName) const;
300
301 MCAPI_C void matchServerItemIds(::std::vector<::ItemData> const& serverItemData);
302
303 MCAPI void onLevelInit(
304 ::WeakRef<::IDynamicContainerSerialization> containerSerialization,
307 );
308
309 MCAPI void
310 registerAlias(::HashedString const& alias, ::HashedString const& name, ::BaseGameVersion const& fromVersion);
311
312 MCAPI ::WeakPtr<::Item>
313 registerComplexAlias(::HashedString const& alias, ::ItemRegistryComplexAlias const& complexAlias);
314
315 MCAPI void registerItem(::SharedPtr<::Item> item);
316
317 MCAPI void registerLegacyID(::HashedString const& name, short id);
318
319 MCAPI void registerLegacyMapping(
320 ::HashedString const& alias,
321 ::HashedString const& name,
322 ::BaseGameVersion const& fromVersion
323 );
324
325 MCAPI void registerValidatorIdentifier(::std::string const& str);
326
327 MCAPI void setCheckForItemWorldCompatibility(bool value);
328
329 MCAPI_C void setItemId(::HashedString const& itemName, short itemId, bool isComponentBased);
330
331 MCAPI void unregisterItem(::HashedString const& itemName);
332
333 MCAPI ::std::vector<::std::string> validateServerItemComponents(::std::vector<::ItemData> const& items);
334
335 MCAPI ~ItemRegistry();
336 // NOLINTEND
337
338public:
339 // static functions
340 // NOLINTBEGIN
341 MCAPI static ::std::vector<::ItemRegistry::LoadedItemAsset> _loadAllItemAssets(
342 ::ResourcePackManager const& resourcePackManager,
343 ::Experiments const& experiments,
346 );
347
348 MCAPI static ::ItemRegistry::ItemLoadResult _tryLoadItemAsset(
349 ::std::string jsonData,
350 ::std::shared_ptr<::IPackLoadContext> packLoadContext,
351 ::Core::Path const& filenameWithExtension,
353 ::std::string const& packName
354 );
355 // NOLINTEND
356
357public:
358 // static variables
359 // NOLINTBEGIN
360 MCAPI static ::std::string_view const& MINECRAFT_NAMESPACE();
361 // NOLINTEND
362
363public:
364 // constructor thunks
365 // NOLINTBEGIN
366 MCAPI void* $ctor();
367 // NOLINTEND
368
369public:
370 // destructor thunk
371 // NOLINTBEGIN
372 MCAPI void $dtor();
373 // NOLINTEND
374};
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:10
Definition CreativeItemRegistry.h:23
Definition Experiments.h:14
Definition HashedString.h:5
Definition IContainerRegistryAccess.h:14
Definition IContainerRegistryTracker.h:15
Definition IDynamicContainerSerialization.h:12
Definition IMinecraftEventing.h:137
Definition IPackLoadContext.h:20
Definition ItemRegistryRef.h:36
Definition Item.h:69
Definition LevelData.h:50
Definition LinkedAssetValidator.h:8
Definition ResourcePackManager.h:29
Definition SharedPtr.h:10
Definition WeakRef.h:8
Definition ItemData.h:15
Definition ItemIconInfoFactory.h:15
Definition ItemParseContext.h:19
Definition ItemRegistryComplexAlias.h:10
Definition ItemRegistry.h:55
Definition ItemRegistry.h:76
Definition ItemRegistry.h:150
Definition ItemRegistry.h:113
Definition ItemTag.h:8
Definition LoadResultWithTiming.h:7
Definition ReflectionCtx.h:11
Definition ctx.h:5