LeviLamina
Loading...
Searching...
No Matches
Recipes.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/deps/core/string/HashedString.h"
7#include "mc/molang/MolangVersion.h"
8#include "mc/platform/brstd/function_ref.h"
9#include "mc/world/inventory/network/TypedServerNetId.h"
10#include "mc/world/item/ItemInstance.h"
11#include "mc/world/item/SortItemInstanceIdAux.h"
12#include "mc/world/item/crafting/ExternalRecipeStore.h"
13#include "mc/world/item/crafting/RecipeIngredient.h"
14
15// auto generated forward declare list
16// clang-format off
17class BaseGameVersion;
18class Block;
19class Experiments;
20class Item;
21class ItemStackBase;
22class Level;
24class PackInstance;
25class Recipe;
28class SemVersion;
29class ShapedRecipe;
30class ShapelessRecipe;
31struct RecipeNetIdTag;
32namespace Json { class Value; }
33namespace mce { class UUID; }
34// clang-format on
35
36class Recipes {
37public:
38 // Recipes inner types declare
39 // clang-format off
40 struct FurnaceRecipeKey;
42 class Type;
43 // clang-format on
44
45 // Recipes inner types define
47 public:
48 // member variables
49 // NOLINTBEGIN
50 ::ll::TypedStorage<4, 4, int> mID;
51 ::ll::TypedStorage<8, 48, ::HashedString> mTag;
52 // NOLINTEND
53
54 public:
55 // member functions
56 // NOLINTBEGIN
57 MCAPI ~FurnaceRecipeKey();
58 // NOLINTEND
59
60 public:
61 // destructor thunk
62 // NOLINTBEGIN
63 MCFOLD void $dtor();
64 // NOLINTEND
65 };
66
68 public:
69 // member variables
70 // NOLINTBEGIN
71 ::ll::TypedStorage<4, 4, int> mWidth;
72 ::ll::TypedStorage<4, 4, int> mHeight;
73 ::ll::TypedStorage<8, 32, ::std::string> mNormalizedResult;
74 ::ll::TypedStorage<8, 32, ::std::string> mWarning;
75 // NOLINTEND
76
77 public:
78 // member functions
79 // NOLINTBEGIN
81 // NOLINTEND
82
83 public:
84 // destructor thunk
85 // NOLINTBEGIN
86 MCFOLD void $dtor();
87 // NOLINTEND
88 };
89
90 class Type {
91 public:
92 // member variables
93 // NOLINTBEGIN
94 ::ll::TypedStorage<8, 8, ::Item*> mItem;
95 ::ll::TypedStorage<8, 8, ::Block const*> mBlock;
96 ::ll::TypedStorage<8, 24, ::RecipeIngredient> mIngredient;
97 ::ll::TypedStorage<1, 1, char> mC;
98 // NOLINTEND
99
100 public:
101 // member functions
102 // NOLINTBEGIN
103 MCAPI ~Type();
104 // NOLINTEND
105
106 public:
107 // destructor thunk
108 // NOLINTBEGIN
109 MCAPI void $dtor();
110 // NOLINTEND
111 };
112
113 using TypeList = ::std::vector<::Recipes::Type>;
114
115public:
116 // member variables
117 // NOLINTBEGIN
118 ::ll::TypedStorage<8, 8, ::ResourcePackManager*> mResourcePackManager;
119 ::ll::TypedStorage<8, 8, ::ExternalRecipeStore> mExternalRecipeStore;
120 ::ll::TypedStorage<8, 16, ::std::map<::HashedString, ::std::map<::std::string, ::std::shared_ptr<::Recipe>>>>
121 mRecipes;
122 ::ll::TypedStorage<8, 16, ::std::map<::Recipes::FurnaceRecipeKey, ::ItemInstance>> mFurnaceRecipes;
123 ::ll::TypedStorage<1, 1, bool> mInitializing;
124 ::ll::TypedStorage<
125 8,
126 16,
127 ::std::map<::ItemInstance, ::std::unordered_map<::std::string, ::Recipe*>, ::SortItemInstanceIdAux>>
128 mRecipesByOutput;
129 ::ll::TypedStorage<8, 64, ::std::unordered_map<::RecipeNetId, ::Recipe*>> mRecipesByNetId;
130 ::ll::TypedStorage<
131 8,
132 64,
133 ::std::unordered_map<uint64, ::std::unordered_map<uint64, ::std::shared_ptr<::std::vector<::ItemInstance>>>>>
134 mRecipesByInput;
135 ::ll::TypedStorage<8, 24, ::std::vector<::gsl::not_null<::Recipe*>>> mUnlockableRecipes;
136 ::ll::TypedStorage<8, 24, ::std::vector<::std::pair<::std::weak_ptr<bool>, ::std::function<void()>>>> mListeners;
137 ::ll::TypedStorage<8, 8, ::Level*> mLevel;
138 // NOLINTEND
139
140public:
141 // prevent constructor by default
142 Recipes();
143
144public:
145 // member functions
146 // NOLINTBEGIN
147 MCAPI explicit Recipes(::Level* level);
148
149 MCAPI void _addItemRecipe(::std::unique_ptr<::Recipe> recipe);
150
151 MCAPI void _addMapRecipes();
152
153 MCAPI bool _isRecipeValidToAdd(::Recipe const& recipe);
154
155 MCAPI bool _loadBrewingMix(::Json::Value const& objData, ::MinEngineVersion const& minEngineVersion);
156
157 MCAPI void _loadDataDrivenRecipes(::std::vector<::PackInstance> const& resourcePacksNewestToOldest);
158
159 MCAPI void _loadHardcodedRecipes(::BaseGameVersion const& baseGameVersion, ::Experiments const&);
160
161 MCAPI ::RecipeIngredient const _loadIngredientFromJson(
162 ::Json::Value const& obj,
163 ::MolangVersion molangVersion,
164 bool allowItemCount,
165 bool allowItemGroup
166 ) const;
167
168 MCAPI ::RecipeIngredient const
169 _loadInputIngredientFromJson(::Json::Value const& obj, ::MinEngineVersion const& minEngineVersion) const;
170
171 MCAPI bool _loadSmithingTransform(
172 ::Json::Value const& objData,
173 ::MolangVersion molangVersion,
174 ::std::string const& recipeId,
175 ::std::vector<::HashedString> const& tags
176 );
177
178 MCAPI bool _loadSmithingTrim(
179 ::Json::Value const& objData,
180 ::MolangVersion molangVersion,
181 ::std::string const& recipeId,
182 ::std::vector<::HashedString> const& tags
183 );
184
185 MCAPI ::std::optional<::RecipeUnlockingRequirement> _loadUnlockingRequirementFromJson(
186 ::Json::Value const& obj,
187 ::MolangVersion molangVersion,
188 ::std::string const& recipeId
189 ) const;
190
191 MCAPI void addDyedItemRecipe(
192 ::std::string recipeId,
193 ::ItemInstance const& result,
194 ::RecipeIngredient itemToDye,
196 ::RecipeUnlockingRequirement unlockingReq,
197 int priority,
198 ::SemVersion const& formatVersion
199 );
200
201 MCAPI void addFurnaceRecipeAuxData(
202 ::ItemInstance const& input,
203 ::ItemInstance const& result,
204 ::std::vector<::HashedString> const& tags
205 );
206
207#ifdef LL_PLAT_C
208 MCAPI void addNetMappedRecipe(::RecipeNetId const& recipeNetId, ::std::unique_ptr<::Recipe> recipe);
209
210 MCAPI void addRecipeListener(::std::weak_ptr<bool> lifePtr, ::std::function<void()> callback);
211#endif
212
213 MCAPI void addShapedRecipe(
214 ::std::string recipeId,
215 ::ItemInstance const& result,
216 ::std::string const& r0,
217 ::std::vector<::Recipes::Type> const& types,
218 ::std::vector<::HashedString> const& tags,
219 int priority,
220 ::std::function<::std::unique_ptr<::ShapedRecipe>(
221 ::std::string,
222 int,
223 int,
224 ::std::vector<::RecipeIngredient> const&,
225 ::std::vector<::ItemInstance> const&,
227 bool,
228 int,
229 ::mce::UUID const*,
231 ::SemVersion const&
232 )> constructor,
233 ::RecipeUnlockingRequirement const& unlockingReq,
234 ::SemVersion const& formatVersion,
235 bool assumeSymmetry
236 );
237
238 MCAPI void addShapedRecipe(
239 ::std::string recipeId,
240 ::std::vector<::ItemInstance> const& result,
241 ::std::vector<::std::string> const& rows,
242 ::std::vector<::Recipes::Type> const& types,
243 ::std::vector<::HashedString> const& tags,
244 int priority,
245 ::std::function<::std::unique_ptr<::ShapedRecipe>(
246 ::std::string,
247 int,
248 int,
249 ::std::vector<::RecipeIngredient> const&,
250 ::std::vector<::ItemInstance> const&,
252 bool,
253 int,
254 ::mce::UUID const*,
256 ::SemVersion const&
257 )> constructor,
258 ::RecipeUnlockingRequirement const& unlockingReq,
259 ::SemVersion const& formatVersion,
260 bool assumeSymmetry
261 );
262
263 MCAPI void addShapedRecipe(
264 ::std::string recipeId,
265 ::ItemInstance const& result,
266 ::std::vector<::std::string> const& rows,
267 ::std::vector<::Recipes::Type> const& types,
268 ::std::vector<::HashedString> const& tags,
269 int priority,
270 ::std::function<::std::unique_ptr<::ShapedRecipe>(
271 ::std::string,
272 int,
273 int,
274 ::std::vector<::RecipeIngredient> const&,
275 ::std::vector<::ItemInstance> const&,
277 bool,
278 int,
279 ::mce::UUID const*,
281 ::SemVersion const&
282 )> constructor,
283 ::RecipeUnlockingRequirement const& unlockingReq,
284 ::SemVersion const& formatVersion,
285 bool assumeSymmetry
286 );
287
288 MCAPI void addShapedRecipe(
289 ::std::string recipeId,
290 ::ItemInstance const& result,
291 ::std::string const& r0,
292 ::std::string const& r1,
293 ::std::vector<::Recipes::Type> const& types,
294 ::std::vector<::HashedString> const& tags,
295 int priority,
296 ::std::function<::std::unique_ptr<::ShapedRecipe>(
297 ::std::string,
298 int,
299 int,
300 ::std::vector<::RecipeIngredient> const&,
301 ::std::vector<::ItemInstance> const&,
303 bool,
304 int,
305 ::mce::UUID const*,
307 ::SemVersion const&
308 )> constructor,
309 ::RecipeUnlockingRequirement const& unlockingReq,
310 ::SemVersion const& formatVersion,
311 bool assumeSymmetry
312 );
313
314 MCAPI void addShapedRecipe(
315 ::std::string recipeId,
316 ::ItemInstance const& result,
317 ::std::string const& r0,
318 ::std::string const& r1,
319 ::std::string const& r2,
320 ::std::vector<::Recipes::Type> const& types,
321 ::std::vector<::HashedString> const& tags,
322 int priority,
323 ::std::function<::std::unique_ptr<::ShapedRecipe>(
324 ::std::string,
325 int,
326 int,
327 ::std::vector<::RecipeIngredient> const&,
328 ::std::vector<::ItemInstance> const&,
330 bool,
331 int,
332 ::mce::UUID const*,
334 ::SemVersion const&
335 )> constructor,
336 ::RecipeUnlockingRequirement const& unlockingReq,
337 ::SemVersion const& formatVersion,
338 bool assumeSymmetry
339 );
340
341 MCAPI void addShapelessRecipe(
342 ::std::string recipeId,
343 ::ItemInstance const& result,
344 ::std::vector<::Recipes::Type> const& types,
345 ::std::vector<::HashedString> const& tags,
346 int priority,
347 ::std::function<::std::unique_ptr<::ShapelessRecipe>(
348 ::std::string,
349 ::std::vector<::RecipeIngredient> const&,
350 ::std::vector<::ItemInstance> const&,
352 int,
353 ::mce::UUID const*,
355 ::SemVersion const&
356 )> constructor,
357 ::RecipeUnlockingRequirement const& unlockingReq,
358 ::SemVersion const& formatVersion
359 );
360
361 MCAPI void addShulkerBoxRecipe(
362 ::std::string& recipeId,
363 ::ItemInstance const& result,
364 ::std::vector<::Recipes::Type> const& types,
365 ::std::vector<::HashedString> const& tags,
366 ::RecipeUnlockingRequirement const& unlockingReq,
367 ::SemVersion const& formatVersion
368 );
369
370 MCAPI void clearRecipes();
371
372 MCAPI ::SemVersion extractRecipeFormatVersion(::Json::Value const& obj);
373
374 MCAPI ::std::pair<::std::string, ::Json::Value> extractRecipeObjInfo(::Json::Value const& obj);
375
376#ifdef LL_PLAT_C
377 MCAPI void forEachRecipeFor(::HashedString const& tag, ::brstd::function_ref<void(::Recipe const&)> callback) const;
378
379 MCAPI void forEachRecipeFor(
380 ::std::vector<::std::string> const& tags,
381 ::brstd::function_ref<void(::Recipe const&)> callback
382 ) const;
383
384 MCAPI void forEachRecipeFor(
385 ::ItemInstance const& result,
386 ::HashedString const& tag,
387 ::brstd::function_ref<void(::Recipe const&)> callback
388 ) const;
389
390 MCAPI void forEachRecipeFor(
391 ::ItemInstance const& result,
392 ::std::vector<::std::string> const& tags,
393 ::brstd::function_ref<void(::Recipe const&)> callback
394 ) const;
395
396 MCAPI void forEachRecipeUntil(
397 ::ItemInstance const& result,
398 ::HashedString const& tag,
399 ::brstd::function_ref<bool(::Recipe const&)> callback
400 ) const;
401
402 MCAPI void forEachRecipeUntil(
403 ::ItemInstance const& result,
404 ::std::vector<::std::string> const& tags,
405 ::brstd::function_ref<bool(::Recipe const&)> callback
406 ) const;
407#endif
408
409 MCAPI ::std::vector<::ItemInstance>
410 getFurnaceRecipeFor(::ItemStackBase const& output, ::HashedString const& tag) const;
411
412 MCAPI ::ItemInstance getFurnaceRecipeResult(::ItemStackBase const& item, ::HashedString const& tag) const;
413
414 MCAPI ::Recipe const* getRecipeByNetId(::RecipeNetId const& netId) const;
415
416 MCAPI ::Recipe* getRecipeFor(::ItemInstance const& result, ::HashedString const& tag) const;
417
418 MCAPI void init(
419 ::ResourcePackManager& resourcePackManager,
420 ::ExternalRecipeStore& recipeStorage,
421 ::BaseGameVersion const& baseGameVersion,
422 ::Experiments const& experiments
423 );
424
425 MCAPI bool loadRecipe(
426 ::std::pair<::std::string, ::Json::Value> const& recipeObjInfo,
427 ::MinEngineVersion const& minEngineVersion,
428 ::SemVersion const& formatVersion,
429 bool isBaseGamePack
430 );
431
432#ifdef LL_PLAT_C
433 MCAPI void notifyRecipeListeners();
434#endif
435
436 MCAPI ~Recipes();
437 // NOLINTEND
438
439public:
440 // static functions
441 // NOLINTBEGIN
442 MCAPI static ::Recipes::NormalizedRectangularRecipeResults
443 _normalizeRectangularRecipe(::std::vector<::std::string> const& rows);
444 // NOLINTEND
445
446public:
447 // constructor thunks
448 // NOLINTBEGIN
449 MCAPI void* $ctor(::Level* level);
450 // NOLINTEND
451
452public:
453 // destructor thunk
454 // NOLINTBEGIN
455 MCAPI void $dtor();
456 // NOLINTEND
457};
Definition BaseGameVersion.h:8
Definition Block.h:43
Definition Experiments.h:14
Definition ExternalRecipeStore.h:10
Definition HashedString.h:5
Definition ItemInstance.h:15
Definition ItemStackBase.h:44
Definition Item.h:68
Definition Value.h:16
Definition Level.h:250
Definition MinEngineVersion.h:10
Definition PackInstance.h:17
Definition RecipeIngredient.h:17
Definition RecipeUnlockingRequirement.h:10
Definition Recipe.h:31
Definition Recipes.h:90
Definition ResourcePackManager.h:30
Definition SemVersion.h:15
Definition ShapedRecipe.h:16
Definition ShapelessRecipe.h:16
Definition function_ref.h:60
Definition UUID.h:7
Definition RecipeNetIdTag.h:5
Definition Recipes.h:46
Definition SortItemInstanceIdAux.h:5