10 #include "../Mobs/Villager.h"
11 #include "../ClientHandle.h"
13 #include "../Server.h"
14 #include "../Bindings/PluginManager.h"
15 #include "../Registries/Items.h"
44 auto & OtherPickup =
static_cast<cPickup &
>(a_Entity);
48 short CombineCount =
static_cast<short>(
Item.m_ItemCount);
54 if (CombineCount <= 0)
62 if (
Item.m_ItemCount <= 0)
99 Super(etPickup, a_Pos, 0.25f, 0.25f),
103 m_bIsPlayerCreated(IsPlayerCreated),
104 m_bCanCombine(a_CanCombine),
155 m_Timer = std::chrono::milliseconds(0);
157 if (
m_Timer > std::chrono::milliseconds(500))
181 if (
m_Timer > std::chrono::milliseconds(500))
239 auto & Mob =
static_cast<cMonster &
>(a_Dest);
248 auto & Villager =
static_cast<cVillager &
>(Mob);
262 m_Timer = std::chrono::milliseconds(0);
271 auto & Player =
static_cast<cPlayer &
>(a_Dest);
274 if (Player.IsGameModeSpectator())
308 m_Timer = std::chrono::milliseconds(0);
#define GET_AND_VERIFY_CURRENT_CHUNK(ChunkVarName, X, Z)
std::chrono::duration< signed int, std::ratio_multiply< std::chrono::milliseconds::period, std::ratio< 50 > >> cTickTime
bool IsVillagerFood(short a_ItemType)
unsigned char Distance(const BlockState Block)
bool CallHookCollectingPickup(cPlayer &a_Player, cPickup &a_Pickup)
bool ForEachEntity(cEntityCallback a_Callback) const
Calls the callback for each entity; returns true if all entities processed, false if the callback abo...
void SendSpawnEntity(const cEntity &a_Entity)
void SendEntityMetadata(const cEntity &a_Entity)
bool IsPlayer(void) const
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk)
bool IsPickup(void) const
void SetHealth(float a_Health)
Sets the health of this entity; doesn't broadcast any hurt animation.
bool IsTicking(void) const
Returns true if the entity is valid and ticking.
void SetGravity(float a_Gravity)
void SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ)
Sets the speed of the entity, measured in m / sec.
UInt32 GetUniqueID(void) const
void Destroy()
Destroys the entity, schedules it for memory freeing and broadcasts the DestroyEntity packet.
virtual bool IsOnFire(void) const
virtual bool IsOnGround(void) const
Returns whether the entity is on ground or not.
void SetAirDrag(float a_AirDrag)
virtual bool DoTakeDamage(TakeDamageInfo &a_TDI)
Makes this entity take damage specified in the a_TDI.
void SetMaxHealth(float a_MaxHealth)
Sets the maximum value for the health.
const Vector3d & GetPosition(void) const
Exported in ManualBindings.
virtual void BroadcastMovementUpdate(const cClientHandle *a_Exclude=nullptr)
Updates clients of changes in the entity.
cWorld * GetWorld(void) const
bool FoundMatchingPickup()
cPickupCombiningCallback(Vector3d a_Position, cPickup *a_Pickup)
bool m_FoundMatchingPickup
bool operator()(cEntity &a_Entity)
std::chrono::milliseconds m_Lifetime
bool CollectedBy(cEntity &a_Dest)
cPickup(Vector3d a_Pos, const cItem &a_Item, bool IsPlayerCreated, Vector3f a_Speed=Vector3f(), int a_LifetimeTicks=6000, bool a_CanCombine=true)
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
void SetAge(int a_Age)
Set the number of ticks that this entity has existed.
std::chrono::milliseconds m_Timer
The number of ticks that the entity has existed / timer between collect and destroy; in msec.
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 bool DoTakeDamage(TakeDamageInfo &a_TDI) override
Makes this entity take damage specified in the a_TDI.
bool CanCombine(void) const
Returns whether this pickup is allowed to combine with other similar pickups.
cInventory & GetInventory(void)
char AddItem(const cItem &a_ItemStack, bool a_AllowNewStacks=true)
Adds as many items out of a_ItemStack as can fit.
cItem & AddCount(char a_AmountToAdd)
Adds the specified count to this object and returns the reference to self (useful for chaining)
char GetMaxStackSize(void) const
Returns the maximum amount of stacked items of this type.
char AddItem(cItem &a_ItemStack, bool a_AllowNewStacks=true, int a_PrioritySlot=-1)
Adds as many items out of a_ItemStack as can fit.
cItemGrid & GetInventory(void)
Returns the villager hidden inventory (8 slots).
cPluginManager * GetPluginManager(void)
virtual void BroadcastEntityMetadata(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
virtual void BroadcastCollectEntity(const cEntity &a_Collected, const cEntity &a_Collector, unsigned a_Count, const cClientHandle *a_Exclude=nullptr) override
virtual void BroadcastSoundEffect(const AString &a_SoundName, Vector3d a_Position, float a_Volume, float a_Pitch, const cClientHandle *a_Exclude=nullptr) override