Botcraft 26.2
Loading...
Searching...
No Matches
Entity.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <any>
4#include <chrono>
5#include <map>
6#include <memory>
7#include <optional>
8#include <shared_mutex>
9
10#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
12#endif
15
17
20
21#if USE_GUI
23#endif
24
25namespace Botcraft
26{
27 enum class EntityType;
28#if PROTOCOL_VERSION < 458 /* < 1.14 */
29 enum class ObjectEntityType;
30#endif
31
33 {
35 unsigned char amplifier;
36 std::chrono::steady_clock::time_point end;
37 };
38
39 enum class EntitySharedFlagsId : char
40 {
41 OnFire = 0,
42 ShiftKeyDown = 1,
43 // 2 is unused? Maybe in previous versions
44 Sprinting = 3,
45 Swimming = 4,
46 Invisible = 5,
47 Glowing = 6,
48 FallFlying = 7
49 };
50
51 class Entity
52 {
53 protected:
54#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
55 static constexpr int metadata_count = 8;
56#elif PROTOCOL_VERSION > 404 /* > 1.13.2 */
57 static constexpr int metadata_count = 7;
58#else
59 static constexpr int metadata_count = 6;
60#endif
61 static const std::array<std::string, metadata_count> metadata_names;
62 static constexpr int hierarchy_metadata_count = 0;
63
64 public:
65 Entity();
66 virtual ~Entity();
67
68 // Object related stuff
69 virtual std::string GetName() const = 0;
70 virtual EntityType GetType() const = 0;
71 AABB GetCollider() const;
72 double GetWidth() const;
73 double GetHeight() const;
74
75 // Metadata stuff
76 void LoadMetadataFromRawArray(const std::vector<unsigned char>& data);
77 virtual void SetMetadataValue(const int index, const std::any& value);
78
79 char GetDataSharedFlagsId() const;
80 bool GetDataSharedFlagsId(const EntitySharedFlagsId id) const;
81 int GetDataAirSupplyId() const;
82#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
83 std::optional<ProtocolCraft::Chat> GetDataCustomName() const;
84#else
85 std::string GetDataCustomName() const;
86#endif
87 bool GetDataCustomNameVisible() const;
88 bool GetDataSilent() const;
89 bool GetDataNoGravity() const;
90#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
91 Pose GetDataPose() const;
92#endif
93#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
94 int GetDataTicksFrozen() const;
95#endif
96
97 void SetDataSharedFlagsId(const char data_shared_flags_id);
98 void SetDataSharedFlagsId(const EntitySharedFlagsId id, const bool b);
99 void SetDataAirSupplyId(const int data_air_supply_id);
100#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
101 void SetDataCustomName(const std::optional<ProtocolCraft::Chat>& data_custom_name);
102#else
103 void SetDataCustomName(const std::string& data_custom_name);
104#endif
105 void SetDataCustomNameVisible(const bool data_custom_name_visible);
106 void SetDataSilent(const bool data_silent);
107 void SetDataNoGravity(const bool data_no_gravity);
108#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
109 void SetDataPose(const Pose data_pose);
110#endif
111#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
112 void SetDataTicksFrozen(const int data_ticks_frozen);
113#endif
114
115 // Generic properties getter
116 int GetEntityID() const;
119 double GetX() const;
120 double GetY() const;
121 double GetZ() const;
122 float GetYaw() const;
123 float GetPitch() const;
125 double GetSpeedX() const;
126 double GetSpeedY() const;
127 double GetSpeedZ() const;
128 bool GetOnGround() const;
129 std::map<EquipmentSlot, ProtocolCraft::Slot> GetEquipments() const;
131 std::vector<EntityEffect> GetEffects() const;
132#if USE_GUI
133 std::vector<Renderer::Face> GetFaces(const bool reset_uptodate_status);
134 bool GetAreRenderedFacesUpToDate() const;
135#endif
136
137 // Generic properties setter
138 void SetEntityID(const int entity_id_);
139 void SetUUID(const ProtocolCraft::UUID& uuid_);
140 virtual void SetPosition(const Vector3<double>& position_);
141 virtual void SetX(const double x_);
142 virtual void SetY(const double y_);
143 virtual void SetZ(const double z_);
144 virtual void SetYaw(const float yaw_);
145 virtual void SetPitch(const float pitch_);
146 void SetSpeed(const Vector3<double>& speed_);
147 void SetSpeedX(const double speed_x_);
148 void SetSpeedY(const double speed_y_);
149 void SetSpeedZ(const double speed_z_);
150 void SetOnGround(const bool on_ground_);
151 void SetEquipment(const EquipmentSlot slot, const ProtocolCraft::Slot& item);
152 void SetEffects(const std::vector<EntityEffect>& effects_);
153 void AddEffect(const EntityEffect& effect);
154 void RemoveEffect(const EntityEffectType type);
155#if USE_GUI
156 void SetAreRenderedFacesUpToDate(const bool are_rendered_faces_up_to_date_);
157#endif
158
159 // In case it's needed one day, could be useful
161
162 virtual bool IsLocalPlayer() const;
163 virtual bool IsRemotePlayer() const;
164 // Can be used to know if an entity has a certain virtual type as ancestor
165 virtual bool IsLivingEntity() const;
166 virtual bool IsAbstractArrow() const;
167 virtual bool IsAnimal() const;
168 virtual bool IsAmbientCreature() const;
169 virtual bool IsMonster() const;
170#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
171 virtual bool IsDisplay() const;
172#endif
173#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
174 virtual bool IsVehicle() const;
175#endif
176 virtual bool IsTamableAnimal() const;
177 virtual bool IsAbstractSchoolingFish() const;
178 virtual bool IsWaterAnimal() const;
179 virtual bool IsAbstractChestedHorse() const;
180 virtual bool IsAbstractHurtingProjectile() const;
181 virtual bool IsMob() const;
182 virtual bool IsSpellcasterIllager() const;
183#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
184 virtual bool IsProjectile() const;
185#endif
186#if PROTOCOL_VERSION < 771 /* < 1.21.6 */
187 virtual bool IsFlyingMob() const;
188#endif
189 virtual bool IsAbstractHorse() const;
190 virtual bool IsAbstractGolem() const;
191 virtual bool IsHangingEntity() const;
192 virtual bool IsFireball() const;
193 virtual bool IsAbstractMinecart() const;
194#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
195 virtual bool IsAbstractCow() const;
196#endif
197 virtual bool IsAbstractMinecartContainer() const;
198 virtual bool IsShoulderRidingEntity() const;
199#if PROTOCOL_VERSION > 736 /* > 1.16.1 */
200 virtual bool IsAbstractPiglin() const;
201#endif
202 virtual bool IsAbstractIllager() const;
203#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
204 virtual bool IsAbstractThrownPotion() const;
205#endif
206 virtual bool IsAbstractFish() const;
207#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
208 virtual bool IsRaider() const;
209#endif
210 virtual bool IsAbstractSkeleton() const;
211 virtual bool IsThrowableItemProjectile() const;
212#if PROTOCOL_VERSION > 477 /* > 1.14 */
213 virtual bool IsAbstractVillager() const;
214#endif
215 virtual bool IsAgeableMob() const;
216 virtual bool IsPathfinderMob() const;
217#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
218 virtual bool IsPatrollingMonster() const;
219#endif
220 virtual bool IsThrowableProjectile() const;
221#if PROTOCOL_VERSION > 765 /* > 1.20.4 */
222 virtual bool IsAbstractWindCharge() const;
223#endif
224#if PROTOCOL_VERSION > 766 /* > 1.20.6 */
225 virtual bool IsBlockAttachedEntity() const;
226#endif
227#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
228 virtual bool IsAbstractBoat() const;
229 virtual bool IsAbstractChestBoat() const;
230 virtual bool IsAgeableWaterCreature() const;
231 virtual bool IsBoat() const;
232 virtual bool IsChestBoat() const;
233 virtual bool IsChestRaft() const;
234 virtual bool IsRaft() const;
235#endif
236#if PROTOCOL_VERSION > 772 /* > 1.21.8 */
237 virtual bool IsAvatar() const;
238#endif
239#if PROTOCOL_VERSION > 773 /* > 1.21.10 */
240 virtual bool IsAbstractNautilus() const;
241#endif
242#if PROTOCOL_VERSION > 775 /* > 26.1.2 */
243 virtual bool IsAbstractCubeMob() const;
244#endif
245
246 // Factory stuff
247 static std::shared_ptr<Entity> CreateEntity(const EntityType type);
248#if PROTOCOL_VERSION < 458 /* < 1.14 */
249 static std::shared_ptr<Entity> CreateObjectEntity(const ObjectEntityType type);
250#endif
251
252 protected:
253#if USE_GUI
254 virtual void InitializeFaces();
255 void OnSizeUpdated();
256#endif
257 char GetDataSharedFlagsIdImpl() const;
259 void SetDataSharedFlagsIdImpl(const char data_shared_flags_id);
260 void SetDataSharedFlagsIdImpl(const EntitySharedFlagsId id, const bool b);
261#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
262 Pose GetDataPoseImpl() const;
263 void SetDataPoseImpl(const Pose data_pose);
264#endif
265 AABB GetColliderImpl() const;
266 virtual double GetWidthImpl() const;
267 virtual double GetHeightImpl() const;
268
269 protected:
270 mutable std::shared_mutex entity_mutex;
271
275 float yaw;
276 float pitch;
279 /// @brief Items on this entity. Note that for the local player
280 /// this will **NOT** be populated. Check corresponding
281 /// player inventory slots instead.
282 std::map<EquipmentSlot, ProtocolCraft::Slot> equipments;
283 std::vector<EntityEffect> effects;
284
285 std::map<std::string, std::any> metadata;
286
287#if USE_GUI
288 //All the faces of this model
289 std::vector<FaceDescriptor> face_descriptors;
290 std::vector<Renderer::Face> faces;
291
293#endif
294 };
295
296 enum class EntityType
297 {
298 None = -1,
299#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
300#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
303#endif
304#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
305 Allay,
306#endif
308#if PROTOCOL_VERSION > 765 /* > 1.20.4 */
309 Armadillo,
310#endif
312 Arrow,
313#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
314 Axolotl,
315#endif
316#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
317 ChestRaft,
318 Raft,
319#endif
320 Bat,
321#if PROTOCOL_VERSION > 498 /* > 1.14.4 */
322 Bee,
323#endif
324#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
325 BirchBoat,
327#endif
328 Blaze,
329#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
331#endif
332#if PROTOCOL_VERSION < 768 /* < 1.21.2 */
333 Boat,
334#endif
335#if PROTOCOL_VERSION > 765 /* > 1.20.4 */
336 Bogged,
337#endif
338#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
339 Breeze,
340#endif
341#if PROTOCOL_VERSION > 765 /* > 1.20.4 */
343#endif
344#if PROTOCOL_VERSION > 758 /* > 1.18.2 */ && PROTOCOL_VERSION < 762 /* < 1.19.4 */
345 ChestBoat,
346#endif
347#if PROTOCOL_VERSION > 404 /* > 1.13.2 */ && PROTOCOL_VERSION < 762 /* < 1.19.4 */
348 Cat,
349#endif
350#if PROTOCOL_VERSION > 760 /* > 1.19.2 */
351 Camel,
352#endif
353#if PROTOCOL_VERSION > 773 /* > 1.21.10 */
354 CamelHusk,
355#endif
356#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
357 Cat,
358#endif
360#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
363#endif
364#if PROTOCOL_VERSION > 761 /* > 1.19.3 */ && PROTOCOL_VERSION < 768 /* < 1.21.2 */
365 ChestBoat,
366#endif
367#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
369#endif
370 Chicken,
371 Cod,
372#if PROTOCOL_VERSION > 772 /* > 1.21.8 */
374#endif
375#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
377#endif
378 Cow,
379#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
380 Creaking,
381#endif
382#if PROTOCOL_VERSION > 767 /* > 1.21.1 */ && PROTOCOL_VERSION < 769 /* < 1.21.4 */
383 CreakingTransient,
384#endif
385 Creeper,
386#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
389#endif
390#if PROTOCOL_VERSION < 735 /* < 1.16 */
391 Donkey,
392#endif
393 Dolphin,
394#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
395 Donkey,
396#endif
398 Drowned,
399#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
400 ThrownEgg,
401#endif
403#if PROTOCOL_VERSION < 768 /* < 1.21.2 */
406#endif
407#if PROTOCOL_VERSION > 761 /* > 1.19.3 */ && PROTOCOL_VERSION < 768 /* < 1.21.2 */
409#endif
410 EnderMan,
411 Endermite,
412#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
416#endif
417#if PROTOCOL_VERSION < 735 /* < 1.16 */
419#endif
420 Evoker,
421#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
423#endif
424#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
426#endif
430#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
432#endif
434#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
435 Fox,
436#endif
437#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
438 Frog,
439#endif
440#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
442#endif
443 Ghast,
444#if PROTOCOL_VERSION > 770 /* > 1.21.5 */
446#endif
447 Giant,
448#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
450 GlowSquid,
451 Goat,
452#endif
453 Guardian,
454#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
455 Hoglin,
456#endif
457#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
459#endif
460 Horse,
461 Husk,
463#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
465#endif
466#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
467 IronGolem,
468#endif
470#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
472#endif
473 ItemFrame,
474#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
477#endif
478#if PROTOCOL_VERSION > 765 /* > 1.20.4 */ && PROTOCOL_VERSION < 768 /* < 1.21.2 */
480#endif
481#if PROTOCOL_VERSION < 768 /* < 1.21.2 */
483#endif
485#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
487#endif
488 Llama,
489 LlamaSpit,
490 MagmaCube,
491#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
494#endif
495#if PROTOCOL_VERSION > 772 /* > 1.21.8 */
496 Mannequin,
497#endif
498#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
499 Marker,
500#endif
501 Minecart,
502#if PROTOCOL_VERSION < 762 /* < 1.19.4 */
509 Mule,
510#endif
512#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
513 Mule,
514#endif
515#if PROTOCOL_VERSION > 773 /* > 1.21.10 */
516 Nautilus,
517#endif
518#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
519 OakBoat,
521#endif
522 Ocelot,
523#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
525#endif
526 Painting,
527#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
530#endif
531#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
532 Panda,
533#endif
534#if PROTOCOL_VERSION > 773 /* > 1.21.10 */
535 Parched,
536#endif
537 Parrot,
538#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
539 Phantom,
540#endif
541 Pig,
542#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
543 Piglin,
544#endif
545#if PROTOCOL_VERSION > 736 /* > 1.16.1 */
547#endif
548#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
549 Pillager,
550#endif
551#if PROTOCOL_VERSION < 735 /* < 1.16 */
553 PigZombie,
554#endif
555 PolarBear,
556#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
559#endif
560#if PROTOCOL_VERSION > 761 /* > 1.19.3 */ && PROTOCOL_VERSION < 770 /* < 1.21.5 */
561 ThrownPotion,
562#endif
563#if PROTOCOL_VERSION < 762 /* < 1.19.4 */
564 PrimedTnt,
565#endif
566#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
568#endif
569 Rabbit,
570#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
571 Ravager,
572#endif
573 Salmon,
574 Sheep,
575 Shulker,
578 Skeleton,
580 Slime,
582#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
583 Sniffer,
584#endif
585#if PROTOCOL_VERSION < 768 /* < 1.21.2 */
586 SnowGolem,
587#endif
588 Snowball,
589#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
590 SnowGolem,
591#endif
592#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
594#endif
596 Spider,
597#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
600#endif
601 Squid,
602 Stray,
603#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
604 Strider,
605#endif
606#if PROTOCOL_VERSION > 775 /* > 26.1.2 */
608#endif
609#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
610 Tadpole,
611#endif
612#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
614 PrimedTnt,
616#endif
617#if PROTOCOL_VERSION > 404 /* > 1.13.2 */ && PROTOCOL_VERSION < 735 /* < 1.16 */
619#endif
620#if PROTOCOL_VERSION < 735 /* < 1.16 */
622 Turtle,
623#endif
624#if PROTOCOL_VERSION < 762 /* < 1.19.4 */
625 ThrownEgg,
628 ThrownPotion,
629#endif
630#if PROTOCOL_VERSION > 404 /* > 1.13.2 */ && PROTOCOL_VERSION < 762 /* < 1.19.4 */
632#endif
633#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
635#endif
636#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
638#endif
639#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
641 Turtle,
642#endif
643 Vex,
644 Villager,
645#if PROTOCOL_VERSION < 735 /* < 1.16 */
646 IronGolem,
647#endif
649#if PROTOCOL_VERSION > 404 /* > 1.13.2 */ && PROTOCOL_VERSION < 735 /* < 1.16 */
650 Pillager,
651#endif
652#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
654#endif
655#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
656 Warden,
657#endif
658#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
660#endif
661 Witch,
665 Wolf,
666#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
667 Zoglin,
668#endif
669 Zombie,
671#if PROTOCOL_VERSION > 773 /* > 1.21.10 */
673#endif
675#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
677#endif
678#if PROTOCOL_VERSION < 735 /* < 1.16 */
679 Phantom,
680#endif
681#if PROTOCOL_VERSION > 404 /* > 1.13.2 */ && PROTOCOL_VERSION < 735 /* < 1.16 */
682 Ravager,
683#endif
684#if PROTOCOL_VERSION < 735 /* < 1.16 */
686#endif
687 Player,
689#if PROTOCOL_VERSION < 477 /* < 1.14 */
691#endif
692#else
693 FishingHook = -3,
694 Player = -2,
695 ItemEntity = 1,
696 ExperienceOrb = 2,
697 AreaEffectCloud = 3,
698 ElderGuardian = 4,
699 WitherSkeleton = 5,
700 Stray = 6,
701 ThrownEgg = 7,
703 Painting = 9,
704 Arrow = 10,
705 Snowball = 11,
706 LargeFireball = 12,
707 SmallFireball = 13,
708 ThrownEnderpearl = 14,
709 EyeOfEnder = 15,
710 ThrownPotion = 16,
712 ItemFrame = 18,
713 WitherSkull = 19,
714 PrimedTnt = 20,
717 Husk = 23,
718 SpectralArrow = 24,
719 ShulkerBullet = 25,
720 DragonFireball = 26,
721 ZombieVillager = 27,
722 SkeletonHorse = 28,
723 ZombieHorse = 29,
724 ArmorStand = 30,
725 Donkey = 31,
726 Mule = 32,
727 EvokerFangs = 33,
728 Evoker = 34,
729 Vex = 35,
730 Vindicator = 36,
731 Illusioner = 37,
733 Boat = 41,
734 Minecart = 42,
735 MinecartChest = 43,
736 MinecartFurnace = 44,
737 MinecartTNT = 45,
738 MinecartHopper = 46,
739 MinecartSpawner = 47,
740 Creeper = 50,
741 Skeleton = 51,
742 Spider = 52,
743 Giant = 53,
744 Zombie = 54,
745 Slime = 55,
746 Ghast = 56,
747 PigZombie = 57,
748 EnderMan = 58,
749 CaveSpider = 59,
750 Silverfish = 60,
751 Blaze = 61,
752 MagmaCube = 62,
753 EnderDragon = 63,
754 WitherBoss = 64,
755 Bat = 65,
756 Witch = 66,
757 Endermite = 67,
758 Guardian = 68,
759 Shulker = 69,
760 Pig = 90,
761 Sheep = 91,
762 Cow = 92,
763 Chicken = 93,
764 Squid = 94,
765 Wolf = 95,
766 MushroomCow = 96,
767 SnowGolem = 97,
768 Ocelot = 98,
769 IronGolem = 99,
770 Horse = 100,
771 Rabbit = 101,
772 PolarBear = 102,
773 Llama = 103,
774 LlamaSpit = 104,
775 Parrot = 105,
776 Villager = 120,
777 EndCrystal = 200,
778#endif
780 };
781
782#if PROTOCOL_VERSION < 458 /* < 1.14 */
783 enum class ObjectEntityType
784 {
785 None = -1,
786 Boat = 1,
787 ItemEntity = 2,
788 AreaEffectCloud = 3,
789 PrimedTnt = 50,
790 EndCrystal = 51,
791 Arrow = 60,
792 Snowball = 61,
793 ThrownEgg = 62,
794 LargeFireball = 63,
795 SmallFireball = 64,
796 ThrownEnderpearl = 65,
797 WitherSkull = 66,
798 ShulkerBullet = 67,
799 LlamaSpit = 68,
800 FallingBlockEntity = 70,
801 ItemFrame = 71,
802 EyeOfEnder = 72,
803 ThrownPotion = 73,
805 FireworkRocketEntity = 76,
806 LeashFenceKnotEntity = 77,
807 ArmorStand = 78,
808 EvokerFangs = 79,
809 FishingHook = 90,
810 SpectralArrow = 91,
811 DragonFireball = 93,
812#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
813 ThrownTrident = 94,
814#endif
816 };
817#endif
818}
int GetDataTicksFrozen() const
Definition Entity.cpp:846
void OnSizeUpdated()
Definition Entity.cpp:2162
virtual EntityType GetType() const =0
bool GetOnGround() const
Definition Entity.cpp:993
ProtocolCraft::UUID uuid
Definition Entity.hpp:273
virtual double GetHeightImpl() const
Definition Entity.cpp:2233
void SetDataSilent(const bool data_silent)
Definition Entity.cpp:892
virtual ProtocolCraft::Json::Value Serialize() const
Definition Entity.cpp:1245
void SetDataPose(const Pose data_pose)
Definition Entity.cpp:905
std::map< EquipmentSlot, ProtocolCraft::Slot > equipments
Items on this entity.
Definition Entity.hpp:282
virtual void SetY(const double y_)
Definition Entity.cpp:1094
double GetZ() const
Definition Entity.cpp:951
virtual bool IsAbstractChestedHorse() const
Definition Entity.cpp:1350
virtual bool IsWaterAnimal() const
Definition Entity.cpp:1345
void SetEffects(const std::vector< EntityEffect > &effects_)
Definition Entity.cpp:1194
void SetDataAirSupplyId(const int data_air_supply_id)
Definition Entity.cpp:866
void SetDataSharedFlagsIdImpl(const char data_shared_flags_id)
Definition Entity.cpp:2187
Vector3< double > GetSpeed() const
Definition Entity.cpp:969
void SetUUID(const ProtocolCraft::UUID &uuid_)
Definition Entity.cpp:1053
std::map< EquipmentSlot, ProtocolCraft::Slot > GetEquipments() const
Definition Entity.cpp:999
Vector3< double > speed
Definition Entity.hpp:277
virtual bool IsAbstractArrow() const
Definition Entity.cpp:1301
virtual bool IsAbstractSkeleton() const
Definition Entity.cpp:1457
virtual bool IsAbstractPiglin() const
Definition Entity.cpp:1427
int GetEntityID() const
Definition Entity.cpp:921
virtual bool IsLocalPlayer() const
Definition Entity.cpp:1286
double GetHeight() const
Definition Entity.cpp:361
std::vector< EntityEffect > effects
Definition Entity.hpp:283
char GetDataSharedFlagsIdImpl() const
Definition Entity.cpp:2177
virtual bool IsRemotePlayer() const
Definition Entity.cpp:1291
virtual bool IsAbstractNautilus() const
Definition Entity.cpp:1555
bool GetDataSilent() const
Definition Entity.cpp:825
void SetDataPoseImpl(const Pose data_pose)
Definition Entity.cpp:2209
double GetSpeedX() const
Definition Entity.cpp:975
virtual bool IsAbstractBoat() const
Definition Entity.cpp:1511
virtual bool IsAbstractHurtingProjectile() const
Definition Entity.cpp:1355
ProtocolCraft::UUID GetUUID() const
Definition Entity.cpp:927
double GetY() const
Definition Entity.cpp:945
virtual bool IsAbstractSchoolingFish() const
Definition Entity.cpp:1340
void SetSpeed(const Vector3< double > &speed_)
Definition Entity.cpp:1158
virtual bool IsHangingEntity() const
Definition Entity.cpp:1394
bool GetAreRenderedFacesUpToDate() const
Definition Entity.cpp:1039
virtual void SetMetadataValue(const int index, const std::any &value)
Definition Entity.cpp:772
virtual bool IsSpellcasterIllager() const
Definition Entity.cpp:1365
virtual bool IsBlockAttachedEntity() const
Definition Entity.cpp:1504
static std::shared_ptr< Entity > CreateEntity(const EntityType type)
Definition Entity.cpp:1569
static constexpr int hierarchy_metadata_count
Definition Entity.hpp:62
virtual bool IsAbstractThrownPotion() const
Definition Entity.cpp:1439
AABB GetCollider() const
Definition Entity.cpp:349
static const std::array< std::string, metadata_count > metadata_names
Definition Entity.hpp:61
bool are_rendered_faces_up_to_date
Definition Entity.hpp:292
virtual double GetWidthImpl() const
Definition Entity.cpp:2228
virtual void SetZ(const double z_)
Definition Entity.cpp:1110
void SetEquipment(const EquipmentSlot slot, const ProtocolCraft::Slot &item)
Definition Entity.cpp:1188
std::vector< Renderer::Face > faces
Definition Entity.hpp:290
virtual bool IsLivingEntity() const
Definition Entity.cpp:1296
virtual bool IsChestBoat() const
Definition Entity.cpp:1531
double GetWidth() const
Definition Entity.cpp:355
virtual ~Entity()
Definition Entity.cpp:343
virtual bool IsPatrollingMonster() const
Definition Entity.cpp:1485
virtual bool IsProjectile() const
Definition Entity.cpp:1371
int GetDataAirSupplyId() const
Definition Entity.cpp:799
std::vector< EntityEffect > GetEffects() const
Definition Entity.cpp:1011
virtual bool IsAbstractMinecart() const
Definition Entity.cpp:1404
virtual bool IsAvatar() const
Definition Entity.cpp:1548
virtual bool IsDisplay() const
Definition Entity.cpp:1322
void SetSpeedY(const double speed_y_)
Definition Entity.cpp:1170
virtual bool IsAbstractMinecartContainer() const
Definition Entity.cpp:1416
void SetDataCustomName(const std::optional< ProtocolCraft::Chat > &data_custom_name)
Definition Entity.cpp:873
virtual bool IsAmbientCreature() const
Definition Entity.cpp:1311
virtual bool IsFireball() const
Definition Entity.cpp:1399
Pose GetDataPose() const
Definition Entity.cpp:838
std::shared_mutex entity_mutex
Definition Entity.hpp:270
void SetOnGround(const bool on_ground_)
Definition Entity.cpp:1182
virtual bool IsAnimal() const
Definition Entity.cpp:1306
std::vector< Renderer::Face > GetFaces(const bool reset_uptodate_status)
Definition Entity.cpp:1018
void SetSpeedX(const double speed_x_)
Definition Entity.cpp:1164
virtual bool IsAbstractFish() const
Definition Entity.cpp:1445
virtual bool IsAbstractCubeMob() const
Definition Entity.cpp:1562
virtual bool IsAgeableMob() const
Definition Entity.cpp:1474
virtual void SetX(const double x_)
Definition Entity.cpp:1078
virtual bool IsAbstractVillager() const
Definition Entity.cpp:1468
virtual void InitializeFaces()
Definition Entity.cpp:2080
virtual bool IsThrowableProjectile() const
Definition Entity.cpp:1491
virtual bool IsAbstractWindCharge() const
Definition Entity.cpp:1497
AABB GetColliderImpl() const
Definition Entity.cpp:2218
void SetDataSharedFlagsId(const char data_shared_flags_id)
Definition Entity.cpp:854
char GetDataSharedFlagsId() const
Definition Entity.cpp:787
virtual bool IsMob() const
Definition Entity.cpp:1360
virtual void SetYaw(const float yaw_)
Definition Entity.cpp:1126
virtual bool IsPathfinderMob() const
Definition Entity.cpp:1479
ProtocolCraft::Slot GetEquipment(const EquipmentSlot slot) const
Definition Entity.cpp:1005
void SetDataCustomNameVisible(const bool data_custom_name_visible)
Definition Entity.cpp:886
virtual bool IsVehicle() const
Definition Entity.cpp:1329
double GetSpeedY() const
Definition Entity.cpp:981
double GetSpeedZ() const
Definition Entity.cpp:987
virtual std::string GetName() const =0
Pose GetDataPoseImpl() const
Definition Entity.cpp:2204
virtual bool IsRaider() const
Definition Entity.cpp:1451
virtual void SetPitch(const float pitch_)
Definition Entity.cpp:1142
virtual bool IsThrowableItemProjectile() const
Definition Entity.cpp:1462
void SetEntityID(const int entity_id_)
Definition Entity.cpp:1047
virtual bool IsMonster() const
Definition Entity.cpp:1316
virtual bool IsTamableAnimal() const
Definition Entity.cpp:1335
void SetDataNoGravity(const bool data_no_gravity)
Definition Entity.cpp:898
bool GetDataCustomNameVisible() const
Definition Entity.cpp:819
virtual bool IsAbstractIllager() const
Definition Entity.cpp:1433
virtual bool IsAbstractHorse() const
Definition Entity.cpp:1384
std::map< std::string, std::any > metadata
Definition Entity.hpp:285
Vector3< double > position
Definition Entity.hpp:274
virtual bool IsAbstractCow() const
Definition Entity.cpp:1410
virtual bool IsAbstractChestBoat() const
Definition Entity.cpp:1516
void AddEffect(const EntityEffect &effect)
Definition Entity.cpp:1216
virtual bool IsChestRaft() const
Definition Entity.cpp:1536
virtual bool IsAbstractGolem() const
Definition Entity.cpp:1389
float GetYaw() const
Definition Entity.cpp:957
virtual bool IsAgeableWaterCreature() const
Definition Entity.cpp:1521
double GetX() const
Definition Entity.cpp:939
bool GetDataNoGravity() const
Definition Entity.cpp:831
void SetAreRenderedFacesUpToDate(const bool are_rendered_faces_up_to_date_)
Definition Entity.cpp:1237
Vector3< double > GetPosition() const
Definition Entity.cpp:933
void SetSpeedZ(const double speed_z_)
Definition Entity.cpp:1176
static constexpr int metadata_count
Definition Entity.hpp:55
std::vector< FaceDescriptor > face_descriptors
Definition Entity.hpp:289
std::optional< ProtocolCraft::Chat > GetDataCustomName() const
Definition Entity.cpp:806
virtual bool IsBoat() const
Definition Entity.cpp:1526
void LoadMetadataFromRawArray(const std::vector< unsigned char > &data)
Definition Entity.cpp:368
virtual bool IsRaft() const
Definition Entity.cpp:1541
virtual bool IsShoulderRidingEntity() const
Definition Entity.cpp:1421
float GetPitch() const
Definition Entity.cpp:963
void RemoveEffect(const EntityEffectType type)
Definition Entity.cpp:1200
virtual void SetPosition(const Vector3< double > &position_)
Definition Entity.cpp:1059
void SetDataTicksFrozen(const int data_ticks_frozen)
Definition Entity.cpp:913
Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant direc...
Definition Json.hpp:45
EquipmentSlot
Definition Enums.hpp:282
EntityEffectType
Definition Enums.hpp:327
EntitySharedFlagsId
Definition Entity.hpp:40
std::array< unsigned char, 16 > UUID
std::chrono::steady_clock::time_point end
Definition Entity.hpp:36
unsigned char amplifier
Definition Entity.hpp:35
EntityEffectType type
Definition Entity.hpp:34