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 BlockActor;
19class BlockPalette;
20class BlockSource;
21class BlockType;
22class CompoundTag;
25class HashedString;
26class IDataOutput;
27class Item;
28class ItemDescriptor;
29class ItemEnchants;
30class ItemInstance;
31class ItemStack;
32class Level;
34class Player;
36class SaveContext;
37class Vec3;
38struct ItemTag;
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 LLAPI bool operator==(ItemStackBase const& other) const;
69 LLNDAPI short getId() const;
70 LLNDAPI short getAuxValue() const;
71 LLAPI void setDamageValue(short newDamage);
72 inline void add(int count) { set(mCount + count); }
73 inline void remove(int count) { set(mCount - count); }
74
75
76public:
77 // member variables
78 // NOLINTBEGIN
79 ::WeakPtr<::Item> mItem;
80 ::std::unique_ptr<::CompoundTag> mUserData;
81 ::Block const* mBlock;
82 short mAuxValue;
83 uchar mCount;
84 bool mValid_DeprecatedSeeComment;
85 bool mShowPickUp;
86 bool mWasPickedUp;
87 ::std::chrono::steady_clock::time_point mPickupTime;
88 ::std::vector<::BlockType const*> mCanPlaceOn;
89 uint64 mCanPlaceOnHash;
90 ::std::vector<::BlockType const*> mCanDestroy;
91 uint64 mCanDestroyHash;
92 ::Tick mBlockingTick;
93 ::std::unique_ptr<::ItemInstance> mChargedItem;
94 // NOLINTEND
95
96public:
97 // prevent constructor by default
98 ItemStackBase();
99
100public:
101 // virtual functions
102 // NOLINTBEGIN
103 virtual ~ItemStackBase();
104
105 virtual void reinit(::Item const& item, int count, int auxValue);
106
107 virtual void reinit(::Block const& block, int count);
108
109 virtual void reinit(::std::string_view const name, int count, int auxValue);
110
111 virtual void setNull(::std::optional<::std::string> reason);
112
113 virtual ::std::string toString() const;
114
115 virtual ::std::string toDebugString() const;
116 // NOLINTEND
117
118public:
119 // member functions
120 // NOLINTBEGIN
121 MCAPI explicit ItemStackBase(::RecipeIngredient const& ingredient);
122
123 MCAPI ItemStackBase(::ItemStackBase const& rhs);
124
125 MCAPI ItemStackBase(::Block const& block, int count = 1, ::CompoundTag const* _userData = nullptr);
126
127 MCAPI ItemStackBase(::Item const& item, int count = 1, int auxValue = 0, ::CompoundTag const* _userData = nullptr);
128
129 MCAPI
130 ItemStackBase(::std::string_view name, int count = 1, int auxValue = 0, ::CompoundTag const* _userData = nullptr);
131
132 MCAPI void _addCustomUserDataCommon(::std::unique_ptr<::CompoundTag>&& tag);
133
134 MCAPI void _checkForItemWorldCompatibility();
135
136 MCAPI void _cloneComponents(::ItemStackBase const& other);
137
138 MCAPI ::std::string _getHoverFormattingPrefix() const;
139
140#ifdef LL_PLAT_C
141 MCAPI bool _hasFullOrPartialTag(::HashedString const& string) const;
142#endif
143
144 MCAPI bool _isInstance(::std::string_view itemName) const;
145
146 MCAPI void _loadItem(::CompoundTag const& compoundTag);
147
148 MCAPI void _setChargedItem(::ItemInstance const& item);
149
150 MCAPI bool _setItem(int id, bool doRemap);
151
152 MCAPI void _updateCompareHashes();
153
154 MCAPI bool addComponents(::Json::Value const& root, ::std::string& errorMsg);
155
156 MCAPI void addCustomUserData(::ContainerComponent const& containerComponent);
157
158 MCAPI void addCustomUserData(::BlockActor& blockEntity, ::BlockSource& region);
159
160 MCAPI void clearCustomLore();
161
162 MCAPI ::ItemEnchants constructItemEnchantsFromUserData() const;
163
164 MCAPI ::SharedTypes::Legacy::ArmorSlot getArmorSlot() const;
165
166 MCAPI int getBaseRepairCost() const;
167
168#ifdef LL_PLAT_C
169 MCAPI ::Block const* getBlockForRendering() const;
170#endif
171
172 MCAPI ::WeakPtr<::BlockType const> const& getBlockType() const;
173
174#ifdef LL_PLAT_C
175 MCAPI ::WeakPtr<::BlockType const> const& getBlockTypeForRendering() const;
176#endif
177
178 MCAPI ::mce::Color getColor() const;
179
180 MCAPI ::std::vector<::std::string> getCustomLore() const;
181
182 MCAPI ::std::string getCustomName() const;
183
184 MCAPI short getDamageValue() const;
185
186 MCAPI ::std::string getDescriptionId() const;
187
188 MCAPI ::ItemDescriptor getDescriptor() const;
189
190 MCAPI ::std::unique_ptr<::DynamicProperties> getDynamicProperties() const;
191
192 MCAPI ::std::optional<::std::variant<double, float, bool, ::std::string, ::Vec3>>
193 getDynamicProperty(::std::string const& key, ::std::string const& collectionName) const;
194
195#ifdef LL_PLAT_C
196 MCAPI ::Bedrock::Safety::RedactableString getFormattedHovertext(::Level& level, bool showCategory) const;
197#endif
198
199 MCAPI ::HashedString const& getFullNameHash() const;
200
201#ifdef LL_PLAT_C
202 MCAPI ::std::string getHoverName() const;
203#endif
204
205 MCAPI int getIdAux() const;
206
207#ifdef LL_PLAT_C
208 MCAPI int getIdAuxEnchanted() const;
209#endif
210
211 MCAPI uchar getMaxStackSize() const;
212
213 MCAPI ::std::string getName() const;
214
215 MCAPI float getPickupPopPercentage() const;
216
217 MCAPI ::HashedString const& getRawNameHash() const;
218
219 MCAPI ::std::string getRawNameId() const;
220
221 MCAPI ::Bedrock::Safety::RedactableString getRedactedCustomName() const;
222
223 MCAPI ::Bedrock::Safety::RedactableString getRedactedHoverName() const;
224
225 MCAPI ::Bedrock::Safety::RedactableString getRedactedName() const;
226
227 MCAPI bool hasChargedItem() const;
228
229#ifdef LL_PLAT_C
230 MCAPI bool hasComponent(::std::string const& name) const;
231#endif
232
233 MCAPI bool hasSameAuxValue(::ItemStackBase const& other) const;
234
235 MCAPI bool hasSameUserData(::ItemStackBase const& other) const;
236
237 MCAPI bool hasTag(::ItemTag const& string) const;
238
239 MCAPI bool hurtAndBreak(int deltaDamage, ::Actor* owner);
240
241 MCAPI void init(int id, int count_, int aux_, bool doRemap);
242
243 MCAPI void init(::Item const& item, int count, int auxValue, ::CompoundTag const* userData, bool doRemap);
244
245 MCAPI bool isArmorItem() const;
246
247#ifdef LL_PLAT_C
248 MCAPI bool isAttachableEquipment() const;
249#endif
250
251 MCAPI bool isDamageableItem() const;
252
253 MCAPI bool isDamaged() const;
254
255 MCAPI bool isEnchantingBook() const;
256
257 MCAPI bool isFullStack() const;
258
259 MCAPI bool isHorseArmorItem() const;
260
261 MCAPI bool isHumanoidWearableBlockItem() const;
262
263 MCAPI bool isInstance(::HashedString const& itemName, bool useItemLookup) const;
264
265 MCAPI bool isNull() const;
266
267#ifdef LL_PLAT_C
268 MCAPI bool isOnCooldown(::Player& player, ::SharedTypes::ItemCooldownType type) const;
269#endif
270
271 MCAPI bool
272 isOneOfBlockInstances(::std::vector<::std::reference_wrapper<::HashedString const>> const& blockTypeIds) const;
273
274#ifdef LL_PLAT_C
275 MCAPI bool
276 isOneOfBlockInstances(::std::initializer_list<::std::reference_wrapper<::HashedString const>> blocks) const;
277#endif
278
279 MCAPI bool isOneOfInstances(
280 ::std::initializer_list<::std::reference_wrapper<::HashedString const>> items,
281 bool useItemLookup
282 ) const;
283
284 MCAPI bool isPotionItem() const;
285
286 MCAPI bool isStackable() const;
287
288 MCAPI bool isStackable(::ItemStackBase const& other) const;
289
290#ifdef LL_PLAT_C
291 MCAPI bool isTransparentAttachable() const;
292#endif
293
294 MCAPI bool matchesEitherWearableCase(::CompoundTag const* userData) const;
295
296 MCAPI bool matchesItem(::ItemStackBase const& other) const;
297
298 MCAPI explicit operator bool() const;
299
300 MCAPI ::ItemStackBase& operator=(::ItemStackBase const& rhs);
301
302 MCAPI void resetHoverName();
303
304 MCAPI bool sameItem(::ItemStackBase const& other, ::ItemStackBase::ComparisonOptions const& options) const;
305
306 MCAPI ::std::unique_ptr<::CompoundTag> save(::SaveContext const& saveContext) const;
307
308 MCAPI void saveEnchantsToUserData(::ItemEnchants const& enchant);
309
310 MCAPI void serializeComponents(::IDataOutput& output) const;
311
312 MCAPI void set(int inCount);
313
314 MCAPI void setChargedItem(::ItemInstance const& instance, bool isSwapping);
315
316 MCAPI void setCustomLore(::std::vector<::std::string> const& lore);
317
318 MCAPI void setCustomName(::Bedrock::Safety::RedactableString const& name);
319
320 MCAPI void setDynamicProperty(
321 ::std::string const& key,
322 ::std::variant<double, float, bool, ::std::string, ::Vec3> const& value,
323 ::std::string const& collectionName
324 );
325
326 MCAPI void setJustBrewed(bool justBrewed);
327
328 MCAPI void setPickupTime();
329
330 MCAPI void setRepairCost(int cost);
331
332 MCAPI void setUnbreakable(bool isUnbreakable);
333
334 MCAPI void setUserData(::std::unique_ptr<::CompoundTag> tag);
335
336 MCAPI bool shouldVanish() const;
337
338 MCAPI void startCooldown(::Player& player, ::SharedTypes::ItemCooldownType type) const;
339 // NOLINTEND
340
341public:
342 // static functions
343 // NOLINTBEGIN
344 MCAPI static bool
345 _loadBlocksForCanPlaceOnCanDestroy(::std::vector<::BlockType const*>& blockList, ::std::string const& blockName);
346
347#ifdef LL_PLAT_C
348 MCAPI static void loadItemStacksFromDescriptor(
349 ::std::vector<::ItemStack>& outItems,
350 ::std::vector<::NetworkItemStackDescriptor> const& descriptors,
351 ::BlockPalette& blockPalette,
352 bool isClientSide
353 );
354#endif
355 // NOLINTEND
356
357public:
358 // static variables
359 // NOLINTBEGIN
360 MCAPI static ::ItemStackBase::ComparisonOptions const& COMPARISONOPTIONS_AUXANDRELEVANTUSERDATA();
361
362 MCAPI static ::ItemStackBase::ComparisonOptions const& COMPARISONOPTIONS_RELEVANTUSERDATA();
363
364 MCAPI static ::std::string const& TAG_CAN_DESTROY();
365
366 MCAPI static ::std::string const& TAG_CAN_PLACE_ON();
367
368 MCAPI static ::std::string const& TAG_CHARGED_ITEM();
369
370 MCAPI static ::std::string const& TAG_DISPLAY();
371
372 MCAPI static ::std::string const& TAG_DISPLAY_FILTERED_NAME();
373
374 MCAPI static ::std::string const& TAG_DISPLAY_NAME();
375
376 MCAPI static ::std::string const& TAG_ENCHANTS();
377
378 MCAPI static ::std::string const& TAG_LORE();
379
380 MCAPI static ::std::string const& TAG_REPAIR_COST();
381
382 MCAPI static ::std::string const& TAG_STORE_CAN_DESTROY();
383
384 MCAPI static ::std::string const& TAG_STORE_CAN_PLACE_ON();
385
386 MCAPI static ::std::string const& TAG_UNBREAKABLE();
387 // NOLINTEND
388
389public:
390 // constructor thunks
391 // NOLINTBEGIN
392 MCAPI void* $ctor(::RecipeIngredient const& ingredient);
393
394 MCAPI void* $ctor(::ItemStackBase const& rhs);
395
396 MCAPI void* $ctor(::Block const& block, int count, ::CompoundTag const* _userData);
397
398 MCAPI void* $ctor(::Item const& item, int count, int auxValue, ::CompoundTag const* _userData);
399
400 MCAPI void* $ctor(::std::string_view name, int count, int auxValue, ::CompoundTag const* _userData);
401 // NOLINTEND
402
403public:
404 // destructor thunk
405 // NOLINTBEGIN
406 MCAPI void $dtor();
407 // NOLINTEND
408
409public:
410 // virtual function thunks
411 // NOLINTBEGIN
412 MCFOLD void $reinit(::Item const& item, int count, int auxValue);
413
414 MCFOLD void $reinit(::Block const& block, int count);
415
416 MCFOLD void $reinit(::std::string_view const name, int count, int auxValue);
417
418 MCAPI void $setNull(::std::optional<::std::string> reason);
419
420 MCAPI ::std::string $toString() const;
421
422 MCAPI ::std::string $toDebugString() const;
423
424
425 // NOLINTEND
426
427public:
428 // vftables
429 // NOLINTBEGIN
430 MCAPI static void** $vftable();
431 // NOLINTEND
432};
Definition Actor.h:114
Definition RedactableString.h:10
Definition BlockActor.h:28
Definition BlockPalette.h:19
Definition BlockSource.h:71
Definition BlockType.h:79
Definition Block.h:42
Definition CompoundTag.h:18
Definition ContainerComponent.h:25
Definition DynamicProperties.h:14
Definition HashedString.h:5
Definition IDataInput.h:8
Definition IDataOutput.h:5
Definition ItemDescriptor.h:26
Definition ItemEnchants.h:13
Definition ItemInstance.h:15
Definition ItemStack.h:24
Definition Item.h:71
Definition Value.h:16
Definition Level.h:253
Definition NetworkItemStackDescriptor.h:16
Definition Player.h:129
Definition RecipeIngredient.h:8
Definition SaveContext.h:5
Definition Vec3.h:10
Definition Color.h:13
Definition ItemStackBase.h:52
Definition ItemTag.h:8