6 #include "../Mobs/Monster.h" 7 #include "../BoundingBox.h" 8 #include "../ClientHandle.h" 18 super(etLeashKnot, a_BlockFace, a_Pos),
19 m_ShouldSelfDestroy(false),
20 m_TicksToSelfDestroy(20 * 1)
48 if (a_Entity.
GetEntityType() != cEntity::eEntityType::etMonster)
53 auto & PotentialLeashed =
static_cast<cMonster&
>(a_Entity);
56 if (!PotentialLeashed.CanBeLeashed())
63 !PotentialLeashed.IsLeashed() ||
64 !PotentialLeashed.GetLeashedTo()->IsPlayer() ||
65 (PotentialLeashed.GetLeashedTo()->GetUniqueID() != a_Player.
GetUniqueID())
72 PotentialLeashed.
Unleash(
false,
false);
73 PotentialLeashed.LeashTo(*
this, a_ShouldBroadcast);
97 if ((a_Killer !=
nullptr) && a_Killer->
IsPlayer() && !
static_cast<cPlayer *
>(a_Killer)->IsGameModeCreative())
150 LeashKnot =
static_cast<cLeashKnot *
>(&a_Entity);
virtual bool ForEachEntityInBox(const cBoundingBox &a_Box, cEntityCallback a_Callback) override
Calls the callback for each entity that has a nonempty intersection with the specified boundingbox...
virtual void KilledBy(TakeDamageInfo &a_TDI) override
Called when the health drops below zero.
double GetPitch(void) const
Byte GetProtocolFacing() const
Returns the direction in which the entity is facing.
eEntityType GetEntityType(void) const
virtual void GetDrops(cItems &a_Items, cEntity *a_Killer) override
Returns the list of drops for this pawn when it is killed.
virtual void BroadcastEntityMetadata(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
virtual void KilledBy(TakeDamageInfo &a_TDI)
Called when the health drops below zero.
void TiePlayersLeashedMobs(cPlayer &a_Player, bool a_ShouldBroadCast)
Looks for mobs leashed to a player and ties them to this knot.
virtual void SpawnOn(cClientHandle &a_ClientHandle) override
Descendants override this function to send a command to the specified client to spawn the entity on t...
void SendSpawnObject(const cEntity &a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch)
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
bool m_ShouldSelfDestroy
When a fence is destroyed, the knot on it gets destroyed after a while.
Represents two sets of coords, minimum and maximum for each direction.
cLeashKnot(eBlockFace a_BlockFace, Vector3d a_Pos)
static cLeashKnot * FindKnotAtPos(cWorldInterface &a_WorldInterface, Vector3i a_BlockPos)
Returns the leash knot entity representing the knot at the specified position.
virtual void OnRightClicked(cPlayer &a_Player) override
Called when the specified player right-clicks this entity.
virtual void Destroy(bool a_ShouldBroadcast=true)
Destroys the entity and schedules it for memory freeing; if a_ShouldBroadcast is set to true...
virtual void BroadcastSoundEffect(const AString &a_SoundName, Vector3d a_Position, float a_Volume, float a_Pitch, const cClientHandle *a_Exclude=nullptr) override
virtual void SpawnOn(cClientHandle &a_ClientHandle) override
Descendants override this function to send a command to the specified client to spawn the entity on t...
virtual void OnRightClicked(cPlayer &a_Player)
Called when the specified player right-clicks this entity.
double GetYaw(void) const
virtual bool ForEachEntityInBox(const cBoundingBox &a_Box, cEntityCallback a_Callback)=0
Calls the callback for each entity that has a nonempty intersection with the specified boundingbox...
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc...
bool IsPlayer(void) const
const Vector3d & GetPosition(void) const
Exported in ManualBindings.
void Unleash(bool a_ShouldDropLeashPickup)
Unleash the monster.
long int m_TicksAlive
The number of ticks this entity has been alive for.
void SendEntityMetadata(const cEntity &a_Entity)
bool IsLeashKnot(void) const
UInt32 GetUniqueID(void) const
cWorld * GetWorld(void) const
This class bridges a vector of cItem for safe access via Lua.