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