LeviLamina
Loading...
Searching...
No Matches
ItemStackBase.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4#include "mc/world/level/Tick.h"
5
6class IDataInput;
7
8// auto generated inclusion list
9#include "mc/common/WeakPtr.h"
10#include "mc/deps/shared_types/item/ItemCooldownType.h"
11#include "mc/deps/shared_types/legacy/actor/ArmorSlot.h"
12#include "mc/world/level/Tick.h"
13
14// auto generated forward declare list
15// clang-format off
16class Actor;
17class Block;
18class BlockPalette;
19class BlockType;
20class ComponentItem;
21class CompoundTag;
24class HashedString;
25class IDataInput;
26class Item;
27class ItemDescriptor;
28class ItemEnchants;
29class ItemInstance;
30class ItemStack;
31class Level;
33class Player;
35class RenderParams;
36class SaveContext;
37class Vec3;
39namespace Bedrock::Safety { class RedactableString; }
40namespace Json { class Value; }
41namespace mce { class Color; }
42// clang-format on
43
44class ItemStackBase {
45public:
46 // ItemStackBase inner types declare
47 // clang-format off
48 struct ComparisonOptions;
49 // clang-format on
50
51 // ItemStackBase inner types define
53 public:
54 // member variables
55 // NOLINTBEGIN
56 ::ll::TypedStorage<1, 1, bool> mCompareAux;
57 ::ll::TypedStorage<1, 1, bool> mCompareRelevantUserData;
58 ::ll::TypedStorage<1, 1, bool> mCompareDamage;
59 // NOLINTEND
60 };
61
62public:
63 LLNDAPI std::string getTypeName() const;
64 LLNDAPI std::string getDescriptionName() const;
65 LLNDAPI bool isEnchanted() const;
66 LLNDAPI bool removeEnchants() const;
67 LLAPI void deserializeComponents(IDataInput& input);
68
69public:
70 // member variables
71 // NOLINTBEGIN
73 ::std::unique_ptr<::CompoundTag> mUserData;
74 ::Block const* mBlock;
75 short mAuxValue;
76 uchar mCount;
77 bool mValid_DeprecatedSeeComment;
78 bool mShowPickUp;
79 bool mWasPickedUp;
80 ::std::chrono::steady_clock::time_point mPickupTime;
81 ::std::vector<::BlockType const*> mCanPlaceOn;
82 uint64 mCanPlaceOnHash;
83 ::std::vector<::BlockType const*> mCanDestroy;
84 uint64 mCanDestroyHash;
85 ::Tick mBlockingTick;
86 ::std::unique_ptr<::ItemInstance> mChargedItem;
87 // NOLINTEND
88
89public:
90 // prevent constructor by default
91 ItemStackBase();
92
93public:
94 // virtual functions
95 // NOLINTBEGIN
96 virtual ~ItemStackBase();
97
98 virtual void reinit(::Item const& item, int count, int auxValue);
99
100 virtual void reinit(::Block const& block, int count);
101
102 virtual void reinit(::std::string_view const name, int count, int auxValue);
103
104 virtual void setNull(::std::optional<::std::string> reason);
105
106 virtual ::std::string toString() const;
107
108 virtual ::std::string toDebugString() const;
109 // NOLINTEND
110
111public:
112 // member functions
113 // NOLINTBEGIN
114 MCAPI explicit ItemStackBase(::RecipeIngredient const& ingredient);
115
116 MCAPI ItemStackBase(::ItemStackBase const& rhs);
117
118 MCAPI ItemStackBase(::Block const& block, int count = 1, ::CompoundTag const* _userData = nullptr);
119
120 MCAPI
121 ItemStackBase(::std::string_view name, int count = 1, int auxValue = 0, ::CompoundTag const* _userData = nullptr);
122
123 MCAPI void _addCustomUserDataCommon(::std::unique_ptr<::CompoundTag>&& tag);
124
125 MCAPI void _checkForItemWorldCompatibility();
126
127 MCAPI ::std::string _getHoverFormattingPrefix() const;
128
129#ifdef LL_PLAT_C
130 MCAPI bool _hasFullOrPartialTag(::HashedString const& string) const;
131#endif
132
133 MCAPI void _loadComponents(::CompoundTag const& compoundTag);
134
135 MCAPI void _loadItem(::CompoundTag const& compoundTag);
136
137 MCAPI void _setChargedItem(::ItemInstance const& item);
138
139 MCAPI bool _setItem(int id, bool doRemap);
140
141 MCAPI void _setItemFromBlockName(::HashedString const& blockName);
142
143 MCAPI void _updateCompareHashes();
144
145 MCAPI void add(int inCount);
146
147 MCAPI bool addComponents(::Json::Value const& root, ::std::string& errorMsg);
148
149 MCAPI void addCustomUserData(::ContainerComponent const& containerComponent);
150
151 MCAPI void clearChargedItem();
152
153 MCAPI void clearCustomLore();
154
155 MCAPI ::ItemEnchants constructItemEnchantsFromUserData() const;
156
157 MCAPI ::SharedTypes::Legacy::ArmorSlot getArmorSlot() const;
158
159 MCAPI short getAuxValue() const;
160
161 MCAPI int getBaseRepairCost() const;
162
163#ifdef LL_PLAT_C
164 MCAPI ::Block const* getBlockForRendering() const;
165#endif
166
167 MCAPI ::WeakPtr<::BlockType const> const& getBlockType() const;
168
169#ifdef LL_PLAT_C
170 MCAPI ::WeakPtr<::BlockType const> const& getBlockTypeForRendering() const;
171#endif
172
173 MCAPI ::mce::Color getColor() const;
174
175 MCAPI ::ComponentItem const* getComponentItem() const;
176
177 MCAPI ::std::vector<::std::string> getCustomLore() const;
178
179 MCAPI ::std::string getCustomName() const;
180
181 MCAPI short getDamageValue() const;
182
183 MCAPI ::std::string getDescriptionId() const;
184
185 MCAPI ::ItemDescriptor getDescriptor() const;
186
187 MCAPI ::std::unique_ptr<::DynamicProperties> getDynamicProperties() const;
188
189 MCAPI ::std::optional<::std::variant<double, float, bool, ::std::string, ::Vec3>>
190 getDynamicProperty(::std::string const& key, ::std::string const& collectionName) const;
191
192#ifdef LL_PLAT_C
193 MCAPI ::Bedrock::Safety::RedactableString getFormattedHovertext(::Level& level, bool showCategory) const;
194#endif
195
196 MCAPI ::HashedString const& getFullNameHash() const;
197
198#ifdef LL_PLAT_C
199 MCAPI ::std::string getHoverName() const;
200
201 MCAPI ::ResolvedItemIconInfo getIconInfo(int newAnimationFrame, bool inInventoryPane) const;
202#endif
203
204 MCAPI short getId() const;
205
206 MCAPI int getIdAux() const;
207
208#ifdef LL_PLAT_C
209 MCAPI int getIdAuxEnchanted() const;
210
211 MCAPI bool getIsValidPickupTime() const;
212#endif
213
214 MCAPI ::Item const* getItem() const;
215
216 MCAPI short getMaxDamage() const;
217
218 MCAPI uchar getMaxStackSize() const;
219
220 MCAPI ::std::string getName() const;
221
222 MCAPI ::std::unique_ptr<::CompoundTag> getNetworkUserData() const;
223
224 MCAPI ::HashedString const& getRawNameHash() const;
225
226 MCAPI ::std::string getRawNameId() const;
227
228 MCAPI ::Bedrock::Safety::RedactableString getRedactedCustomName() const;
229
230 MCAPI ::Bedrock::Safety::RedactableString getRedactedHoverName() const;
231
232 MCAPI ::Bedrock::Safety::RedactableString getRedactedName() const;
233
234#ifdef LL_PLAT_C
235 MCAPI ::HashedString const& getRendererId() const;
236
237 MCAPI bool hasChargedItem() const;
238
239 MCAPI bool hasComponent(::std::string const& name) const;
240#endif
241
242 MCAPI bool hasContainerData() const;
243
244 MCAPI bool hasCustomHoverName() const;
245
246 MCAPI bool hasSameAuxValue(::ItemStackBase const& other) const;
247
248 MCAPI bool hasSameUserData(::ItemStackBase const& other) const;
249
250 MCAPI bool hurtAndBreak(int deltaDamage, ::Actor* owner);
251
252 MCAPI void init(::BlockType const& block, int count);
253
254 MCAPI void init(int id, int count_, int aux_, bool doRemap);
255
256 MCAPI void init(::Item const& item, int count, int auxValue, ::CompoundTag const* userData, bool doRemap);
257
258 MCAPI bool isArmorItem() const;
259
260#ifdef LL_PLAT_C
261 MCAPI bool isAttachableEquipment() const;
262
263 MCAPI bool isBlock() const;
264
265 MCAPI bool isBlockInstance(::HashedString const& blockName) const;
266#endif
267
268 MCAPI bool isDamageableItem() const;
269
270#ifdef LL_PLAT_C
271 MCAPI bool isDamaged() const;
272#endif
273
274 MCAPI bool isEnchantingBook() const;
275
276 MCAPI bool isGlint() const;
277
278 MCAPI bool isHorseArmorItem() const;
279
280 MCAPI bool isHumanoidArmorItem() const;
281
282 MCAPI bool isHumanoidWearableBlockItem() const;
283
284 MCAPI bool isInstance(::HashedString const& itemName, bool useItemLookup) const;
285
286#ifdef LL_PLAT_C
287 MCAPI bool isLiquidClipItem() const;
288#endif
289
290 MCAPI bool isNull() const;
291
292#ifdef LL_PLAT_C
293 MCAPI bool isOnCooldown(::Player& player, ::SharedTypes::ItemCooldownType type) const;
294#endif
295
296 MCAPI bool
297 isOneOfBlockInstances(::std::vector<::std::reference_wrapper<::HashedString const>> const& blockTypeIds) const;
298
299 MCAPI bool isOneOfInstances(
300 ::std::initializer_list<::std::reference_wrapper<::HashedString const>> items,
301 bool useItemLookup
302 ) const;
303
304 MCAPI bool isPotionItem() const;
305
306#ifdef LL_PLAT_C
307 MCAPI bool isStackable() const;
308#endif
309
310 MCAPI bool isStackable(::ItemStackBase const& other) const;
311
312 MCAPI bool isStackedByData() const;
313
314 MCAPI bool isValidAuxValue(int value) const;
315
316#ifdef LL_PLAT_C
317 MCFOLD bool matches(::ItemStackBase const& other) const;
318#endif
319
320 MCAPI bool matchesEitherWearableCase(::CompoundTag const* userData) const;
321
322 MCAPI bool matchesItem(::ItemStackBase const& other) const;
323
324 MCAPI explicit operator bool() const;
325
326 MCAPI bool operator!=(::ItemStackBase const& rhs) const;
327
328 MCAPI ::ItemStackBase& operator=(::ItemStackBase const& rhs);
329
330 MCFOLD bool operator==(::ItemStackBase const& rhs) const;
331
332 MCAPI void remove(int inCount);
333
334 MCAPI void removeDamageValue();
335
336 MCAPI void resetHoverName();
337
338 MCAPI bool sameItem(int itemId, int auxValue) const;
339
340 MCAPI ::std::unique_ptr<::CompoundTag> save(::SaveContext const& saveContext) const;
341
342 MCAPI void saveEnchantsToUserData(::ItemEnchants const& enchant);
343
344 MCAPI bool sendEventTriggered(::std::string const& event, ::RenderParams const& params);
345
346 MCAPI void set(int inCount);
347
348 MCAPI void setChargedItem(::ItemInstance const& instance, bool isSwapping);
349
350 MCAPI void setCustomLore(::std::vector<::std::string> const& lore);
351
352 MCAPI void setCustomName(::Bedrock::Safety::RedactableString const& name);
353
354 MCAPI void setDamageValue(short newDamage);
355
356 MCAPI void setDynamicProperty(
357 ::std::string const& key,
358 ::std::variant<double, float, bool, ::std::string, ::Vec3> const& value,
359 ::std::string const& collectionName
360 );
361
362 MCAPI void setRepairCost(int cost);
363
364 MCAPI void setStackSize(uchar inCount);
365
366 MCAPI void setUserData(::std::unique_ptr<::CompoundTag> tag);
367
368 MCAPI void startCooldown(::Player& player, ::SharedTypes::ItemCooldownType type) const;
369
370 MCAPI bool updateComponent(::std::string const& name, ::Json::Value const& data);
371 // NOLINTEND
372
373public:
374 // static functions
375 // NOLINTBEGIN
376 MCAPI static bool
377 _loadBlocksForCanPlaceOnCanDestroy(::std::vector<::BlockType const*>& blockList, ::std::string const& blockName);
378
379#ifdef LL_PLAT_C
380 MCAPI static void loadItemStacksFromDescriptor(
381 ::std::vector<::ItemStack>& outItems,
382 ::std::vector<::NetworkItemStackDescriptor> const& descriptors,
383 ::BlockPalette& blockPalette,
384 bool isClientSide
385 );
386#endif
387 // NOLINTEND
388
389public:
390 // static variables
391 // NOLINTBEGIN
392 MCAPI static ::std::string const& TAG_CAN_DESTROY();
393
394 MCAPI static ::std::string const& TAG_CAN_PLACE_ON();
395
396 MCAPI static ::std::string const& TAG_CHARGED_ITEM();
397
398 MCAPI static ::std::string const& TAG_DISPLAY();
399
400 MCAPI static ::std::string const& TAG_DISPLAY_FILTERED_NAME();
401
402 MCAPI static ::std::string const& TAG_DISPLAY_NAME();
403
404 MCAPI static ::std::string const& TAG_ENCHANTS();
405
406 MCAPI static ::std::string const& TAG_LORE();
407
408 MCAPI static ::std::string const& TAG_REPAIR_COST();
409
410 MCAPI static ::std::string const& TAG_STORE_CAN_DESTROY();
411
412 MCAPI static ::std::string const& TAG_STORE_CAN_PLACE_ON();
413
414 MCAPI static ::std::string const& TAG_UNBREAKABLE();
415 // NOLINTEND
416
417public:
418 // constructor thunks
419 // NOLINTBEGIN
420 MCAPI void* $ctor(::RecipeIngredient const& ingredient);
421
422 MCAPI void* $ctor(::ItemStackBase const& rhs);
423
424 MCAPI void* $ctor(::Block const& block, int count, ::CompoundTag const* _userData);
425
426 MCAPI void* $ctor(::std::string_view name, int count, int auxValue, ::CompoundTag const* _userData);
427 // NOLINTEND
428
429public:
430 // destructor thunk
431 // NOLINTBEGIN
432 MCAPI void $dtor();
433 // NOLINTEND
434
435public:
436 // virtual function thunks
437 // NOLINTBEGIN
438 MCFOLD void $reinit(::Item const& item, int count, int auxValue);
439
440 MCFOLD void $reinit(::Block const& block, int count);
441
442 MCFOLD void $reinit(::std::string_view const name, int count, int auxValue);
443
444 MCAPI void $setNull(::std::optional<::std::string> reason);
445
446 MCAPI ::std::string $toString() const;
447
448 MCAPI ::std::string $toDebugString() const;
449
450
451 // NOLINTEND
452
453public:
454 // vftables
455 // NOLINTBEGIN
456 MCNAPI static void** $vftable();
457 // NOLINTEND
458};
Definition Actor.h:106
Definition RedactableString.h:10
Definition BlockPalette.h:19
Definition BlockType.h:84
Definition Block.h:43
Definition ComponentItem.h:54
Definition CompoundTag.h:23
Definition ContainerComponent.h:28
Definition DynamicProperties.h:13
Definition HashedString.h:5
Definition IDataInput.h:8
Definition ItemDescriptor.h:24
Definition ItemEnchants.h:17
Definition ItemInstance.h:15
static MCAPI void ** $vftable()
Definition ItemStack.h:26
Definition Item.h:68
Definition Value.h:16
Definition Level.h:250
Definition NetworkItemStackDescriptor.h:17
Definition Player.h:129
Definition RecipeIngredient.h:17
Definition RenderParams.h:30
Definition SaveContext.h:5
Definition Vec3.h:10
Definition WeakPtr.h:10
Definition Color.h:13
Definition ItemStackBase.h:52
Definition ResolvedItemIconInfo.h:8
Definition Tick.h:5