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