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