LeviLamina
Loading...
Searching...
No Matches
ComponentItem.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/common/WeakPtr.h"
7#include "mc/deps/core/string/HashedString.h"
8#include "mc/deps/core/utility/NonOwnerPointer.h"
9#include "mc/deps/shared_types/legacy/LevelSoundEvent.h"
10#include "mc/deps/shared_types/legacy/actor/ActorLocation.h"
11#include "mc/resources/JsonBetaState.h"
12#include "mc/world/item/Item.h"
13#include "mc/world/item/ItemUseMethod.h"
14#include "mc/world/item/enchanting/Enchant.h"
15#include "mc/world/level/block/BlockShape.h"
16
17// auto generated forward declare list
18// clang-format off
19class Actor;
20class BaseGameVersion;
21class Block;
22class BlockPos;
23class BlockSource;
24class BlockType;
25class CompoundTag;
26class Container;
27class Experiments;
32class ItemComponent;
33class ItemDescriptor;
34class ItemStack;
35class ItemStackBase;
36class Level;
37class ListTag;
38class Mob;
39class Player;
40class SemVersion;
41class Vec3;
45namespace Bedrock::Safety { class RedactableString; }
46namespace Core { class Path; }
47namespace Json { class Value; }
48namespace PuvLoadData { struct LoadResultWithTiming; }
49namespace cereal { struct ReflectionCtx; }
50namespace mce { class Color; }
51// clang-format on
52
53class ComponentItem : public ::Item {
54public:
55 // member variables
56 // NOLINTBEGIN
57 bool mExcludeUserDataDiffCheck : 1;
58 bool mCanDestroyInCreative : 1;
59 bool mRequiresInteract : 1;
60 bool mIsLiquidClipped : 1;
61 ::ll::TypedStorage<4, 4, float> mSpeed;
62 ::ll::TypedStorage<4, 4, int> mDamage;
63 ::ll::TypedStorage<4, 4, ::Enchant::Slot> mEnchantSlot;
64 ::ll::TypedStorage<4, 4, int> mEnchantValue;
65 ::ll::TypedStorage<8, 24, ::std::vector<::std::string>> mAlias;
66 ::ll::TypedStorage<1, 1, bool> mIsAttachable;
67 ::ll::TypedStorage<8, 16, ::std::map<::HashedString, ::std::shared_ptr<::ItemComponent>>> mItemComponents;
68 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::IconItemComponent>> mIcon;
69 ::ll::TypedStorage<8, 8, ::WeakPtr<::BlockType const>> mBlockTypeForRendering;
70 ::ll::TypedStorage<8, 16, ::std::map<::std::string, ::std::shared_ptr<::ItemComponent>>>
71 mRegisteredCerealComponents;
72 ::ll::TypedStorage<8, 24, ::Bedrock::NotNullNonOwnerPtr<::cereal::ReflectionCtx const>> mCtx;
73 // NOLINTEND
74
75public:
76 // prevent constructor by default
78
79public:
80 // virtual functions
81 // NOLINTBEGIN
82 // vIndex: 0
83 virtual ~ComponentItem() /*override*/;
84
85 // vIndex: 1
86 virtual ::PuvLoadData::LoadResultWithTiming
87 initServer(::Json::Value const&, ::SemVersion const&, ::IPackLoadContext&, ::JsonBetaState const) /*override*/;
88
89 // vIndex: 2
90 virtual void tearDown() /*override*/;
91
92 // vIndex: 9
93 virtual bool isComponentBased() const /*override*/;
94
95 // vIndex: 10
96 virtual bool isHumanoidArmor() const /*override*/;
97
98 // vIndex: 11
99 virtual bool isBlockPlanterItem() const /*override*/;
100
101 // vIndex: 14
102 virtual bool isDamageable() const /*override*/;
103
104 // vIndex: 15
105 virtual bool isDyeable() const /*override*/;
106
107 // vIndex: 19
108 virtual bool isFood() const /*override*/;
109
110 // vIndex: 20
111 virtual bool isThrowable() const /*override*/;
112
113 // vIndex: 21
114 virtual bool isUseable() const /*override*/;
115
116 // vIndex: 7
117 virtual bool isMusicDisk() const /*override*/;
118
119 // vIndex: 22
120 virtual bool isTrimAllowed() const /*override*/;
121
122 // vIndex: 6
123 virtual ::WeakPtr<::BlockType const> const& getBlockTypeForRendering() const /*override*/;
124
125 // vIndex: 23
126 virtual ::ItemComponent* getComponent(::HashedString const& id) const /*override*/;
127
128 // vIndex: 24
129 virtual ::IFoodItemComponent* getFood() const /*override*/;
130
131 // vIndex: 25
132 virtual ::Item& setMaxDamage(int maxDamage) /*override*/;
133
134 // vIndex: 4
135 virtual ::std::string const& getDescriptionId() const /*override*/;
136
137 // vIndex: 30
138 virtual ::BlockShape getBlockShape() const /*override*/;
139
140 // vIndex: 31
141 virtual bool canBeDepleted() const /*override*/;
142
143 // vIndex: 32
144 virtual bool canDestroySpecial(::Block const& block) const /*override*/;
145
146 // vIndex: 33
147 virtual int getLevelDataForAuxValue(int) const /*override*/;
148
149 // vIndex: 35
150 virtual short getMaxDamage() const /*override*/;
151
152 // vIndex: 36
153 virtual int getAttackDamage() const /*override*/;
154
155 // vIndex: 39
156 virtual bool isGlint(::ItemStackBase const& stack) const /*override*/;
157
158 // vIndex: 47
159 virtual bool canDestroyInCreative() const /*override*/;
160
161 // vIndex: 48
162 virtual bool isDestructive(int) const /*override*/;
163
164 // vIndex: 49
165 virtual bool isLiquidClipItem() const /*override*/;
166
167 // vIndex: 51
168 virtual bool requiresInteract() const /*override*/;
169
170 // vIndex: 53
171 virtual void appendFormattedHovertext(
172 ::ItemStackBase const& stack,
173 ::Level& level,
175 bool const showCategory
176 ) const /*override*/;
177
178 // vIndex: 54
179 virtual bool isValidRepairItem(
180 ::ItemStackBase const& source,
181 ::ItemStackBase const& repairItem,
182 ::BaseGameVersion const& baseGameVersion
183 ) const /*override*/;
184
185 // vIndex: 55
186 virtual int getEnchantSlot() const /*override*/;
187
188 // vIndex: 56
189 virtual int getEnchantValue() const /*override*/;
190
191 // vIndex: 57
192 virtual int getArmorValue() const /*override*/;
193
194 // vIndex: 62
195 virtual int getDamageChance(int unbreaking) const /*override*/;
196
197 // vIndex: 44
198 virtual uint getSwingDuration() const /*override*/;
199
200 // vIndex: 106
201 virtual bool shouldEmitInUseGameEvents() const /*override*/;
202
203 // vIndex: 67
204 virtual ::mce::Color getColor(::CompoundTag const* userData, ::ItemDescriptor const& instance) const /*override*/;
205
206 // vIndex: 69
207 virtual bool hasCustomColor(::ItemStackBase const& instance) const /*override*/;
208
209 // vIndex: 70
210 virtual void clearColor(::ItemStackBase& instance) const /*override*/;
211
212 // vIndex: 71
213 virtual void setColor(::ItemStackBase& instance, ::mce::Color const& color) const /*override*/;
214
215 // vIndex: 77
216 virtual ::ItemStack& use(::ItemStack& item, ::Player& player) const /*override*/;
217
218 // vIndex: 78
219 virtual bool canUseAsAttack() const /*override*/;
220
221 // vIndex: 79
222 virtual ::ItemStack& useAsAttack(::ItemStack& item, ::Player& player) const /*override*/;
223
224 // vIndex: 80
225 virtual ::Actor* createProjectileActor(
226 ::BlockSource& region,
227 ::ItemStack const& stack,
228 ::Vec3 const& pos,
229 ::Vec3 const& direction
230 ) const /*override*/;
231
232 // vIndex: 81
233 virtual bool dispense(::BlockSource& region, ::Container& container, int slot, ::Vec3 const& pos, uchar face) const
234 /*override*/;
235
236 // vIndex: 82
237 virtual ::ItemUseMethod useTimeDepleted(::ItemStack& inoutInstance, ::Level* level, ::Player* player) const
238 /*override*/;
239
240 // vIndex: 83
241 virtual void releaseUsing(::ItemStack& item, ::Player* player, int durationLeft) const /*override*/;
242
243 // vIndex: 84
244 virtual float getDestroySpeed(::ItemStackBase const& item, ::Block const& block) const /*override*/;
245
246 // vIndex: 85
247 virtual void hurtActor(::ItemStack& item, ::Actor& actor, ::Mob& attacker) const /*override*/;
248
249 // vIndex: 86
250 virtual void hitActor(::ItemStack& item, ::Actor& actor, ::Mob& attacker) const /*override*/;
251
252 // vIndex: 87
253 virtual void hitBlock(::ItemStack& item, ::Block const& block, ::BlockPos const& blockPos, ::Mob& attacker) const
254 /*override*/;
255
256 // vIndex: 90
257 virtual ::std::string buildDescriptionId(::ItemDescriptor const&, ::CompoundTag const*) const /*override*/;
258
259 // vIndex: 91
260 virtual ::std::string buildEffectDescriptionName(::ItemStackBase const& stack, bool playerIsCreative) const
261 /*override*/;
262
263 // vIndex: 94
264 virtual uchar getMaxStackSize(::ItemDescriptor const&) const /*override*/;
265
266 // vIndex: 97
267 virtual ::HashedString const& getCooldownCategory() const /*override*/;
268
269 // vIndex: 98
270 virtual int getCooldownDuration() const /*override*/;
271
272 // vIndex: 104
273 virtual ::SharedTypes::Legacy::ActorLocation getEquipLocation() const /*override*/;
274
275 // vIndex: 105
276 virtual ::SharedTypes::Legacy::LevelSoundEvent getEquipSound() const /*override*/;
277
278 // vIndex: 124
279 virtual bool useVariant(int, int, bool) const;
280
281 // vIndex: 125
282 virtual int getVariant(int, int, bool) const;
283
284 // vIndex: 109
285 virtual ::PuvLoadData::LoadResultWithTiming
286 initClient(::Json::Value const&, ::SemVersion const&, ::JsonBetaState const, ::IPackLoadContext&) /*override*/;
287
288 // vIndex: 112
289 virtual ::std::string getInteractText(::Player const& player) const /*override*/;
290
291 // vIndex: 113
292 virtual int getAnimationFrameFor(::Mob*, bool, ::ItemStack const*, bool) const /*override*/;
293
294 // vIndex: 114
295 virtual bool isEmissive(int auxValue) const /*override*/;
296
297 // vIndex: 111
298 virtual ::ResolvedItemIconInfo
299 getIconInfo(::ItemStackBase const& item, int newAnimationFrame, bool inInventoryPane) const /*override*/;
300
301 // vIndex: 110
302 virtual ::Item& setIconInfo(::std::string const& name, int frame) /*override*/;
303
304 // vIndex: 116
305 virtual bool canBeCharged() const /*override*/;
306
307 // vIndex: 3
308 virtual ::ComponentItem& setDescriptionId(::std::string const& descriptionId) /*override*/;
309
310 // vIndex: 126
311 virtual bool shouldUseJsonForRenderMatrix() const;
312
313 // vIndex: 27
314 virtual ::std::unique_ptr<::CompoundTag> buildNetworkTag() const /*override*/;
315
316 // vIndex: 28
317 virtual void initializeFromNetwork(::CompoundTag const& tag) /*override*/;
318
319 // vIndex: 29
320 virtual ::std::vector<::std::string> validateFromNetwork(::CompoundTag const& tag) /*override*/;
321
322 // vIndex: 120
323 virtual bool
324 _checkUseOnPermissions(::Actor& entity, ::ItemStackBase& item, uchar const& face, ::BlockPos const& pos) const
325 /*override*/;
326
327 // vIndex: 121
328 virtual bool _calculatePlacePos(::ItemStackBase& instance, ::Actor& entity, uchar& face, ::BlockPos& pos) const
329 /*override*/;
330
331 // vIndex: 122
332 virtual bool _shouldAutoCalculatePlacePos() const /*override*/;
333
334 // vIndex: 123
335 virtual ::InteractionResult
336 _useOn(::ItemStack& instance, ::Actor& entity, ::BlockPos pos, uchar face, ::Vec3 const& clickPos) const
337 /*override*/;
338 // NOLINTEND
339
340public:
341 // member functions
342 // NOLINTBEGIN
343 MCAPI ComponentItem(::std::string const& nameId, short id, ::cereal::ReflectionCtx const& ctx);
344
345 MCAPI void _addRegisteredCerealComponent(
346 ::std::pair<::std::string const, ::std::shared_ptr<::ItemComponent>>& cerealComponent
347 );
348
349 MCAPI ::std::unique_ptr<::CompoundTag> _buildItemPropertiesNetworkTag(::cereal::ReflectionCtx const& ctx) const;
350
351 MCAPI ::std::unique_ptr<::ListTag> _buildItemTagsNetworkTag() const;
352
353 MCAPI bool _doesNotTakeDurabilityDamage() const;
354
355 MCAPI void _initializeLoadedComponents(
356 ::std::optional<::SemVersion> documentVersion,
357 ::std::optional<::Experiments> _experiments
358 );
359
360 MCAPI void _loadComponentsFromNetworkTag(
361 ::std::string const& componentName,
362 ::CompoundTag const& componentTag,
364 );
365
366 MCAPI void _loadItemPropertiesNetworkTag(::CompoundTag const& tag, ::cereal::ReflectionCtx const& ctx);
367
368 MCAPI void _loadItemTagsNetworkTag(::ListTag const& listTag);
369
370 MCAPI ::PuvLoadData::LoadResultWithTiming _validateSchemaAndInitItem(
371 ::Json::Value const& itemData,
372 ::SemVersion const& documentVersion,
373 ::JsonBetaState canUseBeta,
374 ::IPackLoadContext& packLoadContext,
375 bool isServer,
377 );
378
379 MCAPI ::std::unique_ptr<::CompoundTag> buildNetworkTag(::cereal::ReflectionCtx const& ctx) const;
380
381 MCAPI void
382 init(::ComponentItemDataAll_Latest&& data, ::SemVersion const& documentVersion, ::Experiments const& experiments);
383 // NOLINTEND
384
385public:
386 // static functions
387 // NOLINTBEGIN
388 MCAPI static void _moveDataToComponentItem(::ComponentItem& item, ::ComponentItemData_Legacy& data);
389
390 MCAPI static void registerItemComponentTypes(::cereal::ReflectionCtx& ctx);
391
392 MCAPI static ::std::pair<bool, ::SemVersion> upgradeJson(
394 ::std::string& document,
395 ::Core::Path const& resourceName,
396 ::std::optional<::SemVersion> minVersion
397 );
398 // NOLINTEND
399
400public:
401 // constructor thunks
402 // NOLINTBEGIN
403 MCAPI void* $ctor(::std::string const& nameId, short id, ::cereal::ReflectionCtx const& ctx);
404 // NOLINTEND
405
406public:
407 // destructor thunk
408 // NOLINTBEGIN
409 MCAPI void $dtor();
410 // NOLINTEND
411
412public:
413 // virtual function thunks
414 // NOLINTBEGIN
415 MCFOLD void $tearDown();
416
417 MCFOLD bool $isComponentBased() const;
418
419 MCAPI bool $isHumanoidArmor() const;
420
421 MCAPI bool $isBlockPlanterItem() const;
422
423 MCAPI bool $isDamageable() const;
424
425 MCAPI bool $isDyeable() const;
426
427 MCFOLD bool $isFood() const;
428
429 MCAPI bool $isThrowable() const;
430
431 MCAPI bool $isUseable() const;
432
433 MCAPI bool $isMusicDisk() const;
434
435 MCAPI bool $isTrimAllowed() const;
436
437 MCAPI ::WeakPtr<::BlockType const> const& $getBlockTypeForRendering() const;
438
439 MCAPI ::ItemComponent* $getComponent(::HashedString const& id) const;
440
441 MCAPI ::IFoodItemComponent* $getFood() const;
442
443 MCAPI ::Item& $setMaxDamage(int maxDamage);
444
445 MCAPI ::std::string const& $getDescriptionId() const;
446
447 MCFOLD ::BlockShape $getBlockShape() const;
448
449 MCAPI bool $canBeDepleted() const;
450
451 MCAPI bool $canDestroySpecial(::Block const& block) const;
452
453 MCFOLD int $getLevelDataForAuxValue(int) const;
454
455 MCAPI short $getMaxDamage() const;
456
457 MCAPI int $getAttackDamage() const;
458
459 MCFOLD bool $isGlint(::ItemStackBase const& stack) const;
460
461 MCAPI bool $canDestroyInCreative() const;
462
463 MCFOLD bool $isDestructive(int) const;
464
465 MCAPI bool $isLiquidClipItem() const;
466
467 MCAPI bool $requiresInteract() const;
468
469 MCAPI void $appendFormattedHovertext(
470 ::ItemStackBase const& stack,
471 ::Level& level,
473 bool const showCategory
474 ) const;
475
476 MCAPI bool $isValidRepairItem(
477 ::ItemStackBase const& source,
478 ::ItemStackBase const& repairItem,
479 ::BaseGameVersion const& baseGameVersion
480 ) const;
481
482 MCAPI int $getEnchantSlot() const;
483
484 MCFOLD int $getEnchantValue() const;
485
486 MCAPI int $getArmorValue() const;
487
488 MCAPI int $getDamageChance(int unbreaking) const;
489
490 MCAPI uint $getSwingDuration() const;
491
492 MCAPI bool $shouldEmitInUseGameEvents() const;
493
494 MCAPI ::mce::Color $getColor(::CompoundTag const* userData, ::ItemDescriptor const& instance) const;
495
496 MCAPI bool $hasCustomColor(::ItemStackBase const& instance) const;
497
498 MCAPI void $clearColor(::ItemStackBase& instance) const;
499
500 MCAPI void $setColor(::ItemStackBase& instance, ::mce::Color const& color) const;
501
502 MCAPI ::ItemStack& $use(::ItemStack& item, ::Player& player) const;
503
504 MCAPI bool $canUseAsAttack() const;
505
506 MCAPI ::ItemStack& $useAsAttack(::ItemStack& item, ::Player& player) const;
507
508 MCAPI ::Actor* $createProjectileActor(
509 ::BlockSource& region,
510 ::ItemStack const& stack,
511 ::Vec3 const& pos,
512 ::Vec3 const& direction
513 ) const;
514
515 MCAPI bool $dispense(::BlockSource& region, ::Container& container, int slot, ::Vec3 const& pos, uchar face) const;
516
517 MCAPI void $releaseUsing(::ItemStack& item, ::Player* player, int durationLeft) const;
518
519 MCAPI float $getDestroySpeed(::ItemStackBase const& item, ::Block const& block) const;
520
521 MCAPI void $hurtActor(::ItemStack& item, ::Actor& actor, ::Mob& attacker) const;
522
523 MCAPI void $hitActor(::ItemStack& item, ::Actor& actor, ::Mob& attacker) const;
524
525 MCAPI void $hitBlock(::ItemStack& item, ::Block const& block, ::BlockPos const& blockPos, ::Mob& attacker) const;
526
527 MCAPI ::std::string $buildDescriptionId(::ItemDescriptor const&, ::CompoundTag const*) const;
528
529 MCAPI ::std::string $buildEffectDescriptionName(::ItemStackBase const& stack, bool playerIsCreative) const;
530
531 MCFOLD uchar $getMaxStackSize(::ItemDescriptor const&) const;
532
533 MCAPI ::HashedString const& $getCooldownCategory() const;
534
535 MCAPI int $getCooldownDuration() const;
536
537 MCAPI ::SharedTypes::Legacy::LevelSoundEvent $getEquipSound() const;
538
539 MCFOLD bool $useVariant(int, int, bool) const;
540
541 MCFOLD int $getVariant(int, int, bool) const;
542
543 MCAPI ::std::string $getInteractText(::Player const& player) const;
544
545 MCFOLD int $getAnimationFrameFor(::Mob*, bool, ::ItemStack const*, bool) const;
546
547 MCFOLD bool $isEmissive(int auxValue) const;
548
549 MCAPI ::ResolvedItemIconInfo
550 $getIconInfo(::ItemStackBase const& item, int newAnimationFrame, bool inInventoryPane) const;
551
552 MCAPI ::Item& $setIconInfo(::std::string const& name, int frame);
553
554 MCAPI bool $canBeCharged() const;
555
556 MCAPI ::ComponentItem& $setDescriptionId(::std::string const& descriptionId);
557
558 MCAPI bool $shouldUseJsonForRenderMatrix() const;
559
560 MCAPI ::std::unique_ptr<::CompoundTag> $buildNetworkTag() const;
561
562 MCAPI void $initializeFromNetwork(::CompoundTag const& tag);
563
564 MCAPI ::std::vector<::std::string> $validateFromNetwork(::CompoundTag const& tag);
565
566 MCFOLD bool
567 $_checkUseOnPermissions(::Actor& entity, ::ItemStackBase& item, uchar const& face, ::BlockPos const& pos) const;
568
569 MCAPI bool $_calculatePlacePos(::ItemStackBase& instance, ::Actor& entity, uchar& face, ::BlockPos& pos) const;
570
571 MCAPI bool $_shouldAutoCalculatePlacePos() const;
572
573 MCAPI ::InteractionResult
574 $_useOn(::ItemStack& instance, ::Actor& entity, ::BlockPos pos, uchar face, ::Vec3 const& clickPos) const;
575 // NOLINTEND
576
577public:
578 // vftables
579 // NOLINTBEGIN
580 MCNAPI static void** $vftable();
581 // NOLINTEND
582};
Definition Actor.h:102
Definition BaseGameVersion.h:8
Definition RedactableString.h:10
Definition BlockPos.h:17
Definition BlockSource.h:66
Definition BlockType.h:84
Definition Block.h:38
Definition ComponentItem.h:53
static MCAPI void ** $vftable()
Definition CompoundTag.h:13
Definition Container.h:31
Definition Path.h:11
Definition Experiments.h:14
Definition HashedString.h:5
Definition IFoodItemComponent.h:17
Definition IPackLoadContext.h:20
Definition IconItemComponent.h:19
Definition InteractionResult.h:5
Definition ItemComponent.h:16
Definition ItemDescriptor.h:22
Definition ItemStackBase.h:36
Definition ItemStack.h:23
Definition Item.h:66
Definition Value.h:16
Definition Level.h:247
Definition ListTag.h:12
Definition Mob.h:47
Definition Path.h:16
Definition Player.h:123
Definition SemVersion.h:16
Definition Vec3.h:10
Definition Color.h:13
Definition ComponentItemDataAll_Latest.h:11
Definition ComponentItemData_Legacy.h:17
Definition ResolvedItemIconInfo.h:8
Definition ReflectionCtx.h:11
Definition ctx.h:5