6 #include "../BlockInfo.h"
9 #include "../ClientHandle.h"
10 #include "../Items/ItemHandler.h"
12 #include "../EffectID.h"
13 #include "../Entities/Player.h"
14 #include "../Entities/ExpOrb.h"
15 #include "../MonsterConfig.h"
16 #include "../BoundingBox.h"
21 #include "../FastRandom.h"
24 #include "../Entities/LeashKnot.h"
41 {
mtBat,
"bat",
"Bat",
"bat"},
42 {
mtBlaze,
"blaze",
"Blaze",
"blaze"},
43 {
mtCaveSpider,
"cavespider",
"CaveSpider",
"cave_spider"},
44 {
mtChicken,
"chicken",
"Chicken",
"chicken"},
45 {
mtCow,
"cow",
"Cow",
"cow"},
46 {
mtCreeper,
"creeper",
"Creeper",
"creeper"},
47 {
mtEnderman,
"enderman",
"Enderman",
"enderman"},
48 {
mtEndermite,
"endermite",
"Endermite",
"endermite"},
49 {
mtEnderDragon,
"enderdragon",
"EnderDragon",
"ender_dragon"},
50 {
mtGhast,
"ghast",
"Ghast",
"ghast"},
51 {
mtGiant,
"giant",
"Giant",
"giant"},
52 {
mtGuardian,
"guardian",
"Guardian",
"guardian"},
53 {
mtHorse,
"horse",
"EntityHorse",
"horse"},
54 {
mtIronGolem,
"irongolem",
"VillagerGolem",
"iron_golem"},
55 {
mtMagmaCube,
"magmacube",
"LavaSlime",
"magma_cube"},
56 {
mtMooshroom,
"mooshroom",
"MushroomCow",
"mooshroom"},
57 {
mtOcelot,
"ocelot",
"Ozelot",
"ocelot"},
58 {
mtPig,
"pig",
"Pig",
"pig"},
59 {
mtRabbit,
"rabbit",
"Rabbit",
"rabbit"},
60 {
mtSheep,
"sheep",
"Sheep",
"sheep"},
61 {
mtSilverfish,
"silverfish",
"Silverfish",
"silverfish"},
62 {
mtSkeleton,
"skeleton",
"Skeleton",
"skeleton"},
63 {
mtSlime,
"slime",
"Slime",
"slime"},
64 {
mtSnowGolem,
"snowgolem",
"SnowMan",
"snow_golem"},
65 {
mtSpider,
"spider",
"Spider",
"spider"},
66 {
mtSquid,
"squid",
"Squid",
"squid"},
67 {
mtVillager,
"villager",
"Villager",
"villager"},
68 {
mtWitch,
"witch",
"Witch",
"witch"},
69 {
mtWither,
"wither",
"WitherBoss",
"wither"},
71 {
mtWolf,
"wolf",
"Wolf",
"wolf"},
72 {
mtZombie,
"zombie",
"Zombie",
"zombie"},
85 :
Super(etMonster, a_Width, a_Height)
87 , m_EMPersonality(AGGRESSIVE)
88 , m_PathFinder(a_Width, a_Height)
89 , m_PathfinderActivated(false)
93 , m_MobType(a_MobType)
95 , m_CustomNameAlwaysVisible(false)
96 , m_SoundHurt(a_SoundHurt)
97 , m_SoundDeath(a_SoundDeath)
98 , m_SoundAmbient(a_SoundAmbient)
102 , m_AttackCoolDownTicksLeft(0)
103 , m_SightDistance(25)
104 , m_DropChanceWeapon(0.085f)
105 , m_DropChanceHelmet(0.085f)
106 , m_DropChanceChestplate(0.085f)
107 , m_DropChanceLeggings(0.085f)
108 , m_DropChanceBoots(0.085f)
109 , m_CanPickUpLoot(true)
110 , m_TicksSinceLastDamaged(100)
111 , m_BurnsInDaylight(false)
112 , m_RelativeWalkSpeed(1)
114 , m_AgingTimer(
TPS * 60 * 20)
115 , m_WasLastTargetAPlayer(false)
116 , m_LeashedTo(nullptr)
117 , m_LeashToPos(nullptr)
118 , m_IsLeashActionJustDone(false)
119 , m_CanBeLeashed(GetMobFamily() ==
eFamily::mfPassive)
120 , m_LovePartner(nullptr)
126 if (!a_ConfigName.empty())
299 bool a_IsFollowingPath =
false;
328 a_IsFollowingPath =
true;
379 auto ShouldPlaySound = Random.RandBool();
382 auto SoundPitchMultiplier = 1.0f + (Random.RandReal(1.0f) - Random.RandReal(1.0f)) * 0.2f;
410 if (LeashKnot !=
nullptr)
422 static const double CloseFollowDistance = 1.8;
423 static const double LeashNaturalLength = 5.0;
424 static const double LeashMaximumLength = 10.0;
425 static const double LeashSpringConstant = 20.0;
428 const auto Displacement = LeashedToPos -
GetPosition();
429 const auto Distance = Displacement.Length();
430 const auto Direction = Displacement.NormalizeCopy();
435 LOGD(
"Leash broken (distance)");
444 const auto Extension =
Distance - LeashNaturalLength;
445 auto Acceleration =
Direction * (Extension * LeashSpringConstant);
450 Acceleration.y = 0.0;
454 using namespace std::chrono;
455 AddSpeed(Acceleration * duration_cast<duration<double>>(a_Dt).count());
461 const Vector3d TargetBlock((LeashedToPos -
Direction * CloseFollowDistance).Floor());
474 if (!a_IsFollowingPath)
490 double BodyRotation, BodyPitch;
492 VectorToEuler(BodyDistance.
x, BodyDistance.
y, BodyDistance.
z, BodyRotation, BodyPitch);
510 HeadDistance = BodyDistance;
514 double HeadRotation, HeadPitch;
516 VectorToEuler(HeadDistance.
x, HeadDistance.
y, HeadDistance.
z, HeadRotation, HeadPitch);
517 if ((std::abs(BodyRotation - HeadRotation) < 70) && (std::abs(HeadPitch) < 60))
555 return Position.y + 1;
745 cPlayer * TargetPlayer =
nullptr;
758 const auto TargetDistance = (TargetHeadPosition - MyHeadPosition).
SqrLength();
762 (TargetDistance < ClosestDistance) &&
766 TargetPlayer = &a_Player;
767 ClosestDistance = TargetDistance;
774 if (TargetPlayer !=
nullptr)
801 if (!
Target->GetBoundingBox().DoesIntersect({ GetPosition(), m_SightDistance * 2.0 }))
808 const auto TargetHeadPosition =
Target->GetPosition().addedY(
Target->GetHeight());
865 int rem = Random.RandInt(1, 7);
869 Dist.
x =
static_cast<double>(Random.RandInt(-5, 5));
870 Dist.
z =
static_cast<double>(Random.RandInt(-5, 5));
872 if ((Dist.
SqrLength() > 2) && (rem >= 3))
878 if ((Chunk ==
nullptr) || !Chunk->
IsValid())
887 int YBelowUs =
static_cast<int>(Destination.
y) - 1;
951 if (a_CustomName.length() > 64)
1188 switch (a_MobFamily)
1193 case mfWater:
return 400_tick;
1214 if (OldTarget !=
nullptr)
1220 if (a_NewTarget !=
nullptr)
1261 return std::make_unique<cMagmaCube>(1 << Random.RandInt(2));
1265 return std::make_unique<cSlime>(1 << Random.RandInt(2));
1271 int HorseType = Random.RandInt(7);
1272 int HorseColor = Random.RandInt(6);
1273 int HorseStyle = Random.RandInt(4);
1274 int HorseTameTimes = Random.RandInt(1, 6);
1276 if ((HorseType == 5) || (HorseType == 6) || (HorseType == 7))
1282 return std::make_unique<cHorse>(HorseType, HorseColor, HorseStyle, HorseTameTimes);
1288 case mtBat:
return std::make_unique<cBat>();
1289 case mtBlaze:
return std::make_unique<cBlaze>();
1290 case mtCaveSpider:
return std::make_unique<cCaveSpider>();
1291 case mtChicken:
return std::make_unique<cChicken>();
1292 case mtCow:
return std::make_unique<cCow>();
1293 case mtCreeper:
return std::make_unique<cCreeper>();
1294 case mtEnderDragon:
return std::make_unique<cEnderDragon>();
1295 case mtEndermite:
return std::make_unique<cEndermite>();
1296 case mtEnderman:
return std::make_unique<cEnderman>();
1297 case mtGhast:
return std::make_unique<cGhast>();
1298 case mtGiant:
return std::make_unique<cGiant>();
1299 case mtGuardian:
return std::make_unique<cGuardian>();
1300 case mtIronGolem:
return std::make_unique<cIronGolem>();
1301 case mtMooshroom:
return std::make_unique<cMooshroom>();
1302 case mtOcelot:
return std::make_unique<cOcelot>();
1303 case mtPig:
return std::make_unique<cPig>();
1304 case mtRabbit:
return std::make_unique<cRabbit>();
1305 case mtSheep:
return std::make_unique<cSheep>();
1306 case mtSilverfish:
return std::make_unique<cSilverfish>();
1307 case mtSkeleton:
return std::make_unique<cSkeleton>();
1308 case mtSnowGolem:
return std::make_unique<cSnowGolem>();
1309 case mtSpider:
return std::make_unique<cSpider>();
1310 case mtSquid:
return std::make_unique<cSquid>();
1311 case mtWitch:
return std::make_unique<cWitch>();
1312 case mtWither:
return std::make_unique<cWither>();
1314 case mtWolf:
return std::make_unique<cWolf>();
1315 case mtZombie:
return std::make_unique<cZombie>();
1319 ASSERT(!
"Unhandled mob type whilst trying to spawn mob!");
1376 Baby =
static_cast<cMonster *
>(&a_Entity);
1380 if (Baby !=
nullptr)
1405 if (FollowedItems.
Size() > 0)
1412 Vector3d PlayerPos = a_Player.GetPosition();
1413 MoveToPosition(PlayerPos);
1435 auto & Me =
static_cast<cMonster &
>(*
this);
1436 auto & PotentialPartner =
static_cast<cMonster &
>(a_Entity);
1439 if (PotentialPartner.GetMobType() != Me.GetMobType())
1446 if ((!PotentialPartner.IsInLove()) || (PotentialPartner.GetPartner() !=
nullptr))
1453 Me.EngageLoveMode(&PotentialPartner);
1522 while (Count > MaxStackSize)
1524 a_Drops.emplace_back(a_Item, MaxStackSize, a_ItemHealth);
1525 Count -= MaxStackSize;
1529 a_Drops.emplace_back(a_Item, Count, a_ItemHealth);
1541 a_Drops.emplace_back(a_Item,
static_cast<char>(1), a_ItemHealth);
1552 if (r1.RandBool((5 + a_LootingLevel) / 200.0))
1554 size_t Rare = r1.RandInt<
size_t>(a_Items.
Size() - 1);
1555 a_Drops.push_back(a_Items.at(Rare));
1567 double LootingBonus = a_LootingLevel / 100.0;
1654 int RelY =
FloorC(a_Location.
y);
1674 (
GetWorld()->GetTimeOfDay() < 13000_tick) &&
1675 Chunk->IsWeatherSunnyAt(Rel.x, Rel.z) &&
1688 int CurrentBlock = Chunk->GetHeight(Rel.x, Rel.z);
1689 while (CurrentBlock > MobHeight)
1735 if (a_ShouldBroadcast)
1759 if (a_ShouldDropLeashPickup)
1766 if (a_ShouldBroadcast)
1780 Unleash(a_ShouldDropLeashPickup,
true);
bool IsBlockWater(BLOCKTYPE a_BlockType)
@ E_BLOCK_STATIONARY_WATER
#define PREPARE_REL_AND_CHUNK(Position, OriginalChunk)
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
unsigned char BLOCKTYPE
The datatype used by blockdata.
constexpr const int TPS
Constant to calculate ticks from seconds "ticks per second".
void VectorToEuler(double a_X, double a_Y, double a_Z, double &a_Pan, double &a_Pitch)
#define GET_AND_VERIFY_CURRENT_CHUNK(ChunkVarName, X, Z)
MTRand & GetRandomProvider()
Returns the current thread's random number source.
#define ARRAYCOUNT(X)
Evaluates to the number of elements in an array (compile-time!)
T Clamp(T a_Value, T a_Min, T a_Max)
Clamp X to the specified range.
std::chrono::duration< signed int, std::ratio_multiply< std::chrono::milliseconds::period, std::ratio< 50 > >> cTickTime
std::enable_if< std::is_arithmetic< T >::value, C >::type CeilC(T a_Value)
Ceils a value, then casts it to C (an int by default).
std::enable_if< std::is_arithmetic< T >::value, C >::type FloorC(T a_Value)
Floors a value, then casts it to C (an int by default).
const char * m_VanillaNameNBT
const char * m_VanillaName
static const struct @17 g_MobTypeNames[]
Map for eType <-> string Needs to be alpha-sorted by the strings, because binary search is used in St...
eMonsterType
Identifies individual monster type.
AString StrToLower(const AString &s)
Returns a lower-cased copy of the string.
unsigned char Distance(const BlockState Block)
static bool IsSolid(BLOCKTYPE Block)
Is this block solid (player cannot walk through)?
static bool IsTransparent(BLOCKTYPE Block)
Is a block transparent? (https://minecraft.wiki/w/Opacity)
Represents two sets of coords, minimum and maximum for each direction.
bool IsLightValid(void) const
cChunk * GetNeighborChunk(int a_BlockX, int a_BlockZ)
Returns the chunk into which the specified block belongs, by walking the neighbors.
bool IsValid(void) const
Returns true iff the chunk block data is valid (loaded / generated)
void GetBlockTypeMeta(Vector3i a_RelPos, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta) const
void SendLeashEntity(const cEntity &a_Entity, const cEntity &a_EntityLeashedTo)
void SendSpawnMob(const cMonster &a_Mob)
const Vector3d & GetSpeed(void) const
Exported in ManualBindings.
void SetPitch(double a_Pitch)
int GetChunkZ(void) const
void AddPosY(double a_AddPosY)
void AddSpeedX(double a_AddSpeedX)
bool IsPlayer(void) const
void SetHeadYaw(double a_HeadYaw)
void BroadcastDeathMessage(TakeDamageInfo &a_TDI)
Announces a death message on chat about killing the entity.
void SetSpeedX(double a_SpeedX)
Sets the speed in the X axis, leaving the other speed components intact.
virtual bool IsInWater(void) const
Returns true if any part of the entity is in a water block.
void AddSpeed(double a_AddSpeedX, double a_AddSpeedY, double a_AddSpeedZ)
void SetYaw(double a_Yaw)
virtual cItem GetEquippedLeggings(void) const
Returns the currently equipped leggings; empty item if none.
int GetChunkX(void) const
static const UInt32 INVALID_ID
Special ID that is considered an "invalid value", signifying no entity.
void SetSpeedY(double a_SpeedY)
Sets the speed in the Y axis, leaving the other speed components intact.
bool IsTicking(void) const
Returns true if the entity is valid and ticking.
float GetGravity(void) const
void SetSpeedZ(double a_SpeedZ)
Sets the speed in the Z axis, leaving the other speed components intact.
double GetPosX(void) const
virtual cItem GetEquippedBoots(void) const
Returns the currently equipped boots; empty item if none.
double GetPosZ(void) const
void Destroy()
Destroys the entity, schedules it for memory freeing and broadcasts the DestroyEntity packet.
eEntityType GetEntityType(void) const
virtual bool IsOnFire(void) const
void AddLeashedMob(cMonster *a_Monster)
Adds a mob to the leashed list of mobs.
bool IsLeashKnot(void) const
double GetPosY(void) const
void AddSpeedZ(double a_AddSpeedZ)
virtual bool IsOnGround(void) const
Returns whether the entity is on ground or not.
float GetHeight(void) const
virtual cItem GetEquippedWeapon(void) const
Returns the curently equipped weapon; empty item if none.
virtual bool DoTakeDamage(TakeDamageInfo &a_TDI)
Makes this entity take damage specified in the a_TDI.
bool m_bOnGround
Stores if the entity is on the ground.
virtual cItem GetEquippedHelmet(void) const
Returns the currently equipped helmet; empty item if none.
virtual void OnRightClicked(cPlayer &a_Player)
Called when the specified player right-clicks this entity.
const Vector3d & GetPosition(void) const
Exported in ManualBindings.
bool HasAnyMobLeashed() const
Returs whether the entity has any mob leashed to it.
void RemoveLeashedMob(cMonster *a_Monster)
Removes a mob from the leashed list of mobs.
virtual void BroadcastMovementUpdate(const cClientHandle *a_Exclude=nullptr)
Updates clients of changes in the entity.
void StartBurning(int a_TicksLeftBurning)
Puts the entity on fire for the specified amount of ticks.
cWorld * GetWorld(void) const
virtual cItem GetEquippedChestplate(void) const
Returns the currently equipped chestplate; empty item if none.
static cLeashKnot * FindKnotAtPos(cWorldInterface &a_WorldInterface, Vector3i a_BlockPos)
Returns the leash knot entity representing the knot at the specified position.
virtual void HandleFalling(void)
void TargetingMe(cMonster *a_Monster)
Add the monster to the list of monsters targeting this pawn.
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
virtual void OnRemoveFromWorld(cWorld &a_World) override
Called when the entity is removed from a world.
void NoLongerTargetingMe(cMonster *a_Monster)
Remove the monster from the list of monsters targeting this pawn.
virtual void KilledBy(TakeDamageInfo &a_TDI) override
Called when the health drops below zero.
void AwardAchievement(CustomStatistic a_Ach)
Awards the player an achievement.
StatisticsManager & GetStatistics()
Return the associated statistic and achievement manager.
const cUUID & GetUUID(void) const
Returns the UUID that has been read from the client, or nil if not available.
const cItem & GetEquippedItem(void) const
bool IsGameModeCreative(void) const
Returns true if the player is in Creative mode, either explicitly, or by inheriting from current worl...
cInventory & GetInventory(void)
bool CanMobsTarget(void) const
Returns true if the player can be targeted by Mobs.
IntType RandInt(IntType a_Min, IntType a_Max)
Return a random IntType in the range [a_Min, a_Max].
bool RemoveOneEquippedItem(void)
Removes one item out of the currently equipped item stack, returns true if successful,...
char GetMaxStackSize(void) const
Returns the maximum amount of stacked items of this type.
This class bridges a vector of cItem for safe access via Lua.
bool ContainsType(const cItem &a_Item)
void Add(const cItem &a_Item)
static eMonsterType ItemDamageToMonsterType(short a_ItemDamage)
Converts the Spawn egg item damage to the monster type to spawn.
static bool LineOfSightTrace(cWorld &a_World, const Vector3d &a_Start, const Vector3d &a_End, int a_Sight)
Returns true if the two positions are within line of sight (not obscured by blocks).
cMonster(const AString &a_ConfigName, eMonsterType a_MobType, const AString &a_SoundHurt, const AString &a_SoundDeath, const AString &a_SoundAmbient, float a_Width, float a_Height)
Creates the mob object.
std::chrono::milliseconds m_IdleInterval
int m_LoveCooldown
If above 0, the monster is in cooldown mode and will refuse to breed.
void SetPitchAndYawFromDestination(bool a_IsFollowingPath)
Sets the body yaw and head yaw.
cPathFinder m_PathFinder
The pathfinder instance handles pathfinding for this monster.
virtual bool IsNetherNative(void)
Returns whether this mob spawns in the Nether in Vanilla.
void ResetAttackCooldown()
void SetCustomName(const AString &a_CustomName)
Sets the custom name of the monster.
double m_RelativeWalkSpeed
static AString MobTypeToVanillaName(eMonsterType a_MobType)
Translates MobType enum to the vanilla name of the mob, empty string if unknown.
eFamily GetMobFamily(void) const
virtual void InStateChasing(std::chrono::milliseconds a_Dt, cChunk &a_Chunk)
Vector3d m_FinalDestination
Coordinates for the ultimate, final destination.
virtual void CheckEventLostPlayer(std::chrono::milliseconds a_Dt)
bool WouldBurnAt(Vector3d a_Location, cChunk &a_Chunk)
virtual void GetFollowedItems(cItems &a_Items)
Returns the items that the animal of this class follows when a player holds it in hand.
static cTickTime GetSpawnDelay(cMonster::eFamily a_MobFamily)
Returns the spawn delay (number of game ticks between spawn attempts) for the given mob family.
virtual bool IsTame(void) const
void LoveTick(void)
Does the whole love and breeding processing.
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 AddRandomRareDropItem(cItems &a_Drops, cItems &a_Items, unsigned int a_LootingLevel)
Adds one rare item out of the list of rare items a_Items modified by the looting level a_LootingLevel...
virtual void KilledBy(TakeDamageInfo &a_TDI) override
Called when the health drops below zero.
cUUID m_Feeder
Remembers the player is was last fed by for statistics tracking.
static std::unique_ptr< cMonster > NewMonsterFromType(eMonsterType a_MobType)
Creates a new object of the specified mob.
void SetTarget(cPawn *a_NewTarget)
Sets the target that this mob will chase.
void SetLeashToPos(Vector3d *pos)
Sets entity position to where is leashed this mob.
void GetMonsterConfig(const AString &a_Name)
Reads the monster configuration for the specified monster name and assigns it to this object.
cMonster * m_LovePartner
The monster's breeding partner.
virtual void HandleFalling(void) override
virtual void MoveToPosition(const Vector3d &a_Position)
Engage pathfinder and tell it to calculate a path to a given position, and move the mob accordingly.
float m_DropChanceChestplate
void AddRandomDropItem(cItems &a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth=0)
Adds a random number of a_Item between a_Min and a_Max to itemdrops a_Drops.
void MoveToWayPoint(cChunk &a_Chunk)
Move in a straight line to the next waypoint in the path, will jump if needed.
bool m_PathfinderActivated
Stores if pathfinder is being used - set when final destination is set, and unset when stopped moving...
static eFamily FamilyFromType(eMonsterType a_MobType)
Returns the mob family based on the type.
cPawn * GetTarget()
Returns the current target.
void HandleDaylightBurning(cChunk &a_Chunk, bool WouldBurn)
void EngageLoveMode(cMonster *a_Partner)
Start the mating process.
void UnsafeUnsetTarget()
Unset the target without notifying the target entity.
cPawn * m_Target
A pointer to the entity this mobile is aiming to reach.
virtual void GetBreedingItems(cItems &a_Items)
Returns the items that make the animal breed - this is usually the same as the ones that make the ani...
virtual bool DoTakeDamage(TakeDamageInfo &a_TDI) override
Makes this entity take damage specified in the a_TDI.
virtual void InStateEscaping(std::chrono::milliseconds a_Dt, cChunk &a_Chunk)
bool IsLeashed() const
Returns whether the monster is leashed to an entity.
virtual void OnRightClicked(cPlayer &a_Player) override
Called when the specified player right-clicks this entity.
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
int FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ)
Finds the lowest non-air block position (not the highest, as cWorld::GetHeight does) If current Y is ...
virtual bool IsUndead(void)
Returns whether this mob is undead (skeleton, zombie, etc.)
eMonsterType GetMobType(void) const
bool IsInLove() const
Returns whether the monster has just been fed and is ready to mate.
cEntity * m_LeashedTo
Entity leashed to.
cEntity * GetLeashedTo() const
Returns the entity to where this mob is leashed, returns nullptr if it's not leashed.
static AString MobTypeToString(eMonsterType a_MobType)
Translates MobType enum to a string, empty string if unknown.
int m_MatingTimer
The monster is engaged in mating, once this reaches zero, a baby will be born.
void Unleash(bool a_ShouldDropLeashPickup)
Unleash the monster.
std::chrono::milliseconds m_DestroyTimer
void AddRandomWeaponDropItem(cItems &a_Drops, unsigned int a_LootingLevel)
Adds weapon that is equipped with the chance saved in m_DropChance... to the drop.
void AddRandomArmorDropItem(cItems &a_Drops, unsigned int a_LootingLevel)
Adds armor that is equipped with the chance saved in m_DropChance... to the drop.
Vector3d m_NextWayPointPosition
Coordinates of the next position that should be reached.
bool m_IsLeashActionJustDone
Mob has ben leashed or unleashed in current player action.
bool DoesPosYRequireJump(double a_PosY)
Returns whether the monster needs to jump to reach a given height.
enum cMonster::MState m_EMState
bool m_WasLastTargetAPlayer
virtual void EventSeePlayer(cPlayer *a_Player, cChunk &a_Chunk)
std::chrono::milliseconds m_LoseSightAbandonTargetTimer
bool m_CustomNameAlwaysVisible
int m_TicksSinceLastDamaged
void ResetLoveMode()
Finish the mating process.
virtual void EventLosePlayer(void)
void SetCustomNameAlwaysVisible(bool a_CustomNameAlwaysVisible)
Sets the custom name visiblity of this monster.
void LeashTo(cEntity &a_Entity, bool a_ShouldBroadcast=true)
Leash the monster to an entity.
int m_AttackCoolDownTicksLeft
std::unique_ptr< Vector3d > m_LeashToPos
Entity pos where this mob was leashed to.
virtual void InStateIdle(std::chrono::milliseconds a_Dt, cChunk &a_Chunk)
bool CanBeLeashed() const
Returns whether the mob can be leashed.
virtual void InheritFromParents(cMonster *a_Parent1, cMonster *a_Parent2)
Called after the baby is born, allows the baby to inherit the parents' properties (color,...
float m_DropChanceLeggings
bool ReachedFinalDestination(void)
Returns if the ultimate, final destination has been reached.
void RightClickFeed(cPlayer &a_Player)
Right click call to process feeding.
void CalcLeashActions(std::chrono::milliseconds a_Dt)
Leash calculations inside Tick function.
void AddRandomUncommonDropItem(cItems &a_Drops, float a_Chance, short a_Item, short a_ItemHealth=0)
Adds a item a_Item with the chance of a_Chance (in percent) to itemdrops a_Drops.
static AString MobTypeToVanillaNBT(eMonsterType a_MobType)
Translates the MobType enum to the vanilla nbt name.
int m_LoveTimer
If above 0, the monster is in love mode, and will breed if a nearby monster is also in love mode.
virtual void CheckEventSeePlayer(cChunk &a_Chunk)
virtual void OnRemoveFromWorld(cWorld &a_World) override
Called when the entity is removed from a world.
static eMonsterType StringToMobType(const AString &a_MobTypeName)
Translates MobType string to the enum, mtInvalidType if not recognized.
void StopMovingToPosition()
Stops pathfinding.
ePathFinderStatus GetNextWayPoint(cChunk &a_Chunk, const Vector3d &a_Source, Vector3d *a_Destination, Vector3d *a_OutputWaypoint, bool a_DontCare=false)
Updates the PathFinder's internal state and returns a waypoint.
static eVillagerType GetRandomProfession()
Returns a random Profession.
void AssignAttributes(cMonster *a_Monster, const AString &a_Name)
cMonsterConfig * GetMonsterConfig(void)
std::unordered_map< CustomStatistic, StatValue > Custom
Vector3< T > addedY(T a_AddY) const
Returns a copy of this vector moved by the specified amount on the y axis.
Vector3< int > Floor(void) const
Returns a new Vector3i with coords set to std::floor() of this vector's coords.
double SqrLength(void) const
virtual void BroadcastUnleashEntity(const cEntity &a_Entity) override
bool DoWithPlayerByUUID(const cUUID &a_PlayerUUID, cPlayerListCallback a_Callback)
Finds the player over his uuid and calls the callback.
UInt32 SpawnExperienceOrb(Vector3d a_Pos, int a_Reward)
Spawns an experience orb at the given location with the given reward.
void QueueLightChunk(int a_ChunkX, int a_ChunkZ, std::unique_ptr< cChunkCoordCallback > a_Callback={})
Queues a chunk for lighting; a_Callback is called after the chunk is lighted.
virtual UInt32 SpawnMob(double a_PosX, double a_PosY, double a_PosZ, eMonsterType a_MonsterType, bool a_Baby=false) override
Spawns a mob of the specified type.
virtual void BroadcastEntityMetadata(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
virtual void BroadcastEntityAnimation(const cEntity &a_Entity, EntityAnimation a_Animation, const cClientHandle *a_Exclude=nullptr) override
BLOCKTYPE GetBlock(Vector3i a_BlockPos) const
Returns the block type at the specified position.
bool DoWithEntityByID(UInt32 a_UniqueID, cEntityCallback a_Callback)
Calls the callback if the entity with the specified ID is found, with the entity object as the callba...
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 BroadcastLeashEntity(const cEntity &a_Entity, const cEntity &a_EntityLeashedTo) override
void SpawnItemPickups(const cItems &a_Pickups, Vector3i a_BlockPos, double a_FlyAwaySpeed=1.0, bool a_IsPlayerCreated=false)
Spawns item pickups for each item in the list.
virtual std::vector< UInt32 > SpawnSplitExperienceOrbs(Vector3d a_Pos, int a_Reward) override
Spawns experience orbs of the specified total value at the given location.
virtual void BroadcastSoundEffect(const AString &a_SoundName, Vector3d a_Position, float a_Volume, float a_Pitch, const cClientHandle *a_Exclude=nullptr) override
bool DoWithNearestPlayer(Vector3d a_Pos, double a_RangeLimit, cPlayerListCallback a_Callback, bool a_CheckLineOfSight=true, bool a_IgnoreSpectator=true)
Calls the callback for nearest player for given position, Returns false if player not found,...
virtual bool ForEachPlayer(cPlayerListCallback a_Callback) override
Calls the callback for each player in the list; returns true if all players processed,...