Botcraft 26.3
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 > 776 /* > 26.2 */
387 Cushion,
388#endif
389#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
392#endif
393#if PROTOCOL_VERSION < 735 /* < 1.16 */
394 Donkey,
395#endif
396 Dolphin,
397#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
398 Donkey,
399#endif
401 Drowned,
402#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
403 ThrownEgg,
404#endif
406#if PROTOCOL_VERSION < 768 /* < 1.21.2 */
409#endif
410#if PROTOCOL_VERSION > 761 /* > 1.19.3 */ && PROTOCOL_VERSION < 768 /* < 1.21.2 */
412#endif
413 EnderMan,
414 Endermite,
415#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
419#endif
420#if PROTOCOL_VERSION < 735 /* < 1.16 */
422#endif
423 Evoker,
424#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
426#endif
427#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
429#endif
433#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
435#endif
437#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
438 Fox,
439#endif
440#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
441 Frog,
442#endif
443#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
445#endif
446 Ghast,
447#if PROTOCOL_VERSION > 770 /* > 1.21.5 */
449#endif
450 Giant,
451#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
453 GlowSquid,
454 Goat,
455#endif
456 Guardian,
457#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
458 Hoglin,
459#endif
460#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
462#endif
463 Horse,
464 Husk,
466#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
468#endif
469#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
470 IronGolem,
471#endif
473#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
475#endif
476 ItemFrame,
477#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
480#endif
481#if PROTOCOL_VERSION > 765 /* > 1.20.4 */ && PROTOCOL_VERSION < 768 /* < 1.21.2 */
483#endif
484#if PROTOCOL_VERSION < 768 /* < 1.21.2 */
486#endif
488#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
490#endif
491 Llama,
492 LlamaSpit,
493 MagmaCube,
494#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
497#endif
498#if PROTOCOL_VERSION > 772 /* > 1.21.8 */
499 Mannequin,
500#endif
501#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
502 Marker,
503#endif
504 Minecart,
505#if PROTOCOL_VERSION < 762 /* < 1.19.4 */
512 Mule,
513#endif
515#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
516 Mule,
517#endif
518#if PROTOCOL_VERSION > 773 /* > 1.21.10 */
519 Nautilus,
520#endif
521#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
522 OakBoat,
524#endif
525 Ocelot,
526#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
528#endif
529 Painting,
530#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
533#endif
534#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
535 Panda,
536#endif
537#if PROTOCOL_VERSION > 773 /* > 1.21.10 */
538 Parched,
539#endif
540 Parrot,
541#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
542 Phantom,
543#endif
544 Pig,
545#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
546 Piglin,
547#endif
548#if PROTOCOL_VERSION > 736 /* > 1.16.1 */
550#endif
551#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
552 Pillager,
553#endif
554#if PROTOCOL_VERSION < 735 /* < 1.16 */
556 PigZombie,
557#endif
558 PolarBear,
559#if PROTOCOL_VERSION > 776 /* > 26.2 */
562#endif
563#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
566#endif
567#if PROTOCOL_VERSION > 761 /* > 1.19.3 */ && PROTOCOL_VERSION < 770 /* < 1.21.5 */
568 ThrownPotion,
569#endif
570#if PROTOCOL_VERSION < 762 /* < 1.19.4 */
571 PrimedTnt,
572#endif
573#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
575#endif
576 Rabbit,
577#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
578 Ravager,
579#endif
580 Salmon,
581 Sheep,
582 Shulker,
585 Skeleton,
587 Slime,
589#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
590 Sniffer,
591#endif
592#if PROTOCOL_VERSION < 768 /* < 1.21.2 */
593 SnowGolem,
594#endif
595 Snowball,
596#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
597 SnowGolem,
598#endif
599#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
601#endif
603 Spider,
604#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
607#endif
608 Squid,
609 Stray,
610#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
611 Strider,
612#endif
613#if PROTOCOL_VERSION > 775 /* > 26.1.2 */
615#endif
616#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
617 Tadpole,
618#endif
619#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
621 PrimedTnt,
623#endif
624#if PROTOCOL_VERSION > 404 /* > 1.13.2 */ && PROTOCOL_VERSION < 735 /* < 1.16 */
626#endif
627#if PROTOCOL_VERSION < 735 /* < 1.16 */
629 Turtle,
630#endif
631#if PROTOCOL_VERSION < 762 /* < 1.19.4 */
632 ThrownEgg,
635 ThrownPotion,
636#endif
637#if PROTOCOL_VERSION > 404 /* > 1.13.2 */ && PROTOCOL_VERSION < 762 /* < 1.19.4 */
639#endif
640#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
642#endif
643#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
645#endif
646#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
648 Turtle,
649#endif
650 Vex,
651 Villager,
652#if PROTOCOL_VERSION < 735 /* < 1.16 */
653 IronGolem,
654#endif
656#if PROTOCOL_VERSION > 404 /* > 1.13.2 */ && PROTOCOL_VERSION < 735 /* < 1.16 */
657 Pillager,
658#endif
659#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
661#endif
662#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
663 Warden,
664#endif
665#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
667#endif
668 Witch,
672 Wolf,
673#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
674 Zoglin,
675#endif
676 Zombie,
678#if PROTOCOL_VERSION > 773 /* > 1.21.10 */
680#endif
682#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
684#endif
685#if PROTOCOL_VERSION < 735 /* < 1.16 */
686 Phantom,
687#endif
688#if PROTOCOL_VERSION > 404 /* > 1.13.2 */ && PROTOCOL_VERSION < 735 /* < 1.16 */
689 Ravager,
690#endif
691#if PROTOCOL_VERSION < 735 /* < 1.16 */
693#endif
694 Player,
696#if PROTOCOL_VERSION < 477 /* < 1.14 */
698#endif
699#else
700 FishingHook = -3,
701 Player = -2,
702 ItemEntity = 1,
703 ExperienceOrb = 2,
704 AreaEffectCloud = 3,
705 ElderGuardian = 4,
706 WitherSkeleton = 5,
707 Stray = 6,
708 ThrownEgg = 7,
710 Painting = 9,
711 Arrow = 10,
712 Snowball = 11,
713 LargeFireball = 12,
714 SmallFireball = 13,
715 ThrownEnderpearl = 14,
716 EyeOfEnder = 15,
717 ThrownPotion = 16,
719 ItemFrame = 18,
720 WitherSkull = 19,
721 PrimedTnt = 20,
724 Husk = 23,
725 SpectralArrow = 24,
726 ShulkerBullet = 25,
727 DragonFireball = 26,
728 ZombieVillager = 27,
729 SkeletonHorse = 28,
730 ZombieHorse = 29,
731 ArmorStand = 30,
732 Donkey = 31,
733 Mule = 32,
734 EvokerFangs = 33,
735 Evoker = 34,
736 Vex = 35,
737 Vindicator = 36,
738 Illusioner = 37,
740 Boat = 41,
741 Minecart = 42,
742 MinecartChest = 43,
743 MinecartFurnace = 44,
744 MinecartTNT = 45,
745 MinecartHopper = 46,
746 MinecartSpawner = 47,
747 Creeper = 50,
748 Skeleton = 51,
749 Spider = 52,
750 Giant = 53,
751 Zombie = 54,
752 Slime = 55,
753 Ghast = 56,
754 PigZombie = 57,
755 EnderMan = 58,
756 CaveSpider = 59,
757 Silverfish = 60,
758 Blaze = 61,
759 MagmaCube = 62,
760 EnderDragon = 63,
761 WitherBoss = 64,
762 Bat = 65,
763 Witch = 66,
764 Endermite = 67,
765 Guardian = 68,
766 Shulker = 69,
767 Pig = 90,
768 Sheep = 91,
769 Cow = 92,
770 Chicken = 93,
771 Squid = 94,
772 Wolf = 95,
773 MushroomCow = 96,
774 SnowGolem = 97,
775 Ocelot = 98,
776 IronGolem = 99,
777 Horse = 100,
778 Rabbit = 101,
779 PolarBear = 102,
780 Llama = 103,
781 LlamaSpit = 104,
782 Parrot = 105,
783 Villager = 120,
784 EndCrystal = 200,
785#endif
787 };
788
789#if PROTOCOL_VERSION < 458 /* < 1.14 */
790 enum class ObjectEntityType
791 {
792 None = -1,
793 Boat = 1,
794 ItemEntity = 2,
795 AreaEffectCloud = 3,
796 PrimedTnt = 50,
797 EndCrystal = 51,
798 Arrow = 60,
799 Snowball = 61,
800 ThrownEgg = 62,
801 LargeFireball = 63,
802 SmallFireball = 64,
803 ThrownEnderpearl = 65,
804 WitherSkull = 66,
805 ShulkerBullet = 67,
806 LlamaSpit = 68,
807 FallingBlockEntity = 70,
808 ItemFrame = 71,
809 EyeOfEnder = 72,
810 ThrownPotion = 73,
812 FireworkRocketEntity = 76,
813 LeashFenceKnotEntity = 77,
814 ArmorStand = 78,
815 EvokerFangs = 79,
816 FishingHook = 90,
817 SpectralArrow = 91,
818 DragonFireball = 93,
819#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
820 ThrownTrident = 94,
821#endif
823 };
824#endif
825}
int GetDataTicksFrozen() const
Definition Entity.cpp:857
void OnSizeUpdated()
Definition Entity.cpp:2183
virtual EntityType GetType() const =0
bool GetOnGround() const
Definition Entity.cpp:1004
ProtocolCraft::UUID uuid
Definition Entity.hpp:273
virtual double GetHeightImpl() const
Definition Entity.cpp:2254
void SetDataSilent(const bool data_silent)
Definition Entity.cpp:903
virtual ProtocolCraft::Json::Value Serialize() const
Definition Entity.cpp:1256
void SetDataPose(const Pose data_pose)
Definition Entity.cpp:916
std::map< EquipmentSlot, ProtocolCraft::Slot > equipments
Items on this entity.
Definition Entity.hpp:282
virtual void SetY(const double y_)
Definition Entity.cpp:1105
double GetZ() const
Definition Entity.cpp:962
virtual bool IsAbstractChestedHorse() const
Definition Entity.cpp:1361
virtual bool IsWaterAnimal() const
Definition Entity.cpp:1356
void SetEffects(const std::vector< EntityEffect > &effects_)
Definition Entity.cpp:1205
void SetDataAirSupplyId(const int data_air_supply_id)
Definition Entity.cpp:877
void SetDataSharedFlagsIdImpl(const char data_shared_flags_id)
Definition Entity.cpp:2208
Vector3< double > GetSpeed() const
Definition Entity.cpp:980
void SetUUID(const ProtocolCraft::UUID &uuid_)
Definition Entity.cpp:1064
std::map< EquipmentSlot, ProtocolCraft::Slot > GetEquipments() const
Definition Entity.cpp:1010
Vector3< double > speed
Definition Entity.hpp:277
virtual bool IsAbstractArrow() const
Definition Entity.cpp:1312
virtual bool IsAbstractSkeleton() const
Definition Entity.cpp:1468
virtual bool IsAbstractPiglin() const
Definition Entity.cpp:1438
int GetEntityID() const
Definition Entity.cpp:932
virtual bool IsLocalPlayer() const
Definition Entity.cpp:1297
double GetHeight() const
Definition Entity.cpp:364
std::vector< EntityEffect > effects
Definition Entity.hpp:283
char GetDataSharedFlagsIdImpl() const
Definition Entity.cpp:2198
virtual bool IsRemotePlayer() const
Definition Entity.cpp:1302
virtual bool IsAbstractNautilus() const
Definition Entity.cpp:1566
bool GetDataSilent() const
Definition Entity.cpp:836
void SetDataPoseImpl(const Pose data_pose)
Definition Entity.cpp:2230
double GetSpeedX() const
Definition Entity.cpp:986
virtual bool IsAbstractBoat() const
Definition Entity.cpp:1522
virtual bool IsAbstractHurtingProjectile() const
Definition Entity.cpp:1366
ProtocolCraft::UUID GetUUID() const
Definition Entity.cpp:938
double GetY() const
Definition Entity.cpp:956
virtual bool IsAbstractSchoolingFish() const
Definition Entity.cpp:1351
void SetSpeed(const Vector3< double > &speed_)
Definition Entity.cpp:1169
virtual bool IsHangingEntity() const
Definition Entity.cpp:1405
bool GetAreRenderedFacesUpToDate() const
Definition Entity.cpp:1050
virtual void SetMetadataValue(const int index, const std::any &value)
Definition Entity.cpp:783
virtual bool IsSpellcasterIllager() const
Definition Entity.cpp:1376
virtual bool IsBlockAttachedEntity() const
Definition Entity.cpp:1515
static std::shared_ptr< Entity > CreateEntity(const EntityType type)
Definition Entity.cpp:1580
static constexpr int hierarchy_metadata_count
Definition Entity.hpp:62
virtual bool IsAbstractThrownPotion() const
Definition Entity.cpp:1450
AABB GetCollider() const
Definition Entity.cpp:352
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:2249
virtual void SetZ(const double z_)
Definition Entity.cpp:1121
void SetEquipment(const EquipmentSlot slot, const ProtocolCraft::Slot &item)
Definition Entity.cpp:1199
std::vector< Renderer::Face > faces
Definition Entity.hpp:290
virtual bool IsLivingEntity() const
Definition Entity.cpp:1307
virtual bool IsChestBoat() const
Definition Entity.cpp:1542
double GetWidth() const
Definition Entity.cpp:358
virtual ~Entity()
Definition Entity.cpp:346
virtual bool IsPatrollingMonster() const
Definition Entity.cpp:1496
virtual bool IsProjectile() const
Definition Entity.cpp:1382
int GetDataAirSupplyId() const
Definition Entity.cpp:810
std::vector< EntityEffect > GetEffects() const
Definition Entity.cpp:1022
virtual bool IsAbstractMinecart() const
Definition Entity.cpp:1415
virtual bool IsAvatar() const
Definition Entity.cpp:1559
virtual bool IsDisplay() const
Definition Entity.cpp:1333
void SetSpeedY(const double speed_y_)
Definition Entity.cpp:1181
virtual bool IsAbstractMinecartContainer() const
Definition Entity.cpp:1427
void SetDataCustomName(const std::optional< ProtocolCraft::Chat > &data_custom_name)
Definition Entity.cpp:884
virtual bool IsAmbientCreature() const
Definition Entity.cpp:1322
virtual bool IsFireball() const
Definition Entity.cpp:1410
Pose GetDataPose() const
Definition Entity.cpp:849
std::shared_mutex entity_mutex
Definition Entity.hpp:270
void SetOnGround(const bool on_ground_)
Definition Entity.cpp:1193
virtual bool IsAnimal() const
Definition Entity.cpp:1317
std::vector< Renderer::Face > GetFaces(const bool reset_uptodate_status)
Definition Entity.cpp:1029
void SetSpeedX(const double speed_x_)
Definition Entity.cpp:1175
virtual bool IsAbstractFish() const
Definition Entity.cpp:1456
virtual bool IsAbstractCubeMob() const
Definition Entity.cpp:1573
virtual bool IsAgeableMob() const
Definition Entity.cpp:1485
virtual void SetX(const double x_)
Definition Entity.cpp:1089
virtual bool IsAbstractVillager() const
Definition Entity.cpp:1479
virtual void InitializeFaces()
Definition Entity.cpp:2101
virtual bool IsThrowableProjectile() const
Definition Entity.cpp:1502
virtual bool IsAbstractWindCharge() const
Definition Entity.cpp:1508
AABB GetColliderImpl() const
Definition Entity.cpp:2239
void SetDataSharedFlagsId(const char data_shared_flags_id)
Definition Entity.cpp:865
char GetDataSharedFlagsId() const
Definition Entity.cpp:798
virtual bool IsMob() const
Definition Entity.cpp:1371
virtual void SetYaw(const float yaw_)
Definition Entity.cpp:1137
virtual bool IsPathfinderMob() const
Definition Entity.cpp:1490
ProtocolCraft::Slot GetEquipment(const EquipmentSlot slot) const
Definition Entity.cpp:1016
void SetDataCustomNameVisible(const bool data_custom_name_visible)
Definition Entity.cpp:897
virtual bool IsVehicle() const
Definition Entity.cpp:1340
double GetSpeedY() const
Definition Entity.cpp:992
double GetSpeedZ() const
Definition Entity.cpp:998
virtual std::string GetName() const =0
Pose GetDataPoseImpl() const
Definition Entity.cpp:2225
virtual bool IsRaider() const
Definition Entity.cpp:1462
virtual void SetPitch(const float pitch_)
Definition Entity.cpp:1153
virtual bool IsThrowableItemProjectile() const
Definition Entity.cpp:1473
void SetEntityID(const int entity_id_)
Definition Entity.cpp:1058
virtual bool IsMonster() const
Definition Entity.cpp:1327
virtual bool IsTamableAnimal() const
Definition Entity.cpp:1346
void SetDataNoGravity(const bool data_no_gravity)
Definition Entity.cpp:909
bool GetDataCustomNameVisible() const
Definition Entity.cpp:830
virtual bool IsAbstractIllager() const
Definition Entity.cpp:1444
virtual bool IsAbstractHorse() const
Definition Entity.cpp:1395
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:1421
virtual bool IsAbstractChestBoat() const
Definition Entity.cpp:1527
void AddEffect(const EntityEffect &effect)
Definition Entity.cpp:1227
virtual bool IsChestRaft() const
Definition Entity.cpp:1547
virtual bool IsAbstractGolem() const
Definition Entity.cpp:1400
float GetYaw() const
Definition Entity.cpp:968
virtual bool IsAgeableWaterCreature() const
Definition Entity.cpp:1532
double GetX() const
Definition Entity.cpp:950
bool GetDataNoGravity() const
Definition Entity.cpp:842
void SetAreRenderedFacesUpToDate(const bool are_rendered_faces_up_to_date_)
Definition Entity.cpp:1248
Vector3< double > GetPosition() const
Definition Entity.cpp:944
void SetSpeedZ(const double speed_z_)
Definition Entity.cpp:1187
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:817
virtual bool IsBoat() const
Definition Entity.cpp:1537
void LoadMetadataFromRawArray(const std::vector< unsigned char > &data)
Definition Entity.cpp:371
virtual bool IsRaft() const
Definition Entity.cpp:1552
virtual bool IsShoulderRidingEntity() const
Definition Entity.cpp:1432
float GetPitch() const
Definition Entity.cpp:974
void RemoveEffect(const EntityEffectType type)
Definition Entity.cpp:1211
virtual void SetPosition(const Vector3< double > &position_)
Definition Entity.cpp:1070
void SetDataTicksFrozen(const int data_ticks_frozen)
Definition Entity.cpp:924
Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant direc...
Definition Json.hpp:45
EquipmentSlot
Definition Enums.hpp:285
EntityEffectType
Definition Enums.hpp:330
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