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