2026-03-01 12:16:08 +08:00
# pragma once
# include "AgableMob.h"
# include "Creature.h"
class Level ;
class CompoundTag ;
class DamageSource ;
class Animal : public AgableMob , public Creature
{
private :
static const int DATA_IN_LOVE = 13 ; // 4J added
// int inLove; // 4J removed - now synched data
int loveTime ;
weak_ptr < Player > loveCause ;
public :
Animal ( Level * level ) ;
protected :
virtual void defineSynchedData ( ) ;
virtual void serverAiMobStep ( ) ;
public :
virtual void aiStep ( ) ;
protected :
2026-03-02 17:37:16 +07:00
virtual void checkHurtTarget ( shared_ptr < Entity > target , float d ) ;
2026-03-01 12:16:08 +08:00
private :
2026-03-02 17:37:16 +07:00
virtual void breedWith ( shared_ptr < Animal > target ) ;
2026-03-01 12:16:08 +08:00
public :
virtual float getWalkTargetValue ( int x , int y , int z ) ;
public :
2026-03-03 03:04:10 +08:00
virtual bool hurt ( DamageSource * source , float dmg ) ;
2026-03-01 12:16:08 +08:00
virtual void addAdditonalSaveData ( CompoundTag * tag ) ;
virtual void readAdditionalSaveData ( CompoundTag * tag ) ;
protected :
2026-03-02 17:37:16 +07:00
virtual shared_ptr < Entity > findAttackTarget ( ) ;
2026-03-01 12:16:08 +08:00
public :
virtual bool canSpawn ( ) ;
virtual int getAmbientSoundInterval ( ) ;
protected :
virtual bool removeWhenFarAway ( ) ;
2026-03-02 17:37:16 +07:00
virtual int getExperienceReward ( shared_ptr < Player > killedBy ) ;
2026-03-01 12:16:08 +08:00
public :
2026-03-02 17:37:16 +07:00
virtual bool isFood ( shared_ptr < ItemInstance > itemInstance ) ;
2026-03-03 03:04:10 +08:00
virtual bool mobInteract ( shared_ptr < Player > player ) ;
2026-03-01 12:16:08 +08:00
protected :
int getInLoveValue ( ) ; // 4J added
public :
void setInLoveValue ( int value ) ; // 4J added
2026-03-02 17:37:16 +07:00
void setInLove ( shared_ptr < Player > player ) ; // 4J added, then modified to match latest Java for XboxOne achievements
2026-03-03 03:04:10 +08:00
virtual void setInLove ( ) ;
2026-03-02 17:37:16 +07:00
shared_ptr < Player > getLoveCause ( ) ;
2026-03-01 12:16:08 +08:00
bool isInLove ( ) ;
void resetLove ( ) ;
2026-03-02 17:37:16 +07:00
virtual bool canMate ( shared_ptr < Animal > partner ) ;
2026-03-03 03:04:10 +08:00
virtual void handleEntityEvent ( byte id ) ;
2026-03-01 12:16:08 +08:00
// 4J added for determining whether animals are enclosed or not
private :
bool m_isDespawnProtected ;
static const int MAX_WANDER_DISTANCE = 20 ; // Maximum distance that the entity can wander before being considered as not enclosed & therefore not protected (in tiles)
short m_minWanderX , m_maxWanderX ; // Bounding x values that this has moved since last being set to protected ( in tiles )
short m_minWanderZ , m_maxWanderZ ; // Bounding z values that this has moved since last being set to protected ( in tiles )
void updateDespawnProtectedState ( ) ;
public :
virtual bool isDespawnProtected ( ) ;
virtual void setDespawnProtected ( ) ;
} ;