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/resource/PackType.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/resource_processing/util/MinecraftDocumentInput.h"
13#include "mc/resources/PackLoadInfo.h"
14#include "mc/util/BaseGameVersion.h"
15#include "mc/world/item/Item.h"
16#include "mc/world/item/ItemTag.h"
17#include "mc/world/item/registry/ItemRegistrationOrder.h"
18#include "mc/world/item/registry/ItemRegistrationState.h"
19#include "mc/world/item/registry/ItemRegistryRef.h"
20
21// auto generated forward declare list
22// clang-format off
26class Experiments;
29class ItemRegistryRef;
30class LevelData;
33struct ItemData;
34struct ItemIconInfo;
35struct ItemParseContext;
37namespace Bedrock::PubSub::ThreadModel { struct MultiThreaded; }
38namespace ItemLoaderTraits { struct Loader; }
39namespace Puv { class Input; }
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 LoadedItemAsset;
50 struct ItemLoadResult;
51 struct ParsedName;
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
65 public:
66 // member variables
67 // NOLINTBEGIN
68 ::ll::TypedStorage<8, 8, uint64> aliasName;
69 ::ll::TypedStorage<8, 32, ::BaseGameVersion> sinceVersion;
70 // NOLINTEND
71 };
72
74 public:
75 // member variables
76 // NOLINTBEGIN
77 ::ll::TypedStorage<8, 272, ::Bedrock::Resources::MinecraftDocumentInput> mDocumentInput;
78 ::ll::TypedStorage<1, 1, ::PackType> mPackType;
79 ::ll::TypedStorage<8, 96, ::PackLoadInfo> mPackLoadInfo;
80 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::ItemEventResponseFactory>> mEventResponseFactory;
81 ::ll::TypedStorage<8, 32, ::std::string> mLoadedPackName;
82 ::ll::TypedStorage<1, 1, bool> mIsComponentBased;
83 // NOLINTEND
84 };
85
87 public:
88 // member variables
89 // NOLINTBEGIN
90 ::ll::TypedStorage<8, 440, ::std::optional<::ItemRegistry::LoadedItemAsset>> mLoadedItemAsset;
91 ::ll::TypedStorage<8, 32, ::std::string> mError;
92 // NOLINTEND
93 };
94
95 struct ParsedName {
96 public:
97 // member variables
98 // NOLINTBEGIN
99 ::ll::TypedStorage<8, 32, ::std::string> mItemIdentifier;
100 ::ll::TypedStorage<8, 32, ::std::string> mParsedNamespace;
101 ::ll::TypedStorage<8, 32, ::std::string> mParsedName;
102 ::ll::TypedStorage<4, 4, int> mAux;
103 // NOLINTEND
104 };
105
106 using CreativeItemsServerInitCallbackSignature = void(
110 ::BaseGameVersion const&,
111 ::Experiments const&,
116 );
117
118public:
119 // member variables
120 // NOLINTBEGIN
121 ::ll::TypedStorage<8, 8, ::gsl::not_null<::std::unique_ptr<::cereal::ReflectionCtx>>> mCerealContext;
122 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::LinkedAssetValidator>> mValidator;
123 ::ll::TypedStorage<8, 8, ::gsl::not_null<::std::unique_ptr<::ItemLoaderTraits::Loader>>> mDocumentLoader;
124 ::ll::TypedStorage<8, 24, ::std::vector<::SharedPtr<::Item>>> mItemRegistry;
125 ::ll::TypedStorage<8, 64, ::std::unordered_map<int, ::WeakPtr<::Item>>> mIdToItemMap;
126 ::ll::TypedStorage<8, 64, ::std::unordered_map<::HashedString, ::WeakPtr<::Item>>> mNameToItemMap;
127 ::ll::TypedStorage<8, 64, ::std::unordered_map<::HashedString, ::WeakPtr<::Item>>> mTileNamespaceToItemMap;
128 ::ll::TypedStorage<8, 64, ::std::unordered_map<::HashedString, ::WeakPtr<::Item>>> mTileItemNameToItemMap;
129 ::ll::TypedStorage<8, 64, ::std::unordered_map<::HashedString, ::ItemRegistry::ItemAlias>> mItemAliasLookupMap;
130 ::ll::TypedStorage<8, 64, ::std::unordered_map<uint64, ::ItemRegistry::ItemHashAlias>> mReverseAliasLookupMap;
131 ::ll::TypedStorage<8, 64, ::std::unordered_map<uint64, ::ItemRegistry::ItemHashAlias>>
132 mReverseFullNameAliasLookupMap;
133 ::ll::TypedStorage<8, 64, ::std::unordered_map<::HashedString, ::ItemRegistryComplexAlias>> mComplexAliasLookupMap;
134 ::ll::TypedStorage<8, 64, ::std::unordered_map<short, ::HashedString>> mLegacyIDToNameMap;
135 ::ll::TypedStorage<2, 2, short> mMaxItemID;
136 ::ll::TypedStorage<8, 24, ::std::vector<::HashedString>> mAttachableDefinitions;
137 ::ll::TypedStorage<8, 64, ::std::unordered_map<::ItemTag, ::std::unordered_set<::Item const*>>> mTagToItemsMap;
138 ::ll::TypedStorage<8, 64, ::std::unordered_set<::Item const*> const> mEmptyItemSet;
139 ::ll::TypedStorage<1, 1, bool> mServerInitializingCreativeItems;
140 ::ll::TypedStorage<1, 1, ::ItemRegistrationState> mItemRegistrationState;
141 ::ll::TypedStorage<8, 64, ::std::function<void(::ItemRegistryRef)>> mExtraItemInitCallback;
142 ::ll::TypedStorage<
143 8,
144 8,
146 mFinishedInitServerPublisher;
147 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::std::atomic<int>>> mCanUpdateTags;
148 ::ll::TypedStorage<8, 24, ::std::vector<::SharedPtr<::Item>>> mDeadItemRegistry;
149 ::ll::TypedStorage<1, 1, bool> mAddToPreRegistry;
150 ::ll::TypedStorage<8, 64, ::std::unordered_map<::HashedString, ::SharedPtr<::Item>>>
151 mHardcodedVanillaItemPreRegistry;
152 ::ll::TypedStorage<1, 1, ::ItemRegistrationOrder> mItemRegistrationOrder;
153 ::ll::TypedStorage<8, 32, ::BaseGameVersion> mWorldBaseGameVersion;
154 ::ll::TypedStorage<1, 1, bool> mCheckForItemWorldCompatibility;
155 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::std::mutex>> mCompatibilityCheckMutex;
156 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::CreativeItemRegistry>> mCreativeItemRegistry;
157 // NOLINTEND
158
159public:
160 // member functions
161 // NOLINTBEGIN
162 MCAPI ItemRegistry();
163
164#ifdef LL_PLAT_C
165 MCAPI void _bindBetaItemTypes(::Experiments const& experiments);
166
167 MCAPI void _movePreRegistryToMainRegistry();
168
169 MCAPI void _populateVanillaItemVersionMap(
170 ::ItemRegistry::LoadedItemAsset const& loadedItemAsset,
171 ::ItemParseContext& parseContext
172 );
173#endif
174
175 MCAPI void _preRegisterItem(::HashedString const& itemName, ::SharedPtr<::Item> item);
176
177#ifdef LL_PLAT_C
178 MCAPI ::WeakPtr<::Item>
179 _registerOrPromoteItem(::HashedString const& itemName, bool isComponentBased, ::cereal::ReflectionCtx const& ctx);
180#endif
181
182 MCAPI ::ItemRegistry::ParsedName _tryParseItemName(::Puv::Input const& input);
183
184 MCAPI ::ItemRegistryRef::LoadedItem
185 _tryRegisterAndInitItem(::ItemRegistry::LoadedItemAsset const& loadedItemAsset, ::ItemParseContext& parseContext);
186
187 MCAPI void alterAvailableCreativeItems(::ActorInfoRegistry* registry, ::LevelData& levelData);
188
189#ifdef LL_PLAT_C
190 MCAPI void buildClientRegistryFromServer(
191 ::std::vector<::ItemData> const& serverItemData,
192 ::Experiments const& experiments,
193 ::BaseGameVersion const& baseGameVersion
194 );
195#endif
196
197 MCAPI void clearItemAndCreativeItemRegistry();
198
199#ifdef LL_PLAT_C
200 MCAPI void findAllAttachableDefinitions();
201
202 MCAPI void finishedRegistration(::Experiments const& experiments);
203#endif
204
205 MCAPI ::std::vector<::std::reference_wrapper<::HashedString const>> const&
206 getComplexAliasSplitNames(::HashedString const& oldName) const;
207
208 MCFOLD ::WeakPtr<::Item> getItem(::HashedString const& id);
209
210 MCAPI ::WeakPtr<::Item> getItem(short id);
211
212 MCAPI ::std::pair<::HashedString, int> getNameFromAlias(::HashedString const& name, int aux) const;
213
214 MCAPI bool isComplexAlias(::HashedString const& oldName) const;
215
216 MCAPI ::WeakPtr<::Item> lookupByName(int& inOutItemAux, ::std::string_view inString) const;
217
218 MCAPI ::WeakPtr<::Item> lookupByName(int& outItemId, int& inOutItemAux, ::std::string_view inString) const;
219
220 MCAPI ::WeakPtr<::Item> lookupByNameNoAlias(::std::string_view inString) const;
221
222 MCAPI ::WeakPtr<::Item> lookupByNameNoParsing(int& inOutItemAux, ::HashedString const& fullName) const;
223
224 MCFOLD ::WeakPtr<::Item> lookupByVanillaName(::HashedString const& inString) const;
225
226#ifdef LL_PLAT_C
227 MCAPI void populateClientItemData(
228 ::ResourcePackManager& resourcePackManager,
229 ::Experiments const& experiments,
230 ::std::optional<::ItemIconInfo> (*iconFactory)(::std::string const&, int)
231 );
232#endif
233
234 MCAPI void
235 registerAlias(::HashedString const& alias, ::HashedString const& name, ::BaseGameVersion const& fromVersion);
236
237 MCAPI ::WeakPtr<::Item>
238 registerComplexAlias(::HashedString const& alias, ::ItemRegistryComplexAlias const& complexAlias);
239
240 MCAPI void registerItem(::SharedPtr<::Item> item);
241
242 MCAPI void registerLegacyMapping(
243 ::HashedString const& alias,
244 ::HashedString const& name,
245 ::BaseGameVersion const& fromVersion
246 );
247
248 MCAPI void registerValidatorIdentifier(::std::string const& str);
249
250 MCAPI uint64 remapToFullLegacyNameByHash(uint64 newHash);
251
252 MCAPI uint64 remapToLegacyNameByHash(uint64 newHash);
253
254 MCAPI void shutdown();
255
256 MCAPI void unregisterItem(::HashedString const& itemName);
257
258 MCAPI ::std::vector<::std::string> validateServerItemComponents(::std::vector<::ItemData> const& items);
259
260 MCAPI ~ItemRegistry();
261 // NOLINTEND
262
263public:
264 // static functions
265 // NOLINTBEGIN
266#ifdef LL_PLAT_C
267 MCAPI static ::std::vector<::ItemRegistry::LoadedItemAsset> _loadAllItemAssets(
268 ::ResourcePackManager const& resourcePackManager,
269 ::Experiments const& experiments,
271 );
272#endif
273 // NOLINTEND
274
275public:
276 // constructor thunks
277 // NOLINTBEGIN
278 MCAPI void* $ctor();
279 // NOLINTEND
280
281public:
282 // destructor thunk
283 // NOLINTBEGIN
284 MCAPI void $dtor();
285 // NOLINTEND
286};
Definition ActorInfoRegistry.h:10
Definition BaseGameVersion.h:8
Definition NonOwnerPointer.h:9
Definition Publisher.h:25
Definition BlockDefinitionGroup.h:35
Definition CreativeItemRegistry.h:23
Definition Experiments.h:14
Definition HashedString.h:5
Definition IMinecraftEventing.h:147
Definition ItemEventResponseFactory.h:17
Definition ItemRegistryRef.h:41
Definition LevelData.h:55
Definition LinkedAssetValidator.h:8
Definition Input.h:15
Definition ResourcePackManager.h:36
Definition SharedPtr.h:10
Definition ItemData.h:15
Definition ItemIconInfo.h:5
Definition Loader.h:15
Definition ItemParseContext.h:14
Definition ItemRegistryComplexAlias.h:10
Definition ItemRegistry.h:55
Definition ItemRegistry.h:64
Definition ItemRegistry.h:86
Definition ItemRegistry.h:73
Definition ItemRegistry.h:95
Definition ReflectionCtx.h:11
Definition ctx.h:5