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 // virtual functions
91 // NOLINTBEGIN
92 virtual ~ItemStackBase();
93
94 virtual void reinit(::Item const&, int, int);
95
96 virtual void reinit(::Block const&, int);
97
98 virtual void reinit(::std::string_view const, int, int);
99
100 virtual void setNull(::std::optional<::std::string> reason);
101
102 virtual ::std::string toString() const;
103
104 virtual ::std::string toDebugString() const;
105 // NOLINTEND
106
107public:
108 // member functions
109 // NOLINTBEGIN
110 MCAPI ItemStackBase();
111
112 MCAPI explicit ItemStackBase(::RecipeIngredient const& ingredient);
113
114 MCAPI ItemStackBase(::ItemStackBase const& rhs);
115
116 MCAPI ItemStackBase(::Block const& block, int count = 1, ::CompoundTag const* _userData = nullptr);
117
118 MCAPI
119 ItemStackBase(::std::string_view name, int count = 1, int auxValue = 0, ::CompoundTag const* _userData = nullptr);
120
121 MCAPI void _addCustomUserDataCommon(::std::unique_ptr<::CompoundTag>&& tag);
122
123 MCAPI void _checkForItemWorldCompatibility();
124
125 MCAPI ::std::string _getHoverFormattingPrefix() const;
126
127 MCAPI_C bool _hasFullOrPartialTag(::HashedString const& string) const;
128
129 MCAPI void _loadComponents(::CompoundTag const& compoundTag);
130
131 MCAPI void _loadItem(::CompoundTag const& compoundTag);
132
133 MCAPI void _setChargedItem(::ItemInstance const& item);
134
135 MCAPI bool _setItem(int id, bool doRemap);
136
137 MCAPI void _setItemFromBlockName(::HashedString const& blockName);
138
139 MCAPI void _updateCompareHashes();
140
141 MCAPI void add(int inCount);
142
143 MCAPI bool addComponents(::Json::Value const& root, ::std::string& errorMsg);
144
145 MCAPI void addCustomUserData(::ContainerComponent const& containerComponent);
146
147 MCAPI void clearChargedItem();
148
149 MCAPI void clearCustomLore();
150
151 MCAPI ::ItemEnchants constructItemEnchantsFromUserData() const;
152
153 MCAPI ::SharedTypes::Legacy::ArmorSlot getArmorSlot() const;
154
155 MCAPI short getAuxValue() const;
156
157 MCAPI int getBaseRepairCost() const;
158
159 MCAPI_C ::Block const* getBlockForRendering() const;
160
161 MCAPI ::WeakPtr<::BlockType const> const& getBlockType() const;
162
163 MCAPI_C ::WeakPtr<::BlockType const> const& getBlockTypeForRendering() const;
164
165 MCAPI ::mce::Color getColor() const;
166
167 MCAPI ::ComponentItem const* getComponentItem() const;
168
169 MCAPI ::std::vector<::std::string> getCustomLore() const;
170
171 MCAPI ::std::string getCustomName() const;
172
173 MCAPI short getDamageValue() const;
174
175 MCAPI ::std::string getDescriptionId() const;
176
177 MCAPI ::ItemDescriptor getDescriptor() const;
178
179 MCAPI ::std::unique_ptr<::DynamicProperties> getDynamicProperties() const;
180
181 MCAPI ::std::optional<::std::variant<double, float, bool, ::std::string, ::Vec3>>
182 getDynamicProperty(::std::string const& key, ::std::string const& collectionName) const;
183
184 MCAPI_C ::Bedrock::Safety::RedactableString getFormattedHovertext(::Level& level, bool showCategory) const;
185
186 MCAPI ::HashedString const& getFullNameHash() const;
187
188 MCAPI_C ::std::string getHoverName() const;
189
190 MCAPI_C ::ResolvedItemIconInfo getIconInfo(int newAnimationFrame, bool inInventoryPane) const;
191
192 MCAPI short getId() const;
193
194 MCAPI int getIdAux() const;
195
196 MCAPI_C int getIdAuxEnchanted() const;
197
198 MCAPI_C bool getIsValidPickupTime() const;
199
200 MCAPI ::Item const* getItem() const;
201
202 MCAPI short getMaxDamage() const;
203
204 MCAPI uchar getMaxStackSize() const;
205
206 MCAPI ::std::string getName() const;
207
208 MCAPI ::std::unique_ptr<::CompoundTag> getNetworkUserData() const;
209
210 MCAPI ::HashedString const& getRawNameHash() const;
211
212 MCAPI ::std::string getRawNameId() const;
213
214 MCAPI ::Bedrock::Safety::RedactableString getRedactedCustomName() const;
215
216 MCAPI ::Bedrock::Safety::RedactableString getRedactedHoverName() const;
217
218 MCAPI ::Bedrock::Safety::RedactableString getRedactedName() const;
219
220 MCAPI_C ::HashedString const& getRendererId() const;
221
222 MCAPI_C bool hasChargedItem() const;
223
224 MCAPI_C bool hasComponent(::std::string const& name) const;
225
226 MCAPI bool hasContainerData() const;
227
228 MCAPI bool hasCustomHoverName() const;
229
230 MCAPI bool hasSameAuxValue(::ItemStackBase const& other) const;
231
232 MCAPI bool hasSameUserData(::ItemStackBase const& other) 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 MCAPI_C bool isAttachableEquipment() const;
245
246 MCAPI bool isBlock() const;
247
248 MCAPI_C bool isBlockInstance(::HashedString const& blockName) const;
249
250 MCAPI bool isDamageableItem() const;
251
252 MCAPI_C bool isDamaged() const;
253
254 MCAPI bool isEnchantingBook() const;
255
256 MCAPI bool isGlint() const;
257
258 MCAPI bool isHorseArmorItem() const;
259
260 MCAPI bool isHumanoidArmorItem() const;
261
262 MCAPI bool isHumanoidWearableBlockItem() const;
263
264 MCAPI bool isInstance(::HashedString const& itemName, bool useItemLookup) const;
265
266 MCAPI_C bool isLiquidClipItem() const;
267
268 MCAPI bool isNull() const;
269
270 MCAPI_C bool isOnCooldown(::Player& player, ::SharedTypes::ItemCooldownType type) const;
271
272 MCAPI bool
273 isOneOfBlockInstances(::std::vector<::std::reference_wrapper<::HashedString const>> const& blockTypeIds) const;
274
275 MCAPI bool isOneOfInstances(
276 ::std::initializer_list<::std::reference_wrapper<::HashedString const>> items,
277 bool useItemLookup
278 ) const;
279
280 MCAPI bool isPotionItem() const;
281
282 MCAPI_C bool isStackable() const;
283
284 MCAPI bool isStackable(::ItemStackBase const& other) const;
285
286 MCAPI bool isStackedByData() const;
287
288 MCAPI bool isValidAuxValue(int value) const;
289
290 MCFOLD bool matches(::ItemStackBase const& other) const;
291
292 MCAPI bool matchesEitherWearableCase(::CompoundTag const* userData) const;
293
294 MCAPI bool matchesItem(::ItemStackBase const& other) const;
295
296 MCAPI explicit operator bool() const;
297
298 MCAPI bool operator!=(::ItemStackBase const& rhs) const;
299
300 MCAPI ::ItemStackBase& operator=(::ItemStackBase const& rhs);
301
302 MCFOLD bool operator==(::ItemStackBase const& rhs) const;
303
304 MCAPI void remove(int inCount);
305
306 MCAPI void removeDamageValue();
307
308 MCAPI void resetHoverName();
309
310 MCAPI bool sameItem(int itemId, int auxValue) const;
311
312 MCAPI ::std::unique_ptr<::CompoundTag> save(::SaveContext const& saveContext) const;
313
314 MCAPI void saveEnchantsToUserData(::ItemEnchants const& enchant);
315
316 MCAPI bool sendEventTriggered(::std::string const& event, ::RenderParams const& params);
317
318 MCAPI void set(int inCount);
319
320 MCAPI void setChargedItem(::ItemInstance const& instance, bool isSwapping);
321
322 MCAPI void setCustomLore(::std::vector<::std::string> const& lore);
323
324 MCAPI void setCustomName(::Bedrock::Safety::RedactableString const& name);
325
326 MCAPI void setDamageValue(short newDamage);
327
328 MCAPI void setDynamicProperty(
329 ::std::string const& key,
330 ::std::variant<double, float, bool, ::std::string, ::Vec3> const& value,
331 ::std::string const& collectionName
332 );
333
334 MCAPI void setRepairCost(int cost);
335
336 MCAPI void setStackSize(uchar inCount);
337
338 MCAPI void setUserData(::std::unique_ptr<::CompoundTag> tag);
339
340 MCAPI bool updateComponent(::std::string const& name, ::Json::Value const& data);
341 // NOLINTEND
342
343public:
344 // static functions
345 // NOLINTBEGIN
346 MCAPI static bool
347 _loadBlocksForCanPlaceOnCanDestroy(::std::vector<::BlockType const*>& blockList, ::std::string const& blockName);
348
349 MCAPI_C static void loadItemStacksFromDescriptor(
350 ::std::vector<::ItemStack>& outItems,
351 ::std::vector<::NetworkItemStackDescriptor> const& descriptors,
352 ::BlockPalette& blockPalette,
353 bool isClientSide
354 );
355 // NOLINTEND
356
357public:
358 // static variables
359 // NOLINTBEGIN
360 MCAPI static ::std::string const& TAG_CAN_DESTROY();
361
362 MCAPI static ::std::string const& TAG_CAN_PLACE_ON();
363
364 MCAPI static ::std::string const& TAG_CHARGED_ITEM();
365
366 MCAPI static ::std::string const& TAG_DISPLAY();
367
368 MCAPI static ::std::string const& TAG_DISPLAY_FILTERED_NAME();
369
370 MCAPI static ::std::string const& TAG_DISPLAY_NAME();
371
372 MCAPI static ::std::string const& TAG_ENCHANTS();
373
374 MCAPI static ::std::string const& TAG_LORE();
375
376 MCAPI static ::std::string const& TAG_REPAIR_COST();
377
378 MCAPI static ::std::string const& TAG_STORE_CAN_DESTROY();
379
380 MCAPI static ::std::string const& TAG_STORE_CAN_PLACE_ON();
381
382 MCAPI static ::std::string const& TAG_UNBREAKABLE();
383 // NOLINTEND
384
385public:
386 // constructor thunks
387 // NOLINTBEGIN
388 MCAPI void* $ctor();
389
390 MCAPI void* $ctor(::RecipeIngredient const& ingredient);
391
392 MCAPI void* $ctor(::ItemStackBase const& rhs);
393
394 MCAPI void* $ctor(::Block const& block, int count, ::CompoundTag const* _userData);
395
396 MCAPI void* $ctor(::std::string_view name, int count, int auxValue, ::CompoundTag const* _userData);
397 // NOLINTEND
398
399public:
400 // destructor thunk
401 // NOLINTBEGIN
402 MCAPI void $dtor();
403 // NOLINTEND
404
405public:
406 // virtual function thunks
407 // NOLINTBEGIN
408 MCFOLD void $reinit(::Item const&, int, int);
409
410 MCFOLD void $reinit(::Block const&, int);
411
412 MCFOLD void $reinit(::std::string_view const, int, int);
413
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:105
Definition RedactableString.h:10
Definition BlockPalette.h:19
Definition BlockType.h:84
Definition Block.h:43
Definition ComponentItem.h:55
Definition CompoundTag.h:23
Definition ContainerComponent.h:28
Definition DynamicProperties.h:13
Definition HashedString.h:5
Definition IDataInput.h:8
Definition ItemDescriptor.h:23
Definition ItemEnchants.h:17
Definition ItemInstance.h:15
static MCAPI void ** $vftable()
Definition ItemStack.h:26
Definition Item.h:69
Definition Value.h:16
Definition Level.h:249
Definition NetworkItemStackDescriptor.h:17
Definition Player.h:125
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