Skip to content
LeviMC
English
AutoLightDark
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/ItemRegistrationState.h"
18#include "mc/world/item/registry/ItemRegistryRef.h"
19
20// auto generated forward declare list
21// clang-format off
25class 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&,
117 );
118
119public:
120 // member variables
121 // NOLINTBEGIN
122 ::ll::TypedStorage<8, 8, ::gsl::not_null<::std::unique_ptr<::cereal::ReflectionCtx>>> mCerealContext;
123 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::LinkedAssetValidator>> mValidator;
124 ::ll::TypedStorage<8, 8, ::gsl::not_null<::std::unique_ptr<::ItemLoaderTraits::Loader>>> mDocumentLoader;
125 ::ll::TypedStorage<8, 24, ::std::vector<::SharedPtr<::Item>>> mItemRegistry;
126 ::ll::TypedStorage<8, 64, ::std::unordered_map<int, ::WeakPtr<::Item>>> mIdToItemMap;
127 ::ll::TypedStorage<8, 64, ::std::unordered_map<::HashedString, ::WeakPtr<::Item>>> mNameToItemMap;
128 ::ll::TypedStorage<8, 64, ::std::unordered_map<::HashedString, ::WeakPtr<::Item>>> mTileNamespaceToItemMap;
129 ::ll::TypedStorage<8, 64, ::std::unordered_map<::HashedString, ::WeakPtr<::Item>>> mTileItemNameToItemMap;
130 ::ll::TypedStorage<8, 64, ::std::unordered_map<::HashedString, ::ItemRegistry::ItemAlias>> mItemAliasLookupMap;
131 ::ll::TypedStorage<8, 64, ::std::unordered_map<uint64, ::ItemRegistry::ItemHashAlias>> mReverseAliasLookupMap;
132 ::ll::TypedStorage<8, 64, ::std::unordered_map<uint64, ::ItemRegistry::ItemHashAlias>>
133 mReverseFullNameAliasLookupMap;
134 ::ll::TypedStorage<8, 64, ::std::unordered_map<::HashedString, ::ItemRegistryComplexAlias>> mComplexAliasLookupMap;
135 ::ll::TypedStorage<8, 64, ::std::unordered_map<short, ::HashedString>> mLegacyIDToNameMap;
136 ::ll::TypedStorage<2, 2, short> mMaxItemID;
137 ::ll::TypedStorage<8, 24, ::std::vector<::HashedString>> mAttachableDefinitions;
138 ::ll::TypedStorage<8, 64, ::std::unordered_map<::ItemTag, ::std::unordered_set<::Item const*>>> mTagToItemsMap;
139 ::ll::TypedStorage<8, 64, ::std::unordered_set<::Item const*> const> mEmptyItemSet;
140 ::ll::TypedStorage<1, 1, bool> mServerInitializingCreativeItems;
141 ::ll::TypedStorage<1, 1, ::ItemRegistrationState> mItemRegistrationState;
142 ::ll::TypedStorage<8, 64, ::std::function<void(::ItemRegistryRef)>> mExtraItemInitCallback;
143 ::ll::TypedStorage<
144 8,
145 8,
147 mFinishedInitServerPublisher;
148 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::std::atomic<int>>> mCanUpdateTags;
149 ::ll::TypedStorage<8, 24, ::std::vector<::SharedPtr<::Item>>> mDeadItemRegistry;
150 ::ll::TypedStorage<1, 1, bool> mAddToPreRegistry;
151 ::ll::TypedStorage<8, 64, ::std::unordered_map<::HashedString, ::SharedPtr<::Item>>>
152 mHardcodedVanillaItemPreRegistry;
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 MCNAPI ItemRegistry();
163
164#ifdef LL_PLAT_C
165 MCNAPI void _bindBetaItemTypes(::Experiments const& experiments);
166
167 MCNAPI void _movePreRegistryToMainRegistry();
168
169 MCNAPI void _populateVanillaItemVersionMap(
170 ::ItemRegistry::LoadedItemAsset const& loadedItemAsset,
171 ::ItemParseContext& parseContext
172 );
173#endif
174
175 MCNAPI void _preRegisterItem(::HashedString const& itemName, ::SharedPtr<::Item> item);
176
177#ifdef LL_PLAT_C
178 MCNAPI ::WeakPtr<::Item>
179 _registerOrPromoteItem(::HashedString const& itemName, bool isComponentBased, ::cereal::ReflectionCtx const& ctx);
180#endif
181
182 MCNAPI ::ItemRegistry::ParsedName _tryParseItemName(::Puv::Input const& input);
183
184 MCNAPI ::ItemRegistryRef::LoadedItem
186
187 MCNAPI void addItemToTagMap(::Item const& item);
188
190
191#ifdef LL_PLAT_C
192 MCNAPI void buildClientRegistryFromServer(
193 ::std::vector<::ItemData> const& serverItemData,
194 ::Experiments const& experiments,
195 ::BaseGameVersion const& baseGameVersion,
196 ::IEducationOptions const& educationOptions
197 );
198#endif
199
200#ifdef LL_PLAT_S
201 MCNAPI void buildServerRegistry(
202 ::Experiments const& experiments,
203 ::BaseGameVersion const& baseGameVersion,
204 ::IEducationOptions const& educationOptions,
207 ::IMinecraftEventing& eventing
208 );
209#endif
210
212
213#ifdef LL_PLAT_C
214 MCNAPI void findAllAttachableDefinitions();
215
216 MCNAPI void finishedRegistration(::Experiments const& experiments);
217#endif
218
219 MCNAPI ::std::vector<::std::reference_wrapper<::HashedString const>> const&
221
222 MCFOLD ::WeakPtr<::Item> getItem(::HashedString const& id);
223
224 MCAPI ::WeakPtr<::Item> getItem(short id);
225
226 MCNAPI ::std::pair<::HashedString, int> getNameFromAlias(::HashedString const& name, int aux) const;
227
228 MCNAPI bool isComplexAlias(::HashedString const& oldName) const;
229
230 MCNAPI ::WeakPtr<::Item> lookupByName(int& inOutItemAux, ::std::string_view inString) const;
231
232 MCNAPI ::WeakPtr<::Item> lookupByName(int& outItemId, int& inOutItemAux, ::std::string_view inString) const;
233
234 MCAPI ::WeakPtr<::Item> lookupByNameNoAlias(::std::string_view inString) const;
235
236 MCNAPI ::WeakPtr<::Item> lookupByNameNoParsing(int& inOutItemAux, ::HashedString const& fullName) const;
237
238 MCNAPI ::WeakPtr<::Item> lookupByVanillaName(::HashedString const& inString) const;
239
240#ifdef LL_PLAT_C
241 MCNAPI void populateClientItemData(
242 ::ResourcePackManager& resourcePackManager,
243 ::Experiments const& experiments,
244 ::std::optional<::ItemIconInfo> (*iconFactory)(::std::string const&, int)
245 );
246#endif
247
248 MCNAPI void
249 registerAlias(::HashedString const& alias, ::HashedString const& name, ::BaseGameVersion const& fromVersion);
250
251 MCNAPI ::WeakPtr<::Item>
253
254 MCAPI void registerItem(::SharedPtr<::Item> item);
255
257 ::HashedString const& alias,
258 ::HashedString const& name,
259 ::BaseGameVersion const& fromVersion
260 );
261
262 MCNAPI void registerValidatorIdentifier(::std::string const& str);
263
264 MCNAPI uint64 remapToFullLegacyNameByHash(uint64 newHash);
265
266 MCNAPI uint64 remapToLegacyNameByHash(uint64 newHash);
267
268 MCNAPI void shutdown();
269
270 MCAPI void unregisterItem(::HashedString const& itemName);
271
272 MCNAPI ::std::vector<::std::string> validateServerItemComponents(::std::vector<::ItemData> const& items);
273
275 // NOLINTEND
276
277public:
278 // static functions
279 // NOLINTBEGIN
280#ifdef LL_PLAT_C
281 MCNAPI static ::std::vector<::ItemRegistry::LoadedItemAsset> _loadAllItemAssets(
282 ::ResourcePackManager const& resourcePackManager,
283 ::Experiments const& experiments,
285 );
286#endif
287 // NOLINTEND
288
289public:
290 // constructor thunks
291 // NOLINTBEGIN
292 MCNAPI void* $ctor();
293 // NOLINTEND
294
295public:
296 // destructor thunk
297 // NOLINTBEGIN
298 MCNAPI void $dtor();
299 // NOLINTEND
300};
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 IEducationOptions.h:8
Definition IMinecraftEventing.h:152
Definition ItemEventResponseFactory.h:17
Definition ItemRegistryRef.h:36
MCAPI::ItemRegistry::ParsedName _tryParseItemName(::Puv::Input const &input)
MCAPI void registerAlias(::HashedString const &alias, ::HashedString const &name, ::BaseGameVersion const &fromVersion)
MCAPI::ItemRegistryRef::LoadedItem _tryRegisterAndInitItem(::ItemRegistry::LoadedItemAsset const &loadedItemAsset, ::ItemParseContext &parseContext)
MCAPI void shutdown()
MCAPI void registerLegacyMapping(::HashedString const &alias, ::HashedString const &name, ::BaseGameVersion const &fromVersion)
MCAPI void addItemToTagMap(::Item const &item)
MCAPI void clearItemAndCreativeItemRegistry()
MCAPI void _preRegisterItem(::HashedString const &itemName, ::SharedPtr<::Item > item)
MCAPI ::std::vector<::std::string > validateServerItemComponents(::std::vector<::ItemData > const &items)
MCAPI ::WeakPtr<::Item > lookupByName(int &outItemId, int &inOutItemAux, ::std::string_view inString) const
MCAPI void * $ctor()
MCAPI void alterAvailableCreativeItems(::ActorInfoRegistry *registry, ::LevelData &levelData)
MCAPI ::WeakPtr<::Item > lookupByVanillaName(::HashedString const &inString) const
MCAPI void $dtor()
MCAPI void registerValidatorIdentifier(::std::string const &str)
MCAPI bool isComplexAlias(::HashedString const &oldName) const
MCAPI uint64 remapToFullLegacyNameByHash(uint64 newHash)
MCAPI ::WeakPtr<::Item > lookupByName(int &inOutItemAux, ::std::string_view inString) const
MCAPI ItemRegistry()
MCAPI uint64 remapToLegacyNameByHash(uint64 newHash)
MCAPI ::std::pair<::HashedString, int > getNameFromAlias(::HashedString const &name, int aux) const
MCAPI ::std::vector<::std::reference_wrapper<::HashedString const > > const & getComplexAliasSplitNames(::HashedString const &oldName) const
MCAPI ~ItemRegistry()
MCAPI ::WeakPtr<::Item > lookupByNameNoParsing(int &inOutItemAux, ::HashedString const &fullName) const
MCAPI ::WeakPtr<::Item > registerComplexAlias(::HashedString const &alias, ::ItemRegistryComplexAlias const &complexAlias)
Definition Item.h:73
Definition LevelData.h:57
Definition LinkedAssetValidator.h:9
Definition Input.h:18
Definition ResourcePackManager.h:29
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