Botcraft 1.21.10
Loading...
Searching...
No Matches
Entity.cpp
Go to the documentation of this file.
2
6#if PROTOCOL_VERSION < 773 /* < 1.21.9 */
8#endif
9#if PROTOCOL_VERSION > 772 /* > 1.21.8 */
11#endif
12#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
14#endif
15#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
17#endif
18
19#if USE_GUI
22#endif
24
25#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
28#endif
29#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
31#endif
33#if PROTOCOL_VERSION > 765 /* > 1.20.4 */
35#endif
38#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
40#endif
41#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
44#endif
46#if PROTOCOL_VERSION > 498 /* > 1.14.4 */
48#endif
51#if PROTOCOL_VERSION > 765 /* > 1.20.4 */
53#endif
54#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
56#endif
57#if PROTOCOL_VERSION > 765 /* > 1.20.4 */
59#endif
60#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
62#endif
63#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
65#endif
66#if PROTOCOL_VERSION > 760 /* > 1.19.2 */
68#endif
71#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
73#endif
74#if PROTOCOL_VERSION > 772 /* > 1.21.8 */
76#endif
78#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
80#endif
81#if PROTOCOL_VERSION > 767 /* > 1.21.1 */ && PROTOCOL_VERSION < 769 /* < 1.21.4 */
83#endif
85#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
87#endif
90#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
92#endif
93#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
98#endif
110#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
112#endif
113#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
115#endif
117#if PROTOCOL_VERSION > 770 /* > 1.21.5 */
119#endif
121#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
125#endif
127#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
129#endif
133#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
135#endif
139#if PROTOCOL_VERSION > 765 /* > 1.20.4 */
141#endif
148#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
150#endif
151#if PROTOCOL_VERSION > 772 /* > 1.21.8 */
153#endif
165#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
167#endif
169#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
171#endif
173#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
175#else
177#endif
178#if PROTOCOL_VERSION > 736 /* > 1.16.1 */
180#endif
181#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
183#endif
185#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
188#endif
190#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
192#endif
194#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
196#endif
197#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
199#endif
200#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
202#else
204#endif
212#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
214#endif
221#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
223#endif
224#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
226#endif
231#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
233#endif
234#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
236#endif
237
238#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
240#endif
241#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
243#endif
247#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
249#endif
250#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
252#endif
253#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
255#endif
260#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
262#else
264#endif
265#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
267#endif
271#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
273#endif
276
277#include <mutex>
278
279namespace Botcraft
280{
281 const std::array<std::string, Entity::metadata_count> Entity::metadata_names{ {
282 "data_shared_flags_id",
283 "data_air_supply_id",
284 "data_custom_name",
285 "data_custom_name_visible",
286 "data_silent",
287 "data_no_gravity",
288#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
289 "data_pose",
290#endif
291#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
292 "data_ticks_frozen",
293#endif
294 } };
295
297 {
298 {
299 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
300 // Initialize base stuff
301 entity_id = 0;
302 position = Vector3<double>(0.0, 0.0, 0.0);
303 yaw = 0.0f;
304 pitch = 0.0f;
305 speed = Vector3<double>(0.0, 0.0, 0.0);
306 on_ground = false;
307 equipments = {
314#if PROTOCOL_VERSION > 766 /* > 1.20.6 */
316#endif
317 };
318 }
319
320 // Initialize all metadata with default values
323#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
324 SetDataCustomName(std::optional<ProtocolCraft::Chat>());
325#else
327#endif
329 SetDataSilent(false);
330 SetDataNoGravity(false);
331#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
333#endif
334#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
336#endif
337 }
338
340 {
341
342 }
343
344
346 {
347 std::shared_lock<std::shared_mutex> lock(entity_mutex);
348 return GetColliderImpl();
349 }
350
351 double Entity::GetWidth() const
352 {
353 std::shared_lock<std::shared_mutex> lock(entity_mutex);
354 return GetWidthImpl();
355 }
356
357 double Entity::GetHeight() const
358 {
359 std::shared_lock<std::shared_mutex> lock(entity_mutex);
360 return GetHeightImpl();
361 }
362
363
364 void Entity::LoadMetadataFromRawArray(const std::vector<unsigned char>& data)
365 {
366 if (data.size() == 0)
367 {
368 return;
369 }
370
371 ProtocolCraft::ReadIterator iter = data.begin();
372 size_t length = data.size();
373
374 while (true)
375 {
376 const unsigned char index = ProtocolCraft::ReadData<unsigned char>(iter, length);
377 if (index == 0xFF)
378 {
379 break;
380 }
381
382 const int type = ProtocolCraft::ReadData<ProtocolCraft::VarInt>(iter, length);
383 std::any value;
384
385 enum EntityMetadataTypes
386 {
387 Char = 0,
388 Int,
389#if PROTOCOL_VERSION > 760 /* > 1.19.2 */
390 Long,
391#endif
392 Float,
393 String,
394 Chat,
395#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
396 OptionalChat,
397#endif
398 Slot,
399 Bool,
400 Rotations,
401 BlockPosition,
402 OptionalBlockPosition,
403 DirectionType,
404#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
405 OptionalLivingEntityReference, // Fancy new name for 1.21.5, but it's still an optional UUID
406#else
407 OptionalUUID,
408#endif
409 BlockstateType,
410#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
411 OptionalBlockstate,
412#endif
413#if PROTOCOL_VERSION < 773 /* < 1.21.9 */
414 NBT,
415#endif
416#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
417 Particle,
418#endif
419#if PROTOCOL_VERSION > 765 /* > 1.20.4 */
420 Particles,
421#endif
422#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
423 VillagerDataType,
424 OptionalUint,
425 PoseType,
426#endif
427#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
428 CatVariant,
429#endif
430#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
431 CowVariant,
432#endif
433#if PROTOCOL_VERSION > 765 /* > 1.20.4 */
434 WolfVariant,
435#endif
436#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
437 WolfSoundVariant,
438#endif
439#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
440 FrogVariant,
441#endif
442#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
443 PigVariant,
444 ChickenVariant,
445#endif
446#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
447 OptionalGlobalPos,
448 PaintingVariant,
449#endif
450#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
451 SnifferState,
452#if PROTOCOL_VERSION > 765 /* > 1.20.4 */
453 ArmadilloState,
454#endif
455#if PROTOCOL_VERSION > 772 /* > 1.21.8 */
456 CopperGolemState,
457 WeatheringCopperState,
458#endif
459 Vec3,
460 Quaternion,
461#if PROTOCOL_VERSION > 772 /* > 1.21.8 */
462 ResolvableProfile,
463#endif
464#endif
465 };
466
467 switch (type)
468 {
469 case EntityMetadataTypes::Char:
470 value = ProtocolCraft::ReadData<char>(iter, length);
471 break;
472 case EntityMetadataTypes::Int:
473 value = static_cast<int>(ProtocolCraft::ReadData<ProtocolCraft::VarInt>(iter, length));
474 break;
475#if PROTOCOL_VERSION > 760 /* > 1.19.2 */
476 case EntityMetadataTypes::Long:
477 value = static_cast<long long int>(ProtocolCraft::ReadData<ProtocolCraft::VarLong>(iter, length));
478 break;
479#endif
480 case EntityMetadataTypes::Float:
481 value = ProtocolCraft::ReadData<float>(iter, length);
482 break;
483 case EntityMetadataTypes::String:
484 value = ProtocolCraft::ReadData<std::string>(iter, length);
485 break;
486 case EntityMetadataTypes::Chat:
487 value = ProtocolCraft::Chat();
488 std::any_cast<ProtocolCraft::Chat&>(value).Read(iter, length);
489 break;
490#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
491 case EntityMetadataTypes::OptionalChat:
492 if (ProtocolCraft::ReadData<bool>(iter, length))
493 {
494 value = std::optional<ProtocolCraft::Chat>(ProtocolCraft::Chat());
495 std::any_cast<std::optional<ProtocolCraft::Chat>&>(value).value().Read(iter, length);
496 }
497 else
498 {
499 value = std::optional<ProtocolCraft::Chat>();
500 }
501 break;
502#endif
503 case EntityMetadataTypes::Slot:
504 value = ProtocolCraft::Slot();
505 std::any_cast<ProtocolCraft::Slot&>(value).Read(iter, length);
506 break;
507 case EntityMetadataTypes::Bool:
508 value = ProtocolCraft::ReadData<bool>(iter, length);
509 break;
510 case EntityMetadataTypes::Rotations:
511 {
512 Vector3<float> rotation;
513 for (int i = 0; i < 3; ++i)
514 {
515 rotation[i] = ProtocolCraft::ReadData<float>(iter, length);
516 }
517 value = rotation;
518 break;
519 }
520 case EntityMetadataTypes::BlockPosition:
521 {
523 position.Read(iter, length);
524 value = Position(position);
525 break;
526 }
527 case EntityMetadataTypes::OptionalBlockPosition:
528 if (ProtocolCraft::ReadData<bool>(iter, length))
529 {
531 position.Read(iter, length);
532 value = std::optional<Position>(position);
533 }
534 else
535 {
536 value = std::optional<Position>();
537 }
538 break;
539 case EntityMetadataTypes::DirectionType:
540 value = static_cast<Direction>(static_cast<int>(ProtocolCraft::ReadData<ProtocolCraft::VarInt>(iter, length)));
541 break;
542#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
543 case EntityMetadataTypes::OptionalLivingEntityReference:
544#else
545 case EntityMetadataTypes::OptionalUUID:
546#endif
547 if (ProtocolCraft::ReadData<bool>(iter, length))
548 {
549 value = std::optional<ProtocolCraft::UUID>(ProtocolCraft::ReadData<ProtocolCraft::UUID>(iter, length));
550 }
551 else
552 {
553 value = std::optional<ProtocolCraft::UUID>();
554 }
555 break;
556 case EntityMetadataTypes::BlockstateType:
557 value = static_cast<int>(ProtocolCraft::ReadData<ProtocolCraft::VarInt>(iter, length));
558 break;
559#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
560 case EntityMetadataTypes::OptionalBlockstate:
561 if (const int n = ProtocolCraft::ReadData<ProtocolCraft::VarInt>(iter, length))
562 {
563 value = std::optional<int>(n);
564 }
565 else
566 {
567 value = std::optional<int>();
568 }
569 break;
570#endif
571#if PROTOCOL_VERSION < 773 /* < 1.21.9 */
572 case EntityMetadataTypes::NBT:
573 {
575 unnamed_value.Read(iter, length);
576 value = ProtocolCraft::NBT::Value(unnamed_value);
577 break;
578 }
579#endif
580#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
581 case EntityMetadataTypes::Particle:
582 {
584 particle.Read(iter, length);
585 value = particle;
586 break;
587 }
588#endif
589#if PROTOCOL_VERSION > 765 /* > 1.20.4 */
590 case EntityMetadataTypes::Particles:
591 value = ProtocolCraft::ReadData<std::vector<ProtocolCraft::Particle>>(iter, length);
592 break;
593#endif
594#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
595 case EntityMetadataTypes::VillagerDataType:
596 value = VillagerData{
597 ProtocolCraft::ReadData<ProtocolCraft::VarInt>(iter, length), // villager_type
598 ProtocolCraft::ReadData<ProtocolCraft::VarInt>(iter, length), // villager_profession
599 ProtocolCraft::ReadData<ProtocolCraft::VarInt>(iter, length) // level
600 };
601 break;
602 case EntityMetadataTypes::OptionalUint:
603 {
604 const int val = ProtocolCraft::ReadData<ProtocolCraft::VarInt>(iter, length);
605 value = val > 0 ? std::optional<int>(val - 1) : std::optional<int>();
606 break;
607 }
608 case EntityMetadataTypes::PoseType:
609 value = static_cast<Pose>(static_cast<int>(ProtocolCraft::ReadData<ProtocolCraft::VarInt>(iter, length)));
610 break;
611#endif
612#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
613 case EntityMetadataTypes::CatVariant:
614 value = static_cast<int>(ProtocolCraft::ReadData<ProtocolCraft::VarInt>(iter, length));
615 break;
616#endif
617#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
618 case EntityMetadataTypes::CowVariant:
619 value = static_cast<int>(ProtocolCraft::ReadData<ProtocolCraft::VarInt>(iter, length));
620 break;
621#endif
622#if PROTOCOL_VERSION > 765 /* > 1.20.4 */
623 case EntityMetadataTypes::WolfVariant:
624 value = static_cast<int>(ProtocolCraft::ReadData<ProtocolCraft::VarInt>(iter, length));
625 break;
626#endif
627#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
628 case EntityMetadataTypes::WolfSoundVariant:
629 value = static_cast<int>(ProtocolCraft::ReadData<ProtocolCraft::VarInt>(iter, length));
630 break;
631#endif
632#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
633 case EntityMetadataTypes::FrogVariant:
634 value = static_cast<int>(ProtocolCraft::ReadData<ProtocolCraft::VarInt>(iter, length));
635 break;
636#endif
637#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
638 case EntityMetadataTypes::PigVariant:
639 value = static_cast<int>(ProtocolCraft::ReadData<ProtocolCraft::VarInt>(iter, length));
640 break;
641 case EntityMetadataTypes::ChickenVariant:
642 value = static_cast<int>(ProtocolCraft::ReadData<ProtocolCraft::VarInt>(iter, length));
643 break;
644#endif
645#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
646 case EntityMetadataTypes::OptionalGlobalPos:
647 if (ProtocolCraft::ReadData<bool>(iter, length))
648 {
650 dimension.Read(iter, length);
652 pos.Read(iter, length);
653
654 value = std::optional<GlobalPos>({
655 dimension,
656 pos
657 });
658 }
659 else
660 {
661 value = std::optional<GlobalPos>();
662 }
663 break;
664 case EntityMetadataTypes::PaintingVariant:
665 value = static_cast<int>(ProtocolCraft::ReadData<ProtocolCraft::VarInt>(iter, length));
666 break;
667#endif
668#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
669 case EntityMetadataTypes::SnifferState:
670 value = static_cast<int>(ProtocolCraft::ReadData<ProtocolCraft::VarInt>(iter, length));
671 break;
672#if PROTOCOL_VERSION > 765 /* > 1.20.4 */
673 case EntityMetadataTypes::ArmadilloState:
674 value = static_cast<int>(ProtocolCraft::ReadData<ProtocolCraft::VarInt>(iter, length));
675 break;
676#endif
677#if PROTOCOL_VERSION > 772 /* > 1.21.8 */
678 case EntityMetadataTypes::CopperGolemState:
679 value = static_cast<int>(ProtocolCraft::ReadData<ProtocolCraft::VarInt>(iter, length));
680 break;
681 case EntityMetadataTypes::WeatheringCopperState:
682 value = static_cast<int>(ProtocolCraft::ReadData<ProtocolCraft::VarInt>(iter, length));
683 break;
684#endif
685 case EntityMetadataTypes::Vec3:
686 {
687 const float x = ProtocolCraft::ReadData<float>(iter, length);
688 const float y = ProtocolCraft::ReadData<float>(iter, length);
689 const float z = ProtocolCraft::ReadData<float>(iter, length);
690 value = Vector3<float>(x, y, z);
691 }
692 break;
693 case EntityMetadataTypes::Quaternion:
694 {
695 const float x = ProtocolCraft::ReadData<float>(iter, length);
696 const float y = ProtocolCraft::ReadData<float>(iter, length);
697 const float z = ProtocolCraft::ReadData<float>(iter, length);
698 const float w = ProtocolCraft::ReadData<float>(iter, length);
699 value = std::array<float, 4>{x, y, z, w};
700 }
701 break;
702#endif
703#if PROTOCOL_VERSION > 772 /* > 1.21.8 */
704 case EntityMetadataTypes::ResolvableProfile:
705 value = ProtocolCraft::ReadData<ProtocolCraft::Components::DataComponentTypeResolvableProfile>(iter, length);
706 break;
707#endif
708 default:
709 LOG_ERROR("Unknown type in entity metadata : " << type << ".Stopping current metadata parsing.");
710 return;
711 }
712 SetMetadataValue(index, value);
713 }
714 }
715
716 void Entity::SetMetadataValue(const int index, const std::any& value)
717 {
718 assert(index >= 0 && index < metadata_count);
719 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
720 const std::string& metadata_name = metadata_names[index];
721 metadata[metadata_name] = value;
722#if USE_GUI && PROTOCOL_VERSION > 404 /* > 1.13.2 */
723 if (metadata_name == "data_pose")
724 {
726 }
727#endif
728 }
729
730
732 {
733 std::shared_lock<std::shared_mutex> lock(entity_mutex);
735 }
736
738 {
739 std::shared_lock<std::shared_mutex> lock(entity_mutex);
740 return GetDataSharedFlagsIdImpl(id);
741 }
742
744 {
745 std::shared_lock<std::shared_mutex> lock(entity_mutex);
746 return std::any_cast<int>(metadata.at("data_air_supply_id"));
747 }
748
749#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
750 std::optional<ProtocolCraft::Chat> Entity::GetDataCustomName() const
751 {
752 std::shared_lock<std::shared_mutex> lock(entity_mutex);
753 return std::any_cast<std::optional<ProtocolCraft::Chat>>(metadata.at("data_custom_name"));
754 }
755#else
756 std::string Entity::GetDataCustomName() const
757 {
758 std::shared_lock<std::shared_mutex> lock(entity_mutex);
759 return std::any_cast<std::string>(metadata.at("data_custom_name"));
760 }
761#endif
762
764 {
765 std::shared_lock<std::shared_mutex> lock(entity_mutex);
766 return std::any_cast<bool>(metadata.at("data_custom_name_visible"));
767 }
768
770 {
771 std::shared_lock<std::shared_mutex> lock(entity_mutex);
772 return std::any_cast<bool>(metadata.at("data_silent"));
773 }
774
776 {
777 std::shared_lock<std::shared_mutex> lock(entity_mutex);
778 return std::any_cast<bool>(metadata.at("data_no_gravity"));
779 }
780
781#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
783 {
784 std::shared_lock<std::shared_mutex> lock(entity_mutex);
785 return GetDataPoseImpl();
786 }
787#endif
788
789#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
791 {
792 std::shared_lock<std::shared_mutex> lock(entity_mutex);
793 return std::any_cast<int>(metadata.at("data_ticks_frozen"));
794 }
795#endif
796
797
798 void Entity::SetDataSharedFlagsId(const char data_shared_flags_id)
799 {
800 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
801 SetDataSharedFlagsIdImpl(data_shared_flags_id);
802 }
803
805 {
806 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
808 }
809
810 void Entity::SetDataAirSupplyId(const int data_air_supply_id)
811 {
812 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
813 metadata["data_air_supply_id"] = data_air_supply_id;
814 }
815
816#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
817 void Entity::SetDataCustomName(const std::optional<ProtocolCraft::Chat>& data_custom_name)
818 {
819 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
820 metadata["data_custom_name"] = data_custom_name;
821 }
822#else
823 void Entity::SetDataCustomName(const std::string& data_custom_name)
824 {
825 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
826 metadata["data_custom_name"] = data_custom_name;
827 }
828#endif
829
830 void Entity::SetDataCustomNameVisible(const bool data_custom_name_visible)
831 {
832 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
833 metadata["data_custom_name_visible"] = data_custom_name_visible;
834 }
835
836 void Entity::SetDataSilent(const bool data_silent)
837 {
838 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
839 metadata["data_silent"] = data_silent;
840 }
841
842 void Entity::SetDataNoGravity(const bool data_no_gravity)
843 {
844 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
845 metadata["data_no_gravity"] = data_no_gravity;
846 }
847
848#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
849 void Entity::SetDataPose(const Pose data_pose)
850 {
851 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
852 SetDataPoseImpl(data_pose);
853 }
854#endif
855
856#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
857 void Entity::SetDataTicksFrozen(const int data_ticks_frozen)
858 {
859 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
860 metadata["data_ticks_frozen"] = data_ticks_frozen;
861 }
862#endif
863
864
866 {
867 std::shared_lock<std::shared_mutex> lock(entity_mutex);
868 return entity_id;
869 }
870
872 {
873 std::shared_lock<std::shared_mutex> lock(entity_mutex);
874 return uuid;
875 }
876
878 {
879 std::shared_lock<std::shared_mutex> lock(entity_mutex);
880 return position;
881 }
882
883 double Entity::GetX() const
884 {
885 std::shared_lock<std::shared_mutex> lock(entity_mutex);
886 return position.x;
887 }
888
889 double Entity::GetY() const
890 {
891 std::shared_lock<std::shared_mutex> lock(entity_mutex);
892 return position.y;
893 }
894
895 double Entity::GetZ() const
896 {
897 std::shared_lock<std::shared_mutex> lock(entity_mutex);
898 return position.z;
899 }
900
901 float Entity::GetYaw() const
902 {
903 std::shared_lock<std::shared_mutex> lock(entity_mutex);
904 return yaw;
905 }
906
907 float Entity::GetPitch() const
908 {
909 std::shared_lock<std::shared_mutex> lock(entity_mutex);
910 return pitch;
911 }
912
914 {
915 std::shared_lock<std::shared_mutex> lock(entity_mutex);
916 return speed;
917 }
918
919 double Entity::GetSpeedX() const
920 {
921 std::shared_lock<std::shared_mutex> lock(entity_mutex);
922 return speed.x;
923 }
924
925 double Entity::GetSpeedY() const
926 {
927 std::shared_lock<std::shared_mutex> lock(entity_mutex);
928 return speed.y;
929 }
930
931 double Entity::GetSpeedZ() const
932 {
933 std::shared_lock<std::shared_mutex> lock(entity_mutex);
934 return speed.z;
935 }
936
938 {
939 std::shared_lock<std::shared_mutex> lock(entity_mutex);
940 return on_ground;
941 }
942
943 std::map<EquipmentSlot, ProtocolCraft::Slot> Entity::GetEquipments() const
944 {
945 std::shared_lock<std::shared_mutex> lock(entity_mutex);
946 return equipments;
947 }
948
950 {
951 std::shared_lock<std::shared_mutex> lock(entity_mutex);
952 return equipments.at(slot);
953 }
954
955 std::vector<EntityEffect> Entity::GetEffects() const
956 {
957 std::shared_lock<std::shared_mutex> lock(entity_mutex);
958 return effects;
959 }
960
961#if USE_GUI
962 std::vector<Renderer::Face> Entity::GetFaces(const bool reset_uptodate_status)
963 {
964 if (faces.size() == 0)
965 {
967 }
968 std::shared_lock<std::shared_mutex> lock(entity_mutex);
970 {
971 for (size_t i = 0; i < faces.size(); ++i)
972 {
973 faces[i].UpdateMatrix(face_descriptors[i].transformations, face_descriptors[i].orientation);
974 }
975 }
976 if (reset_uptodate_status)
977 {
979 }
980 return faces;
981 }
982
984 {
985 std::shared_lock<std::shared_mutex> lock(entity_mutex);
987 }
988#endif
989
990
991 void Entity::SetEntityID(const int entity_id_)
992 {
993 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
994 entity_id = entity_id_;
995 }
996
998 {
999 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
1000 uuid = uuid_;
1001 }
1002
1004 {
1005 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
1006#if USE_GUI
1007 if (position_ != position)
1008 {
1010 for (size_t i = 0; i < faces.size(); ++i)
1011 {
1012 std::shared_ptr<Renderer::Translation> f = std::static_pointer_cast<Renderer::Translation>(face_descriptors[i].transformations.translations.back());
1013 f->x = static_cast<float>(position_.x);
1014 f->y = static_cast<float>(position_.y);
1015 f->z = static_cast<float>(position_.z);
1016 }
1017 }
1018#endif
1019 position = position_;
1020 }
1021
1022 void Entity::SetX(const double x_)
1023 {
1024 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
1025#if USE_GUI
1026 if (x_ != position.x)
1027 {
1029 for (size_t i = 0; i < faces.size(); ++i)
1030 {
1031 std::static_pointer_cast<Renderer::Translation>(face_descriptors[i].transformations.translations.back())->x = static_cast<float>(x_);
1032 }
1033 }
1034#endif
1035 position.x = x_;
1036 }
1037
1038 void Entity::SetY(const double y_)
1039 {
1040 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
1041#if USE_GUI
1042 if (y_ != position.y)
1043 {
1045 for (size_t i = 0; i < faces.size(); ++i)
1046 {
1047 std::static_pointer_cast<Renderer::Translation>(face_descriptors[i].transformations.translations.back())->y = static_cast<float>(y_);
1048 }
1049 }
1050#endif
1051 position.y = y_;
1052 }
1053
1054 void Entity::SetZ(const double z_)
1055 {
1056 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
1057#if USE_GUI
1058 if (z_ != position.z)
1059 {
1061 for (size_t i = 0; i < faces.size(); ++i)
1062 {
1063 std::static_pointer_cast<Renderer::Translation>(face_descriptors[i].transformations.translations.back())->z = static_cast<float>(z_);
1064 }
1065 }
1066#endif
1067 position.z = z_;
1068 }
1069
1070 void Entity::SetYaw(const float yaw_)
1071 {
1072 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
1073#if USE_GUI
1074 if (yaw_ != yaw)
1075 {
1077 for (size_t i = 0; i < faces.size(); ++i)
1078 {
1079 std::static_pointer_cast<Renderer::Rotation>(face_descriptors[i].transformations.rotations.front())->deg_angle = yaw_;
1080 }
1081 }
1082#endif
1083 yaw = yaw_;
1084 }
1085
1086 void Entity::SetPitch(const float pitch_)
1087 {
1088 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
1089#if USE_GUI
1090 if (pitch_ != pitch)
1091 {
1093 for (size_t i = 0; i < faces.size(); ++i)
1094 {
1095 std::static_pointer_cast<Renderer::Rotation>(face_descriptors[i].transformations.rotations.back())->deg_angle = pitch_;
1096 }
1097 }
1098#endif
1099 pitch = pitch_;
1100 }
1101
1103 {
1104 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
1105 speed = speed_;
1106 }
1107
1108 void Entity::SetSpeedX(const double speed_x_)
1109 {
1110 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
1111 speed.x = speed_x_;
1112 }
1113
1114 void Entity::SetSpeedY(const double speed_y_)
1115 {
1116 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
1117 speed.y = speed_y_;
1118 }
1119
1120 void Entity::SetSpeedZ(const double speed_z_)
1121 {
1122 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
1123 speed.z = speed_z_;
1124 }
1125
1126 void Entity::SetOnGround(const bool on_ground_)
1127 {
1128 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
1129 on_ground = on_ground_;
1130 }
1131
1133 {
1134 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
1135 equipments.at(slot) = item;
1136 }
1137
1138 void Entity::SetEffects(const std::vector<EntityEffect>& effects_)
1139 {
1140 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
1141 effects = effects_;
1142 }
1143
1145 {
1146 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
1147 for (auto it = effects.begin(); it != effects.end();)
1148 {
1149 if (it->type == type)
1150 {
1151 it = effects.erase(it);
1152 }
1153 else
1154 {
1155 ++it;
1156 }
1157 }
1158 }
1159
1161 {
1162 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
1163 // First, remove any instance of this type of effect on the entity
1164 for (auto it = effects.begin(); it != effects.end();)
1165 {
1166 if (it->type == effect.type)
1167 {
1168 it = effects.erase(it);
1169 }
1170 else
1171 {
1172 ++it;
1173 }
1174 }
1175
1176 // Then add the new one
1177 effects.push_back(effect);
1178 }
1179
1180#if USE_GUI
1181 void Entity::SetAreRenderedFacesUpToDate(const bool should_be_updated_)
1182 {
1183 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
1184 are_rendered_faces_up_to_date = should_be_updated_;
1185 }
1186#endif
1187
1188
1190 {
1192
1193 {
1194 std::shared_lock<std::shared_mutex> lock(entity_mutex);
1195 output["id"] = entity_id;
1196 output["position"] = position.Serialize();
1197 output["yaw"] = yaw;
1198 output["pitch"] = pitch;
1199 output["speed"] = speed.Serialize();
1200 output["on_ground"] = on_ground;
1201 output["equipment"] = ProtocolCraft::Json::Value();
1202 for (auto& p : equipments)
1203 {
1204 output["equipment"][std::to_string(static_cast<int>(p.first))] = p.second.Serialize();
1205 }
1206 }
1207
1208 output["metadata"] = ProtocolCraft::Json::Value();
1209
1210 output["metadata"]["data_shared_flags_id"] = GetDataSharedFlagsId();
1211 output["metadata"]["data_air_supply_id"] = GetDataAirSupplyId();
1212#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
1213 output["metadata"]["data_custom_name"] = GetDataCustomName() ? GetDataCustomName().value().Serialize() : ProtocolCraft::Json::Value();
1214#else
1215 output["metadata"]["data_custom_name"] = GetDataCustomName();
1216#endif
1217 output["metadata"]["data_custom_name_visible"] = GetDataCustomNameVisible();
1218 output["metadata"]["data_silent"] = GetDataSilent();
1219 output["metadata"]["data_no_gravity"] = GetDataNoGravity();
1220#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
1221 output["metadata"]["data_pose"] = static_cast<int>(GetDataPose());
1222#endif
1223#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
1224 output["metadata"]["data_ticks_frozen"] = GetDataTicksFrozen();
1225#endif
1226
1227 return output;
1228 }
1229
1231 {
1232 return false;
1233 }
1234
1236 {
1237 return false;
1238 }
1239
1241 {
1242 return false;
1243 }
1244
1246 {
1247 return false;
1248 }
1249
1250 bool Entity::IsAnimal() const
1251 {
1252 return false;
1253 }
1254
1256 {
1257 return false;
1258 }
1259
1261 {
1262 return false;
1263 }
1264
1265#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
1267 {
1268 return false;
1269 }
1270#endif
1271
1272#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
1274 {
1275 return false;
1276 }
1277#endif
1278
1280 {
1281 return false;
1282 }
1283
1285 {
1286 return false;
1287 }
1288
1290 {
1291 return false;
1292 }
1293
1295 {
1296 return false;
1297 }
1298
1300 {
1301 return false;
1302 }
1303
1304 bool Entity::IsMob() const
1305 {
1306 return false;
1307 }
1308
1310 {
1311 return false;
1312 }
1313
1314#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
1316 {
1317 return false;
1318 }
1319#endif
1320
1321#if PROTOCOL_VERSION < 771 /* < 1.21.6 */
1322 bool Entity::IsFlyingMob() const
1323 {
1324 return false;
1325 }
1326#endif
1327
1329 {
1330 return false;
1331 }
1332
1334 {
1335 return false;
1336 }
1337
1339 {
1340 return false;
1341 }
1342
1344 {
1345 return false;
1346 }
1347
1349 {
1350 return false;
1351 }
1352
1353#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
1355 {
1356 return false;
1357 }
1358#endif
1359
1361 {
1362 return false;
1363 }
1364
1366 {
1367 return false;
1368 }
1369
1370#if PROTOCOL_VERSION > 736 /* > 1.16.1 */
1372 {
1373 return false;
1374 }
1375#endif
1376
1378 {
1379 return false;
1380 }
1381
1382#if PROTOCOL_VERSION > 769 /* > 1.21.4 */
1384 {
1385 return false;
1386 }
1387#endif
1388
1390 {
1391 return false;
1392 }
1393
1394#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
1395 bool Entity::IsRaider() const
1396 {
1397 return false;
1398 }
1399#endif
1400
1402 {
1403 return false;
1404 }
1405
1407 {
1408 return false;
1409 }
1410
1411#if PROTOCOL_VERSION > 477 /* > 1.14 */
1413 {
1414 return false;
1415 }
1416#endif
1417
1419 {
1420 return false;
1421 }
1422
1424 {
1425 return false;
1426 }
1427
1428#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
1430 {
1431 return false;
1432 }
1433#endif
1434
1436 {
1437 return false;
1438 }
1439
1440#if PROTOCOL_VERSION > 765 /* > 1.20.4 */
1442 {
1443 return false;
1444 }
1445#endif
1446
1447#if PROTOCOL_VERSION > 766 /* > 1.20.6 */
1449 {
1450 return false;
1451 }
1452#endif
1453
1454#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
1456 {
1457 return false;
1458 }
1459
1461 {
1462 return false;
1463 }
1464
1466 {
1467 return false;
1468 }
1469
1470 bool Entity::IsBoat() const
1471 {
1472 return false;
1473 }
1474
1476 {
1477 return false;
1478 }
1479
1481 {
1482 return false;
1483 }
1484
1485 bool Entity::IsRaft() const
1486 {
1487 return false;
1488 }
1489#endif
1490#if PROTOCOL_VERSION > 772 /* > 1.21.8 */
1491 bool Entity::IsAvatar() const
1492 {
1493 return false;
1494 }
1495#endif
1496
1497
1498 std::shared_ptr<Entity> Entity::CreateEntity(const EntityType type)
1499 {
1500 switch (type)
1501 {
1502 case EntityType::None:
1503 return nullptr;
1504#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
1505 case EntityType::Allay:
1506 return std::make_shared<AllayEntity>();
1507#endif
1509 return std::make_shared<AreaEffectCloudEntity>();
1510#if PROTOCOL_VERSION > 765 /* > 1.20.4 */
1512 return std::make_shared<ArmadilloEntity>();
1513#endif
1515 return std::make_shared<ArmorStandEntity>();
1516 case EntityType::Arrow:
1517 return std::make_shared<ArrowEntity>();
1518#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
1520 return std::make_shared<AxolotlEntity>();
1521#endif
1522 case EntityType::Bat:
1523 return std::make_shared<BatEntity>();
1524#if PROTOCOL_VERSION > 498 /* > 1.14.4 */
1525 case EntityType::Bee:
1526 return std::make_shared<BeeEntity>();
1527#endif
1528 case EntityType::Blaze:
1529 return std::make_shared<BlazeEntity>();
1530#if PROTOCOL_VERSION < 768 /* < 1.21.2 */
1531 case EntityType::Boat:
1532 return std::make_shared<BoatEntity>();
1533#else
1543 return std::make_shared<BoatEntity>(type);
1544#endif
1545#if PROTOCOL_VERSION > 765 /* > 1.20.4 */
1546 case EntityType::Bogged:
1547 return std::make_shared<BoggedEntity>();
1548#endif
1549#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
1550 case EntityType::Breeze:
1551 return std::make_shared<BreezeEntity>();
1552#endif
1553#if PROTOCOL_VERSION > 765 /* > 1.20.4 */
1555 return std::make_shared<BreezeWindChargeEntity>();
1556#endif
1557#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
1558#if PROTOCOL_VERSION < 768 /* < 1.21.2 */
1559 case EntityType::ChestBoat:
1560 return std::make_shared<ChestBoatEntity>();
1561#else
1571 return std::make_shared<ChestBoatEntity>(type);
1572#endif
1573#endif
1574#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
1576 return std::make_shared<ChestRaftEntity>(type);
1577#endif
1578#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
1579 case EntityType::Cat:
1580 return std::make_shared<CatEntity>();
1581#endif
1582#if PROTOCOL_VERSION > 760 /* > 1.19.2 */
1583 case EntityType::Camel:
1584 return std::make_shared<CamelEntity>();
1585#endif
1587 return std::make_shared<CaveSpiderEntity>();
1589 return std::make_shared<ChickenEntity>();
1590#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
1591 case EntityType::Cod:
1592 return std::make_shared<CodEntity>();
1593#endif
1594#if PROTOCOL_VERSION > 772 /* > 1.21.8 */
1596 return std::make_shared<CopperGolemEntity>();
1597#endif
1598 case EntityType::Cow:
1599 return std::make_shared<CowEntity>();
1600#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
1602 return std::make_shared<CreakingEntity>();
1603#endif
1604#if PROTOCOL_VERSION > 767 /* > 1.21.1 */ && PROTOCOL_VERSION < 769 /* < 1.21.4 */
1605 case EntityType::CreakingTransient:
1606 return std::make_shared<CreakingTransientEntity>();
1607#endif
1609 return std::make_shared<CreeperEntity>();
1610#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
1612 return std::make_shared<DisplayBlockDisplayEntity>();
1614 return std::make_shared<DisplayItemDisplayEntity>();
1616 return std::make_shared<DisplayTextDisplayEntity>();
1617#endif
1618#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
1620 return std::make_shared<DolphinEntity>();
1621#endif
1622 case EntityType::Donkey:
1623 return std::make_shared<DonkeyEntity>();
1625 return std::make_shared<DragonFireballEntity>();
1626#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
1628 return std::make_shared<DrownedEntity>();
1629#endif
1631 return std::make_shared<ElderGuardianEntity>();
1633 return std::make_shared<EndCrystalEntity>();
1635 return std::make_shared<EnderDragonEntity>();
1637 return std::make_shared<EnderManEntity>();
1639 return std::make_shared<EndermiteEntity>();
1640 case EntityType::Evoker:
1641 return std::make_shared<EvokerEntity>();
1643 return std::make_shared<EvokerFangsEntity>();
1645 return std::make_shared<ExperienceOrbEntity>();
1647 return std::make_shared<EyeOfEnderEntity>();
1649 return std::make_shared<FallingBlockEntity>();
1651 return std::make_shared<FireworkRocketEntity>();
1652#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
1653 case EntityType::Fox:
1654 return std::make_shared<FoxEntity>();
1655#endif
1656#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
1657 case EntityType::Frog:
1658 return std::make_shared<FrogEntity>();
1659#endif
1660 case EntityType::Ghast:
1661 return std::make_shared<GhastEntity>();
1662#if PROTOCOL_VERSION > 770 /* > 1.21.5 */
1664 return std::make_shared<HappyGhastEntity>();
1665#endif
1666 case EntityType::Giant:
1667 return std::make_shared<GiantEntity>();
1668#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
1670 return std::make_shared<GlowItemFrameEntity>();
1672 return std::make_shared<GlowSquidEntity>();
1673 case EntityType::Goat:
1674 return std::make_shared<GoatEntity>();
1675#endif
1677 return std::make_shared<GuardianEntity>();
1678#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
1679 case EntityType::Hoglin:
1680 return std::make_shared<HoglinEntity>();
1681#endif
1682 case EntityType::Horse:
1683 return std::make_shared<HorseEntity>();
1684 case EntityType::Husk:
1685 return std::make_shared<HuskEntity>();
1687 return std::make_shared<IllusionerEntity>();
1688#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
1690 return std::make_shared<InteractionEntity>();
1691#endif
1693 return std::make_shared<IronGolemEntity>();
1695 return std::make_shared<ItemEntity>();
1697 return std::make_shared<ItemFrameEntity>();
1698#if PROTOCOL_VERSION > 765 /* > 1.20.4 */
1700 return std::make_shared<OminousItemSpawnerEntity>();
1701#endif
1703 return std::make_shared<LargeFireballEntity>();
1705 return std::make_shared<LeashFenceKnotEntity>();
1706#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
1708 return std::make_shared<LightningBoltEntity>();
1709#endif
1710 case EntityType::Llama:
1711 return std::make_shared<LlamaEntity>();
1713 return std::make_shared<LlamaSpitEntity>();
1715 return std::make_shared<MagmaCubeEntity>();
1716#if PROTOCOL_VERSION > 772 /* > 1.21.8 */
1718 return std::make_shared<MannequinEntity>();
1719#endif
1720#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
1721 case EntityType::Marker:
1722 return std::make_shared<MarkerEntity>();
1723#endif
1725 return std::make_shared<MinecartEntity>();
1727 return std::make_shared<MinecartChestEntity>();
1729 return std::make_shared<MinecartCommandBlockEntity>();
1731 return std::make_shared<MinecartFurnaceEntity>();
1733 return std::make_shared<MinecartHopperEntity>();
1735 return std::make_shared<MinecartSpawnerEntity>();
1737 return std::make_shared<MinecartTNTEntity>();
1738 case EntityType::Mule:
1739 return std::make_shared<MuleEntity>();
1741 return std::make_shared<MushroomCowEntity>();
1742 case EntityType::Ocelot:
1743 return std::make_shared<OcelotEntity>();
1745 return std::make_shared<PaintingEntity>();
1746#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
1747 case EntityType::Panda:
1748 return std::make_shared<PandaEntity>();
1749#endif
1750 case EntityType::Parrot:
1751 return std::make_shared<ParrotEntity>();
1752#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
1754 return std::make_shared<PhantomEntity>();
1755#endif
1756 case EntityType::Pig:
1757 return std::make_shared<PigEntity>();
1758#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
1759 case EntityType::Piglin:
1760 return std::make_shared<PiglinEntity>();
1761#endif
1762#if PROTOCOL_VERSION > 736 /* > 1.16.1 */
1764 return std::make_shared<PiglinBruteEntity>();
1765#endif
1766#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
1768 return std::make_shared<PillagerEntity>();
1769#endif
1771 return std::make_shared<PolarBearEntity>();
1773 return std::make_shared<PrimedTntEntity>();
1774#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
1776 return std::make_shared<PufferfishEntity>();
1777#endif
1778 case EntityType::Rabbit:
1779 return std::make_shared<RabbitEntity>();
1780#if PROTOCOL_VERSION > 767 /* > 1.21.1 */
1781 case EntityType::Raft:
1782 return std::make_shared<RaftEntity>(type);
1783#endif
1784#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
1786 return std::make_shared<RavagerEntity>();
1787#endif
1788#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
1789 case EntityType::Salmon:
1790 return std::make_shared<SalmonEntity>();
1791#endif
1792 case EntityType::Sheep:
1793 return std::make_shared<SheepEntity>();
1795 return std::make_shared<ShulkerEntity>();
1797 return std::make_shared<ShulkerBulletEntity>();
1799 return std::make_shared<SilverfishEntity>();
1801 return std::make_shared<SkeletonEntity>();
1803 return std::make_shared<SkeletonHorseEntity>();
1804 case EntityType::Slime:
1805 return std::make_shared<SlimeEntity>();
1807 return std::make_shared<SmallFireballEntity>();
1808#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
1810 return std::make_shared<SnifferEntity>();
1811#endif
1813 return std::make_shared<SnowGolemEntity>();
1815 return std::make_shared<SnowballEntity>();
1817 return std::make_shared<SpectralArrowEntity>();
1818 case EntityType::Spider:
1819 return std::make_shared<SpiderEntity>();
1820 case EntityType::Squid:
1821 return std::make_shared<SquidEntity>();
1822 case EntityType::Stray:
1823 return std::make_shared<StrayEntity>();
1824#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
1826 return std::make_shared<StriderEntity>();
1827#endif
1828#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
1830 return std::make_shared<TadpoleEntity>();
1831#endif
1833 return std::make_shared<ThrownEggEntity>();
1835 return std::make_shared<ThrownEnderpearlEntity>();
1837 return std::make_shared<ThrownExperienceBottleEntity>();
1838#if PROTOCOL_VERSION < 770 /* < 1.21.5 */
1839 case EntityType::ThrownPotion:
1840 return std::make_shared<ThrownPotionEntity>();
1841#else
1843 return std::make_shared<ThrownSplashPotionEntity>();
1845 return std::make_shared<ThrownLingeringPotionEntity>();
1846#endif
1847#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
1849 return std::make_shared<ThrownTridentEntity>();
1850#endif
1851#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
1853 return std::make_shared<TraderLlamaEntity>();
1854#endif
1855#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
1857 return std::make_shared<TropicalFishEntity>();
1858#endif
1859#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
1860 case EntityType::Turtle:
1861 return std::make_shared<TurtleEntity>();
1862#endif
1863 case EntityType::Vex:
1864 return std::make_shared<VexEntity>();
1866 return std::make_shared<VillagerEntity>();
1868 return std::make_shared<VindicatorEntity>();
1869#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
1871 return std::make_shared<WanderingTraderEntity>();
1872#endif
1873#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
1874 case EntityType::Warden:
1875 return std::make_shared<WardenEntity>();
1876#endif
1877#if PROTOCOL_VERSION > 764 /* > 1.20.2 */
1879 return std::make_shared<WindChargeEntity>();
1880#endif
1881 case EntityType::Witch:
1882 return std::make_shared<WitchEntity>();
1884 return std::make_shared<WitherBossEntity>();
1886 return std::make_shared<WitherSkeletonEntity>();
1888 return std::make_shared<WitherSkullEntity>();
1889 case EntityType::Wolf:
1890 return std::make_shared<WolfEntity>();
1891#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
1892 case EntityType::Zoglin:
1893 return std::make_shared<ZoglinEntity>();
1894#endif
1895 case EntityType::Zombie:
1896 return std::make_shared<ZombieEntity>();
1898 return std::make_shared<ZombieHorseEntity>();
1900 return std::make_shared<ZombieVillagerEntity>();
1901#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
1903 return std::make_shared<ZombifiedPiglinEntity>();
1904#else
1905 case EntityType::PigZombie:
1906 return std::make_shared<PigZombieEntity>();
1907#endif
1908 case EntityType::Player:
1909 return std::make_shared<PlayerEntity>();
1910#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
1912 return std::make_shared<FishingHookEntity>();
1913#endif
1914 default:
1915 return nullptr;
1916 }
1917 }
1918
1919#if PROTOCOL_VERSION < 458 /* < 1.14 */
1920 std::shared_ptr<Entity> Entity::CreateObjectEntity(const ObjectEntityType type)
1921 {
1922 switch (type)
1923 {
1924 case ObjectEntityType::None:
1925 return nullptr;
1926 case ObjectEntityType::Boat:
1927 return std::make_shared<BoatEntity>();
1928 case ObjectEntityType::ItemEntity:
1929 return std::make_shared<ItemEntity>();
1930 case ObjectEntityType::AreaEffectCloud:
1931 return std::make_shared<AreaEffectCloudEntity>();
1932 case ObjectEntityType::PrimedTnt:
1933 return std::make_shared<PrimedTntEntity>();
1934 case ObjectEntityType::EndCrystal:
1935 return std::make_shared<EndCrystalEntity>();
1936 case ObjectEntityType::Arrow:
1937 return std::make_shared<ArrowEntity>();
1938 case ObjectEntityType::Snowball:
1939 return std::make_shared<SnowballEntity>();
1940 case ObjectEntityType::ThrownEgg:
1941 return std::make_shared<ThrownEggEntity>();
1942 case ObjectEntityType::LargeFireball:
1943 return std::make_shared<LargeFireballEntity>();
1944 case ObjectEntityType::SmallFireball:
1945 return std::make_shared<SmallFireballEntity>();
1946 case ObjectEntityType::ThrownEnderpearl:
1947 return std::make_shared<ThrownEnderpearlEntity>();
1948 case ObjectEntityType::WitherSkull:
1949 return std::make_shared<WitherSkullEntity>();
1950 case ObjectEntityType::ShulkerBullet:
1951 return std::make_shared<ShulkerBulletEntity>();
1952 case ObjectEntityType::LlamaSpit:
1953 return std::make_shared<LlamaSpitEntity>();
1954 case ObjectEntityType::FallingBlockEntity:
1955 return std::make_shared<FallingBlockEntity>();
1956 case ObjectEntityType::ItemFrame:
1957 return std::make_shared<ItemFrameEntity>();
1958 case ObjectEntityType::EyeOfEnder:
1959 return std::make_shared<EyeOfEnderEntity>();
1960 case ObjectEntityType::ThrownPotion:
1961 return std::make_shared<ThrownPotionEntity>();
1962 case ObjectEntityType::ThrownExperienceBottle:
1963 return std::make_shared<ThrownExperienceBottleEntity>();
1964 case ObjectEntityType::FireworkRocketEntity:
1965 return std::make_shared<FireworkRocketEntity>();
1966 case ObjectEntityType::LeashFenceKnotEntity:
1967 return std::make_shared<LeashFenceKnotEntity>();
1968 case ObjectEntityType::ArmorStand:
1969 return std::make_shared<ArmorStandEntity>();
1970 case ObjectEntityType::EvokerFangs:
1971 return std::make_shared<EvokerFangsEntity>();
1972 case ObjectEntityType::FishingHook:
1973 return std::make_shared<FishingHookEntity>();
1974 case ObjectEntityType::SpectralArrow:
1975 return std::make_shared<SpectralArrowEntity>();
1976 case ObjectEntityType::DragonFireball:
1977 return std::make_shared<DragonFireballEntity>();
1978#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
1979 case ObjectEntityType::ThrownTrident:
1980 return std::make_shared<ThrownTridentEntity>();
1981#endif
1982 default:
1983 return nullptr;
1984 }
1985 }
1986#endif
1987
1988#if USE_GUI
1990 {
1991 std::scoped_lock<std::shared_mutex> lock(entity_mutex);
1993
1994 // Generate default faces
1995 face_descriptors = std::vector<FaceDescriptor>(6);
1996 faces = std::vector<Renderer::Face>(6);
1997 const double half_height = GetHeightImpl() / 2.0;
1998 const double half_width = GetWidthImpl() / 2.0;
1999 for (int i = 0; i < 6; ++i)
2000 {
2001 face_descriptors[i].orientation = static_cast<Orientation>(i);
2002 face_descriptors[i].texture_names = { "" };
2003 face_descriptors[i].cullface_direction = Orientation::None;
2004 face_descriptors[i].use_tintindexes = { false };
2005
2006 // Base entity scale
2007 face_descriptors[i].transformations.scales.push_back(std::make_shared<Renderer::Scale>(
2008 static_cast<float>(half_width),
2009 static_cast<float>(half_height),
2010 static_cast<float>(half_width)
2011 ));
2012 // Base translation
2013 face_descriptors[i].transformations.translations.push_back(std::make_shared<Renderer::Translation>(0.0f, static_cast<float>(half_height), 0.0f));
2014 // Entity pos translation
2015 face_descriptors[i].transformations.translations.push_back(std::make_shared<Renderer::Translation>(
2016 static_cast<float>(position.x),
2017 static_cast<float>(position.y),
2018 static_cast<float>(position.z))
2019 );
2020 // Entity yaw/pitch rotation
2021 face_descriptors[i].transformations.rotations.push_back(std::make_shared<Renderer::Rotation>(0.0f, 1.0f, 0.0f, yaw));
2022 face_descriptors[i].transformations.rotations.push_back(std::make_shared<Renderer::Rotation>(1.0f, 0.0f, 0.0f, pitch));
2023
2024 face_descriptors[i].transformations.rotation = 0;
2025
2026 faces[i] = Renderer::Face(face_descriptors[i].transformations, face_descriptors[i].orientation);
2027 faces[i].SetDisplayBackface(false);
2028 faces[i].SetTextureMultipliers({ 0xFFFFFFFF, 0xFFFFFFFF });
2029
2030 // Extract texture info from the atlas
2031 std::array<unsigned short, 4> texture_pos = { 0, 0, 0, 0 };
2032 std::array<unsigned short, 4> texture_size = { 0, 0, 0, 0 };
2033 std::array<Renderer::Transparency, 2> transparencies = { Renderer::Transparency::Opaque, Renderer::Transparency::Opaque };
2034 std::array<Renderer::Animation, 2> animated = { Renderer::Animation::Static, Renderer::Animation::Static };
2035
2036 for (int j = 0; j < std::min(2, static_cast<int>(face_descriptors[i].texture_names.size())); ++j)
2037 {
2038 const Renderer::TextureData& texture_data = atlas->GetData(face_descriptors[i].texture_names[j]);
2039 std::tie(texture_pos[2 * j + 0], texture_pos[2 * j + 1]) = texture_data.position;
2040 std::tie(texture_size[2 * j + 0], texture_size[2 * j + 1]) = texture_data.size;
2041 transparencies[j] = texture_data.transparency;
2042 animated[j] = texture_data.animation;
2043 }
2044
2045 // Main texture coords in the atlas
2046 std::array<float, 4> coords = faces[i].GetTextureCoords(false);
2047 unsigned short height_normalizer = animated[0] == Renderer::Animation::Animated ? texture_size[0] : texture_size[1];
2048 coords[0] = (texture_pos[0] + coords[0] / 16.0f * texture_size[0]) / atlas->GetWidth();
2049 coords[1] = (texture_pos[1] + coords[1] / 16.0f * height_normalizer) / atlas->GetHeight();
2050 coords[2] = (texture_pos[0] + coords[2] / 16.0f * texture_size[0]) / atlas->GetWidth();
2051 coords[3] = (texture_pos[1] + coords[3] / 16.0f * height_normalizer) / atlas->GetHeight();
2052 faces[i].SetTextureCoords(coords, false);
2053
2054 // Overlay texture coords in the atlas if existing
2055 if (face_descriptors[i].texture_names.size() > 1)
2056 {
2057 coords = faces[i].GetTextureCoords(true);
2058 height_normalizer = animated[1] == Renderer::Animation::Animated ? texture_size[2] : texture_size[3];
2059 coords[0] = (texture_pos[2] + coords[0] / 16.0f * texture_size[2]) / atlas->GetWidth();
2060 coords[1] = (texture_pos[3] + coords[1] / 16.0f * height_normalizer) / atlas->GetHeight();
2061 coords[2] = (texture_pos[2] + coords[2] / 16.0f * texture_size[2]) / atlas->GetWidth();
2062 coords[3] = (texture_pos[3] + coords[3] / 16.0f * height_normalizer) / atlas->GetHeight();
2063 faces[i].SetTextureCoords(coords, true);
2064 }
2065
2066 faces[i].SetTransparencyData(transparencies[0]);
2067 }
2069 }
2070
2072 {
2074 const double half_width = GetWidthImpl() / 2.0;
2075 const double half_height = GetHeightImpl() / 2.0;
2076 for (size_t i = 0; i < faces.size(); ++i)
2077 {
2078 std::static_pointer_cast<Renderer::Scale>(face_descriptors[i].transformations.scales.back())->axis_x = static_cast<float>(half_width);
2079 std::static_pointer_cast<Renderer::Scale>(face_descriptors[i].transformations.scales.back())->axis_y = static_cast<float>(half_height);
2080 std::static_pointer_cast<Renderer::Scale>(face_descriptors[i].transformations.scales.back())->axis_z = static_cast<float>(half_width);
2081 std::static_pointer_cast<Renderer::Translation>(face_descriptors[i].transformations.translations.front())->y = static_cast<float>(half_height);
2082 }
2083 }
2084#endif
2085
2087 {
2088 return std::any_cast<char>(metadata.at("data_shared_flags_id"));
2089 }
2090
2092 {
2093 return (GetDataSharedFlagsIdImpl() >> static_cast<char>(id)) & 0x01;
2094 }
2095
2096 void Entity::SetDataSharedFlagsIdImpl(const char data_shared_flags_id)
2097 {
2098 metadata["data_shared_flags_id"] = data_shared_flags_id;
2099 }
2100
2102 {
2103 char current_value = GetDataSharedFlagsIdImpl();
2104 // Set the bit to 0
2105 const char mask = 0x01 << static_cast<char>(id);
2106 current_value &= ~mask;
2107 // Set the bit to b
2108 current_value |= b << static_cast<char>(id);
2109 SetDataSharedFlagsIdImpl(current_value);
2110 }
2111
2112#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
2114 {
2115 return std::any_cast<Pose>(metadata.at("data_pose"));
2116 }
2117
2118 void Entity::SetDataPoseImpl(const Pose data_pose)
2119 {
2120 metadata["data_pose"] = data_pose;
2121#if USE_GUI
2122 OnSizeUpdated();
2123#endif
2124 }
2125#endif
2126
2128 {
2129 const double half_width = GetWidthImpl() / 2.0;
2130 const double half_height = GetHeightImpl() / 2.0;
2131 return AABB(Vector3<double>(position.x, position.y + half_height, position.z), Vector3<double>(half_width, half_height, half_width));
2132 }
2133
2135 {
2136 return -1.0;
2137 }
2138
2140 {
2141 return -1.0;
2142 }
2143}
#define LOG_ERROR(osstream)
Definition Logger.hpp:45
const Renderer::Atlas * GetAtlas() const
static AssetsManager & getInstance()
int GetDataTicksFrozen() const
Definition Entity.cpp:790
void OnSizeUpdated()
Definition Entity.cpp:2071
bool GetOnGround() const
Definition Entity.cpp:937
ProtocolCraft::UUID uuid
Definition Entity.hpp:267
virtual double GetHeightImpl() const
Definition Entity.cpp:2139
void SetDataSilent(const bool data_silent)
Definition Entity.cpp:836
virtual ProtocolCraft::Json::Value Serialize() const
Definition Entity.cpp:1189
void SetDataPose(const Pose data_pose)
Definition Entity.cpp:849
std::map< EquipmentSlot, ProtocolCraft::Slot > equipments
Items on this entity.
Definition Entity.hpp:276
virtual void SetY(const double y_)
Definition Entity.cpp:1038
double GetZ() const
Definition Entity.cpp:895
virtual bool IsAbstractChestedHorse() const
Definition Entity.cpp:1294
virtual bool IsWaterAnimal() const
Definition Entity.cpp:1289
void SetEffects(const std::vector< EntityEffect > &effects_)
Definition Entity.cpp:1138
void SetDataAirSupplyId(const int data_air_supply_id)
Definition Entity.cpp:810
void SetDataSharedFlagsIdImpl(const char data_shared_flags_id)
Definition Entity.cpp:2096
Vector3< double > GetSpeed() const
Definition Entity.cpp:913
void SetUUID(const ProtocolCraft::UUID &uuid_)
Definition Entity.cpp:997
std::map< EquipmentSlot, ProtocolCraft::Slot > GetEquipments() const
Definition Entity.cpp:943
Vector3< double > speed
Definition Entity.hpp:271
virtual bool IsAbstractArrow() const
Definition Entity.cpp:1245
virtual bool IsAbstractSkeleton() const
Definition Entity.cpp:1401
virtual bool IsAbstractPiglin() const
Definition Entity.cpp:1371
int GetEntityID() const
Definition Entity.cpp:865
virtual bool IsLocalPlayer() const
Definition Entity.cpp:1230
double GetHeight() const
Definition Entity.cpp:357
std::vector< EntityEffect > effects
Definition Entity.hpp:277
char GetDataSharedFlagsIdImpl() const
Definition Entity.cpp:2086
virtual bool IsRemotePlayer() const
Definition Entity.cpp:1235
bool GetDataSilent() const
Definition Entity.cpp:769
void SetDataPoseImpl(const Pose data_pose)
Definition Entity.cpp:2118
double GetSpeedX() const
Definition Entity.cpp:919
virtual bool IsAbstractBoat() const
Definition Entity.cpp:1455
virtual bool IsAbstractHurtingProjectile() const
Definition Entity.cpp:1299
ProtocolCraft::UUID GetUUID() const
Definition Entity.cpp:871
double GetY() const
Definition Entity.cpp:889
virtual bool IsAbstractSchoolingFish() const
Definition Entity.cpp:1284
void SetSpeed(const Vector3< double > &speed_)
Definition Entity.cpp:1102
virtual bool IsHangingEntity() const
Definition Entity.cpp:1338
bool GetAreRenderedFacesUpToDate() const
Definition Entity.cpp:983
virtual void SetMetadataValue(const int index, const std::any &value)
Definition Entity.cpp:716
virtual bool IsSpellcasterIllager() const
Definition Entity.cpp:1309
virtual bool IsBlockAttachedEntity() const
Definition Entity.cpp:1448
static std::shared_ptr< Entity > CreateEntity(const EntityType type)
Definition Entity.cpp:1498
virtual bool IsAbstractThrownPotion() const
Definition Entity.cpp:1383
AABB GetCollider() const
Definition Entity.cpp:345
static const std::array< std::string, metadata_count > metadata_names
Definition Entity.hpp:61
bool are_rendered_faces_up_to_date
Definition Entity.hpp:286
virtual double GetWidthImpl() const
Definition Entity.cpp:2134
virtual void SetZ(const double z_)
Definition Entity.cpp:1054
void SetEquipment(const EquipmentSlot slot, const ProtocolCraft::Slot &item)
Definition Entity.cpp:1132
std::vector< Renderer::Face > faces
Definition Entity.hpp:284
virtual bool IsLivingEntity() const
Definition Entity.cpp:1240
virtual bool IsChestBoat() const
Definition Entity.cpp:1475
double GetWidth() const
Definition Entity.cpp:351
virtual ~Entity()
Definition Entity.cpp:339
virtual bool IsPatrollingMonster() const
Definition Entity.cpp:1429
virtual bool IsProjectile() const
Definition Entity.cpp:1315
int GetDataAirSupplyId() const
Definition Entity.cpp:743
std::vector< EntityEffect > GetEffects() const
Definition Entity.cpp:955
virtual bool IsAbstractMinecart() const
Definition Entity.cpp:1348
virtual bool IsAvatar() const
Definition Entity.cpp:1491
virtual bool IsDisplay() const
Definition Entity.cpp:1266
void SetSpeedY(const double speed_y_)
Definition Entity.cpp:1114
virtual bool IsAbstractMinecartContainer() const
Definition Entity.cpp:1360
void SetDataCustomName(const std::optional< ProtocolCraft::Chat > &data_custom_name)
Definition Entity.cpp:817
virtual bool IsAmbientCreature() const
Definition Entity.cpp:1255
virtual bool IsFireball() const
Definition Entity.cpp:1343
Pose GetDataPose() const
Definition Entity.cpp:782
std::shared_mutex entity_mutex
Definition Entity.hpp:264
void SetOnGround(const bool on_ground_)
Definition Entity.cpp:1126
virtual bool IsAnimal() const
Definition Entity.cpp:1250
std::vector< Renderer::Face > GetFaces(const bool reset_uptodate_status)
Definition Entity.cpp:962
void SetSpeedX(const double speed_x_)
Definition Entity.cpp:1108
virtual bool IsAbstractFish() const
Definition Entity.cpp:1389
virtual bool IsAgeableMob() const
Definition Entity.cpp:1418
virtual void SetX(const double x_)
Definition Entity.cpp:1022
virtual bool IsAbstractVillager() const
Definition Entity.cpp:1412
virtual void InitializeFaces()
Definition Entity.cpp:1989
virtual bool IsThrowableProjectile() const
Definition Entity.cpp:1435
virtual bool IsAbstractWindCharge() const
Definition Entity.cpp:1441
AABB GetColliderImpl() const
Definition Entity.cpp:2127
void SetDataSharedFlagsId(const char data_shared_flags_id)
Definition Entity.cpp:798
char GetDataSharedFlagsId() const
Definition Entity.cpp:731
virtual bool IsMob() const
Definition Entity.cpp:1304
virtual void SetYaw(const float yaw_)
Definition Entity.cpp:1070
virtual bool IsPathfinderMob() const
Definition Entity.cpp:1423
ProtocolCraft::Slot GetEquipment(const EquipmentSlot slot) const
Definition Entity.cpp:949
void SetDataCustomNameVisible(const bool data_custom_name_visible)
Definition Entity.cpp:830
virtual bool IsVehicle() const
Definition Entity.cpp:1273
double GetSpeedY() const
Definition Entity.cpp:925
double GetSpeedZ() const
Definition Entity.cpp:931
Pose GetDataPoseImpl() const
Definition Entity.cpp:2113
virtual bool IsRaider() const
Definition Entity.cpp:1395
virtual void SetPitch(const float pitch_)
Definition Entity.cpp:1086
virtual bool IsThrowableItemProjectile() const
Definition Entity.cpp:1406
void SetEntityID(const int entity_id_)
Definition Entity.cpp:991
virtual bool IsMonster() const
Definition Entity.cpp:1260
virtual bool IsTamableAnimal() const
Definition Entity.cpp:1279
void SetDataNoGravity(const bool data_no_gravity)
Definition Entity.cpp:842
bool GetDataCustomNameVisible() const
Definition Entity.cpp:763
virtual bool IsAbstractIllager() const
Definition Entity.cpp:1377
virtual bool IsAbstractHorse() const
Definition Entity.cpp:1328
std::map< std::string, std::any > metadata
Definition Entity.hpp:279
Vector3< double > position
Definition Entity.hpp:268
virtual bool IsAbstractCow() const
Definition Entity.cpp:1354
virtual bool IsAbstractChestBoat() const
Definition Entity.cpp:1460
void AddEffect(const EntityEffect &effect)
Definition Entity.cpp:1160
virtual bool IsChestRaft() const
Definition Entity.cpp:1480
virtual bool IsAbstractGolem() const
Definition Entity.cpp:1333
float GetYaw() const
Definition Entity.cpp:901
virtual bool IsAgeableWaterCreature() const
Definition Entity.cpp:1465
double GetX() const
Definition Entity.cpp:883
bool GetDataNoGravity() const
Definition Entity.cpp:775
void SetAreRenderedFacesUpToDate(const bool are_rendered_faces_up_to_date_)
Definition Entity.cpp:1181
Vector3< double > GetPosition() const
Definition Entity.cpp:877
void SetSpeedZ(const double speed_z_)
Definition Entity.cpp:1120
static constexpr int metadata_count
Definition Entity.hpp:55
std::vector< FaceDescriptor > face_descriptors
Definition Entity.hpp:283
std::optional< ProtocolCraft::Chat > GetDataCustomName() const
Definition Entity.cpp:750
virtual bool IsBoat() const
Definition Entity.cpp:1470
void LoadMetadataFromRawArray(const std::vector< unsigned char > &data)
Definition Entity.cpp:364
virtual bool IsRaft() const
Definition Entity.cpp:1485
virtual bool IsShoulderRidingEntity() const
Definition Entity.cpp:1365
float GetPitch() const
Definition Entity.cpp:907
void RemoveEffect(const EntityEffectType type)
Definition Entity.cpp:1144
virtual void SetPosition(const Vector3< double > &position_)
Definition Entity.cpp:1003
void SetDataTicksFrozen(const int data_ticks_frozen)
Definition Entity.cpp:857
const TextureData & GetData(const std::string &name) const
Definition Atlas.cpp:237
Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant direc...
Definition Json.hpp:45
virtual void Read(ReadIterator &iter, size_t &length)
Vector3< int > Position
Definition Vector3.hpp:294
EquipmentSlot
Definition Enums.hpp:276
EntityEffectType
Definition Enums.hpp:318
EntitySharedFlagsId
Definition Entity.hpp:40
std::array< unsigned char, 16 > UUID
std::vector< unsigned char >::const_iterator ReadIterator
EntityEffectType type
Definition Entity.hpp:34
std::pair< int, int > position
<Col, Row>
Definition Atlas.hpp:16
std::pair< int, int > size
<Width, Height>
Definition Atlas.hpp:14
ProtocolCraft::Json::Value Serialize() const
Definition Vector3.hpp:279