10#include <shared_mutex>
13#if PROTOCOL_VERSION > 340
31#if PROTOCOL_VERSION < 458
32 enum class ObjectEntityType;
39 std::chrono::steady_clock::time_point
end;
58 std::string_view(
"data_shared_flags_id"),
59 std::string_view(
"data_air_supply_id"),
60 std::string_view(
"data_custom_name"),
61 std::string_view(
"data_custom_name_visible"),
62 std::string_view(
"data_silent"),
63 std::string_view(
"data_no_gravity"),
64#if PROTOCOL_VERSION > 404
65 std::string_view(
"data_pose"),
67#if PROTOCOL_VERSION > 754
68 std::string_view(
"data_ticks_frozen"),
89 static constexpr int FindMetadataIndex(
const std::array<std::string_view, N>& names,
const std::string_view name)
91 for (
size_t i = 0; i < N; ++i)
95 return static_cast<int>(i);
101 template <
typename T>
104 return std::any_cast<T>(
metadata.at(index));
107 template <
typename T>
111 return GetMetadataImpl<T>(index);
115 void SetMetadata(
const int index,
const std::any& value);
125#if PROTOCOL_VERSION > 340
133#if PROTOCOL_VERSION > 404
136#if PROTOCOL_VERSION > 754
144#if PROTOCOL_VERSION > 340
145 void SetDataCustomName(
const std::optional<ProtocolCraft::Chat>& data_custom_name);
152#if PROTOCOL_VERSION > 404
155#if PROTOCOL_VERSION > 754
174 std::map<EquipmentSlot, ProtocolCraft::Slot>
GetEquipments()
const;
178 std::vector<Renderer::Face>
GetFaces(
const bool reset_uptodate_status);
186 virtual void SetX(
const double x_);
187 virtual void SetY(
const double y_);
188 virtual void SetZ(
const double z_);
189 virtual void SetYaw(
const float yaw_);
190 virtual void SetPitch(
const float pitch_);
198 void SetEffects(
const std::vector<EntityEffect>& effects_);
218#if PROTOCOL_VERSION > 761
221#if PROTOCOL_VERSION > 764
229 virtual bool IsMob()
const;
231#if PROTOCOL_VERSION > 578
234#if PROTOCOL_VERSION < 771
235 virtual bool IsFlyingMob()
const;
242#if PROTOCOL_VERSION > 769
247#if PROTOCOL_VERSION > 736
251#if PROTOCOL_VERSION > 769
255#if PROTOCOL_VERSION > 404
260#if PROTOCOL_VERSION > 477
265#if PROTOCOL_VERSION > 404
269#if PROTOCOL_VERSION > 765
272#if PROTOCOL_VERSION > 766
275#if PROTOCOL_VERSION > 767
279 virtual bool IsBoat()
const;
282 virtual bool IsRaft()
const;
284#if PROTOCOL_VERSION > 772
287#if PROTOCOL_VERSION > 773
290#if PROTOCOL_VERSION > 775
297#if PROTOCOL_VERSION < 458
298 static std::shared_ptr<Entity> CreateObjectEntity(
const ObjectEntityType type);
311#if PROTOCOL_VERSION > 404
347#define BOTCRAFT_ENTITY_METADATA_INDEX(name) \
349 constexpr int i = FindMetadataIndex(metadata_names, name); \
350 static_assert(i >= 0, "Unknown metadata " name); \
351 return hierarchy_metadata_count + i; \
357#if PROTOCOL_VERSION > 340
358#if PROTOCOL_VERSION > 767
362#if PROTOCOL_VERSION > 758
366#if PROTOCOL_VERSION > 765
371#if PROTOCOL_VERSION > 754
374#if PROTOCOL_VERSION > 767
379#if PROTOCOL_VERSION > 498
382#if PROTOCOL_VERSION > 767
387#if PROTOCOL_VERSION > 761
390#if PROTOCOL_VERSION < 768
393#if PROTOCOL_VERSION > 765
396#if PROTOCOL_VERSION > 764
399#if PROTOCOL_VERSION > 765
402#if PROTOCOL_VERSION > 758 && PROTOCOL_VERSION < 762
405#if PROTOCOL_VERSION > 404 && PROTOCOL_VERSION < 762
408#if PROTOCOL_VERSION > 760
411#if PROTOCOL_VERSION > 773
414#if PROTOCOL_VERSION > 761
418#if PROTOCOL_VERSION > 767
422#if PROTOCOL_VERSION > 761 && PROTOCOL_VERSION < 768
425#if PROTOCOL_VERSION > 761
430#if PROTOCOL_VERSION > 772
433#if PROTOCOL_VERSION > 761
437#if PROTOCOL_VERSION > 767
440#if PROTOCOL_VERSION > 767 && PROTOCOL_VERSION < 769
444#if PROTOCOL_VERSION > 776
447#if PROTOCOL_VERSION > 767
451#if PROTOCOL_VERSION < 735
455#if PROTOCOL_VERSION > 578
460#if PROTOCOL_VERSION > 761
464#if PROTOCOL_VERSION < 768
468#if PROTOCOL_VERSION > 761 && PROTOCOL_VERSION < 768
473#if PROTOCOL_VERSION > 767
478#if PROTOCOL_VERSION < 735
482#if PROTOCOL_VERSION > 578
485#if PROTOCOL_VERSION > 761
491#if PROTOCOL_VERSION > 767
495#if PROTOCOL_VERSION > 404
498#if PROTOCOL_VERSION > 758
501#if PROTOCOL_VERSION > 761
505#if PROTOCOL_VERSION > 770
509#if PROTOCOL_VERSION > 754
515#if PROTOCOL_VERSION > 578
518#if PROTOCOL_VERSION > 761
524#if PROTOCOL_VERSION > 761
527#if PROTOCOL_VERSION > 578
531#if PROTOCOL_VERSION > 761
535#if PROTOCOL_VERSION > 767
539#if PROTOCOL_VERSION > 765 && PROTOCOL_VERSION < 768
542#if PROTOCOL_VERSION < 768
546#if PROTOCOL_VERSION > 578
552#if PROTOCOL_VERSION > 767
556#if PROTOCOL_VERSION > 772
559#if PROTOCOL_VERSION > 754
563#if PROTOCOL_VERSION < 762
573#if PROTOCOL_VERSION > 761
576#if PROTOCOL_VERSION > 773
579#if PROTOCOL_VERSION > 767
584#if PROTOCOL_VERSION > 767
588#if PROTOCOL_VERSION > 767
592#if PROTOCOL_VERSION > 404
595#if PROTOCOL_VERSION > 773
599#if PROTOCOL_VERSION > 578
603#if PROTOCOL_VERSION > 578
606#if PROTOCOL_VERSION > 736
609#if PROTOCOL_VERSION > 578
612#if PROTOCOL_VERSION < 735
617#if PROTOCOL_VERSION > 776
621#if PROTOCOL_VERSION > 769
625#if PROTOCOL_VERSION > 761 && PROTOCOL_VERSION < 770
628#if PROTOCOL_VERSION < 762
631#if PROTOCOL_VERSION > 578
635#if PROTOCOL_VERSION > 578
647#if PROTOCOL_VERSION > 761
650#if PROTOCOL_VERSION < 768
654#if PROTOCOL_VERSION > 767
657#if PROTOCOL_VERSION > 761
662#if PROTOCOL_VERSION > 767
668#if PROTOCOL_VERSION > 578
671#if PROTOCOL_VERSION > 775
674#if PROTOCOL_VERSION > 758
677#if PROTOCOL_VERSION > 761
682#if PROTOCOL_VERSION > 404 && PROTOCOL_VERSION < 735
685#if PROTOCOL_VERSION < 735
689#if PROTOCOL_VERSION < 762
695#if PROTOCOL_VERSION > 404 && PROTOCOL_VERSION < 762
698#if PROTOCOL_VERSION > 578
701#if PROTOCOL_VERSION > 761
704#if PROTOCOL_VERSION > 578
710#if PROTOCOL_VERSION < 735
714#if PROTOCOL_VERSION > 404 && PROTOCOL_VERSION < 735
717#if PROTOCOL_VERSION > 404
720#if PROTOCOL_VERSION > 758
723#if PROTOCOL_VERSION > 764
731#if PROTOCOL_VERSION > 578
736#if PROTOCOL_VERSION > 773
740#if PROTOCOL_VERSION > 578
743#if PROTOCOL_VERSION < 735
746#if PROTOCOL_VERSION > 404 && PROTOCOL_VERSION < 735
749#if PROTOCOL_VERSION < 735
754#if PROTOCOL_VERSION < 477
847#if PROTOCOL_VERSION < 458
848 enum class ObjectEntityType
865 FallingBlockEntity = 70,
870 FireworkRocketEntity = 76,
871 LeashFenceKnotEntity = 77,
877#if PROTOCOL_VERSION > 340
int GetDataTicksFrozen() const
void SetMetadata(const int index, const std::any &value)
virtual EntityType GetType() const =0
virtual double GetHeightImpl() const
void SetDataSilent(const bool data_silent)
virtual ProtocolCraft::Json::Value Serialize() const
void SetDataPose(const Pose data_pose)
std::map< EquipmentSlot, ProtocolCraft::Slot > equipments
Items on this entity.
virtual void SetY(const double y_)
virtual bool IsAbstractChestedHorse() const
virtual bool IsWaterAnimal() const
void SetEffects(const std::vector< EntityEffect > &effects_)
void SetDataAirSupplyId(const int data_air_supply_id)
void SetDataSharedFlagsIdImpl(const char data_shared_flags_id)
Vector3< double > GetSpeed() const
void SetUUID(const ProtocolCraft::UUID &uuid_)
std::map< EquipmentSlot, ProtocolCraft::Slot > GetEquipments() const
virtual bool IsAbstractArrow() const
virtual bool IsAbstractSkeleton() const
virtual bool IsAbstractPiglin() const
virtual bool IsLocalPlayer() const
std::vector< EntityEffect > effects
char GetDataSharedFlagsIdImpl() const
virtual bool IsRemotePlayer() const
virtual bool IsAbstractNautilus() const
bool GetDataSilent() const
void SetDataPoseImpl(const Pose data_pose)
virtual bool IsAbstractBoat() const
virtual bool IsAbstractHurtingProjectile() const
ProtocolCraft::UUID GetUUID() const
void AddSpeed(const Vector3< double > &delta)
virtual bool IsAbstractSchoolingFish() const
void SetSpeed(const Vector3< double > &speed_)
virtual bool IsHangingEntity() const
bool GetAreRenderedFacesUpToDate() const
virtual bool IsSpellcasterIllager() const
virtual bool IsBlockAttachedEntity() const
T GetMetadataImpl(const int index) const
static std::shared_ptr< Entity > CreateEntity(const EntityType type)
static constexpr int hierarchy_metadata_count
virtual bool IsAbstractThrownPotion() const
bool are_rendered_faces_up_to_date
virtual double GetWidthImpl() const
virtual void SetZ(const double z_)
void SetEquipment(const EquipmentSlot slot, const ProtocolCraft::Slot &item)
std::vector< Renderer::Face > faces
virtual bool IsLivingEntity() const
virtual bool IsChestBoat() const
virtual bool IsPatrollingMonster() const
virtual bool IsProjectile() const
int GetDataAirSupplyId() const
std::vector< EntityEffect > GetEffects() const
virtual bool IsAbstractMinecart() const
virtual bool IsAvatar() const
virtual bool IsDisplay() const
void SetSpeedY(const double speed_y_)
virtual bool IsAbstractMinecartContainer() const
void SetDataCustomName(const std::optional< ProtocolCraft::Chat > &data_custom_name)
virtual bool IsAmbientCreature() const
virtual bool IsFireball() const
std::shared_mutex entity_mutex
void SetOnGround(const bool on_ground_)
virtual bool IsAnimal() const
std::vector< Renderer::Face > GetFaces(const bool reset_uptodate_status)
void SetSpeedX(const double speed_x_)
virtual bool IsAbstractFish() const
virtual bool IsAbstractCubeMob() const
virtual bool IsAgeableMob() const
virtual void SetX(const double x_)
std::vector< std::any > metadata
virtual bool IsAbstractVillager() const
virtual void InitializeFaces()
virtual bool IsThrowableProjectile() const
virtual bool IsAbstractWindCharge() const
AABB GetColliderImpl() const
void SetDataSharedFlagsId(const char data_shared_flags_id)
char GetDataSharedFlagsId() const
virtual bool IsMob() const
virtual void SetYaw(const float yaw_)
virtual bool IsPathfinderMob() const
ProtocolCraft::Slot GetEquipment(const EquipmentSlot slot) const
T GetMetadata(const int index) const
void SetDataCustomNameVisible(const bool data_custom_name_visible)
virtual bool IsVehicle() const
virtual std::string GetName() const =0
Pose GetDataPoseImpl() const
static constexpr std::array metadata_names
virtual void OnMetadataChangedImpl(const int index)
virtual bool IsRaider() const
virtual void SetPitch(const float pitch_)
virtual bool IsThrowableItemProjectile() const
void SetEntityID(const int entity_id_)
virtual bool IsMonster() const
virtual bool IsTamableAnimal() const
void SetDataNoGravity(const bool data_no_gravity)
bool GetDataCustomNameVisible() const
virtual bool IsAbstractIllager() const
virtual bool IsAbstractHorse() const
void SetMetadataImpl(const int index, const std::any &value)
Vector3< double > position
virtual bool IsAbstractCow() const
virtual bool IsAbstractChestBoat() const
void AddEffect(const EntityEffect &effect)
virtual bool IsChestRaft() const
virtual bool IsAbstractGolem() const
virtual bool IsAgeableWaterCreature() const
bool GetDataNoGravity() const
void SetAreRenderedFacesUpToDate(const bool are_rendered_faces_up_to_date_)
Vector3< double > GetPosition() const
static constexpr int FindMetadataIndex(const std::array< std::string_view, N > &names, const std::string_view name)
void SetSpeedZ(const double speed_z_)
static constexpr int metadata_count
std::vector< FaceDescriptor > face_descriptors
std::optional< ProtocolCraft::Chat > GetDataCustomName() const
virtual bool IsBoat() const
void LoadMetadataFromRawArray(const std::vector< unsigned char > &data)
virtual bool IsRaft() const
virtual bool IsShoulderRidingEntity() const
void RemoveEffect(const EntityEffectType type)
virtual void SetPosition(const Vector3< double > &position_)
void SetDataTicksFrozen(const int data_ticks_frozen)
Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant direc...
std::array< unsigned char, 16 > UUID
std::chrono::steady_clock::time_point end